Skip to content

feat: Handle request list user input #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Nov 20, 2024
Merged

Conversation

Pijukatel
Copy link
Contributor

@Pijukatel Pijukatel commented Nov 18, 2024

Add helper function to handle request list inputs.

Closes: #310

@github-actions github-actions bot added this to the 103rd sprint - Tooling team milestone Nov 18, 2024
@github-actions github-actions bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Nov 18, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Pull Request Tookit has failed!

Pull request is neither linked to an issue or epic nor labeled as adhoc!

@Pijukatel Pijukatel changed the title Handle request list user input feat: Handle request list user input Nov 18, 2024
@Pijukatel Pijukatel marked this pull request as ready for review November 18, 2024 17:28
@Pijukatel Pijukatel requested a review from janbuchar November 18, 2024 17:28
@vdusek vdusek self-requested a review November 19, 2024 09:36
@janbuchar janbuchar self-requested a review November 19, 2024 09:50
Finalize tests.
Split to its own file.
Fix typing issues

WIP
TODO: Finish test for it.
WIP
Add test for checking all genrated request properties.
Add helper class for input keys
Add top level Input class for handling actor inputs.
Add few more tests for regex
It had too many assumptions that users might not be interested in.
Users should create such Input helper classes based on their specific inputs and their names.
Update TCH001, TCH002, TCH003 uses.
@Pijukatel Pijukatel force-pushed the handle-request-list-user-input branch from c237c66 to 6ff9e90 Compare November 19, 2024 12:59
@Pijukatel
Copy link
Contributor Author

Sorry for the force-push. Due to my previous mainly Gerrit-based experience I was expecting this Rebase button in Github to do something more clean in the log...

@@ -141,6 +141,9 @@ indent-style = "space"
docstring-quotes = "double"
inline-quotes = "single"

[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel", "crawlee.configuration.Configuration"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though crawlee.configuration.Configuration inherits from pydantic_settings.BaseSettings and that one from pydantic.BaseModel, ruff has some issues in following inheritance hierarchy too far. So until that changes, some models will have to be explicitly mentioned even though they inherit from pydantic.BaseModel.
See closed issue where this is described as known limitation to certain degree:
astral-sh/ruff#8725

Copy link
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good! Just a bunch of nits to iron out...

headers=request_input.headers,
user_data=request_input.user_data,
)
for request_input in simple_url_inputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw thinking about this class reminded me of this: apify/crawlee#2466

Basically, in JS Crawlee, we used to instantiate all the requests at the beginning (like here), but that ate up much more memory than just keeping the POJO objects (I guess dicts in Python) and instantiating the Request class only once we really need it. Maybe Python handles this better (has slimmer class instances).

It was at that time we learned that users love to make >1.000.000 requests long RLs 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a valid point, but I think it will be done later in apify/crawlee-python#99 as the current class is openly not as mature as the JS version:

https://github.com/apify/crawlee-python/blob/master/src/crawlee/storages/_request_list.py#L23

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's make sure the SDK supports everything the platform can offer first, then we can optimize.

@Pijukatel Pijukatel requested a review from janbuchar November 20, 2024 12:23
Copy link
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last suggestion 🙂

url_input_adapter = TypeAdapter(list[Union[_RequestsFromUrlInput, _SimpleUrlInput]])


# @docs_group('Classes') # Not yet available in crawlee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR here #328

headers=request_input.headers,
user_data=request_input.user_data,
)
for request_input in simple_url_inputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's make sure the SDK supports everything the platform can offer first, then we can optimize.

@janbuchar janbuchar self-requested a review November 20, 2024 16:04
@janbuchar janbuchar merged commit c14fb9a into master Nov 20, 2024
27 checks passed
@janbuchar janbuchar deleted the handle-request-list-user-input branch November 20, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle request list and proxy configuration inputs in a user-friendly way
5 participants