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

Support batches API #1062

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ellnix
Copy link
Contributor

@ellnix ellnix commented Jan 17, 2025

Pull Request

Related issue

Fixes #1050

@ellnix ellnix force-pushed the batches-methods-1050 branch from daf6e60 to cbb59ca Compare January 17, 2025 14:11
Copy link
Contributor Author

@ellnix ellnix left a comment

Choose a reason for hiding this comment

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

Batches are made of tasks, so it made sense to me for them to be handled by the TaskHandler, and be tested side by side with tasks.

As always, let me know if I did something stupid 😄

@@ -113,3 +113,46 @@ def __init__(self, resp: Dict[str, Any]) -> None:
self.total: int = resp["total"]
self.from_: int = resp["from"]
self.next_: int = resp["next"]


class Batch(CamelBase):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept this class mostly the same as the Task model, including (some) of the validations.

I used Optional[*] instead of the Union[*, None] which was widely used in Task.


class Batch(CamelBase):
uid: int
details: Optional[Dict[str, Any]] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if any of this is legacy syntax, I tried to maintain the same style as Task as much as possible.

Copy link
Contributor Author

@ellnix ellnix Jan 17, 2025

Choose a reason for hiding this comment

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

Even though in the previous PR I would have just done:

details: Dict[str, Any]

Additionally, I'm assuming Dict is fine here (instead of Mapping) since we know that we get Dicts as responses from web requests.

@ellnix ellnix changed the title Batches methods 1050 Support batches API Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1.12.0] Add methods for the batches API
1 participant