Skip to content
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

Add sessions subpackage #108

Merged
merged 16 commits into from
Apr 15, 2024
Merged

Add sessions subpackage #108

merged 16 commits into from
Apr 15, 2024

Conversation

vdusek
Copy link
Collaborator

@vdusek vdusek commented Apr 15, 2024

Description

  • Introducing two new classes: Session & SessionPool.
  • The state of the SessionPool can be persisted into KVS, Pydantic models are utilized for this case.
    • Storing cookies and user data as dictionaries. Initially, I considered using a CookiesType union with http.cookie_jar.CookieJar, httpx.Cookies, and dictionary, but these types were not serializable by Pydantic. However, both can be converted to dictionaries, so there should be no problem with cookies being a dict type.
  • There have been slight modifications to the EventManager, which now functions as a context manager (same as LocalEventManager).
    • Additionally, I enhanced its test coverage.

Issue

Tests

src/crawlee/sessions/__init__.py                                        2      0   100%
src/crawlee/sessions/models.py                                         54      5    91%
src/crawlee/sessions/session.py                                        89      2    98%
src/crawlee/sessions/session_pool.py                                  133     20    85%

@vdusek vdusek self-assigned this Apr 15, 2024
@vdusek vdusek requested a review from janbuchar April 15, 2024 07:29
@github-actions github-actions bot added this to the 87th sprint - Tooling team milestone Apr 15, 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 Apr 15, 2024
Copy link
Collaborator

@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.

The implementation is super nice, I like how you split the (de)serialization from the business logic. I found a bunch of things to nitpick though 🙂

src/crawlee/sessions/models.py Outdated Show resolved Hide resolved
src/crawlee/sessions/models.py Show resolved Hide resolved
src/crawlee/sessions/models.py Outdated Show resolved Hide resolved
src/crawlee/sessions/models.py Outdated Show resolved Hide resolved
src/crawlee/sessions/session.py Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
@vdusek vdusek requested a review from janbuchar April 15, 2024 13:54
src/crawlee/sessions/session.py Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Show resolved Hide resolved
src/crawlee/sessions/session_pool.py Outdated Show resolved Hide resolved
@vdusek vdusek requested a review from janbuchar April 15, 2024 15:04
@vdusek vdusek merged commit 29b166e into master Apr 15, 2024
19 checks passed
@vdusek vdusek deleted the add-sessions branch April 15, 2024 15:11
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.

2 participants