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

Belanger/dynamic rate limits #207

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "hatchet"]
path = hatchet
url = [email protected]:hatchet-dev/hatchet.git
branch = main
branch = belanger/dynamic-rate-limits
32 changes: 32 additions & 0 deletions examples/rate_limit/dynamic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from dotenv import load_dotenv

from hatchet_sdk import Context, Hatchet
from hatchet_sdk.rate_limit import RateLimit, RateLimitDuration

load_dotenv()

hatchet = Hatchet(debug=True)


@hatchet.workflow(on_events=["rate_limit:create"])
class RateLimitWorkflow:

@hatchet.step(
rate_limits=[
RateLimit(
dynamic_key=f'"LIMIT:"+input.group',
units="input.units",
limit="input.limit",
)
]
)
def step1(self, context: Context):
print("executed step1")
pass


def main():
worker = hatchet.worker("rate-limit-worker", max_runs=10)
worker.register_workflow(RateLimitWorkflow())

worker.start()
1 change: 0 additions & 1 deletion hatchet
Submodule hatchet deleted from 2f3ea9
16 changes: 16 additions & 0 deletions hatchet_sdk/clients/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from hatchet_sdk.clients.rest.api.healthcheck_api import HealthcheckApi
from hatchet_sdk.clients.rest.api.log_api import LogApi
from hatchet_sdk.clients.rest.api.metadata_api import MetadataApi
from hatchet_sdk.clients.rest.api.rate_limits_api import RateLimitsApi
from hatchet_sdk.clients.rest.api.slack_api import SlackApi
from hatchet_sdk.clients.rest.api.sns_api import SNSApi
from hatchet_sdk.clients.rest.api.step_run_api import StepRunApi
Expand Down Expand Up @@ -56,6 +57,12 @@
from hatchet_sdk.clients.rest.models.api_meta_posthog import APIMetaPosthog
from hatchet_sdk.clients.rest.models.api_resource_meta import APIResourceMeta
from hatchet_sdk.clients.rest.models.api_token import APIToken
from hatchet_sdk.clients.rest.models.bulk_create_event_request import (
BulkCreateEventRequest,
)
from hatchet_sdk.clients.rest.models.bulk_create_event_response import (
BulkCreateEventResponse,
)
from hatchet_sdk.clients.rest.models.cancel_event_request import CancelEventRequest
from hatchet_sdk.clients.rest.models.create_api_token_request import (
CreateAPITokenRequest,
Expand Down Expand Up @@ -116,6 +123,14 @@
from hatchet_sdk.clients.rest.models.pull_request import PullRequest
from hatchet_sdk.clients.rest.models.pull_request_state import PullRequestState
from hatchet_sdk.clients.rest.models.queue_metrics import QueueMetrics
from hatchet_sdk.clients.rest.models.rate_limit import RateLimit
from hatchet_sdk.clients.rest.models.rate_limit_list import RateLimitList
from hatchet_sdk.clients.rest.models.rate_limit_order_by_direction import (
RateLimitOrderByDirection,
)
from hatchet_sdk.clients.rest.models.rate_limit_order_by_field import (
RateLimitOrderByField,
)
from hatchet_sdk.clients.rest.models.recent_step_runs import RecentStepRuns
from hatchet_sdk.clients.rest.models.reject_invite_request import RejectInviteRequest
from hatchet_sdk.clients.rest.models.replay_event_request import ReplayEventRequest
Expand Down Expand Up @@ -239,3 +254,4 @@
WorkflowVersionDefinition,
)
from hatchet_sdk.clients.rest.models.workflow_version_meta import WorkflowVersionMeta
from hatchet_sdk.clients.rest.models.workflow_workers_count import WorkflowWorkersCount
1 change: 1 addition & 0 deletions hatchet_sdk/clients/rest/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hatchet_sdk.clients.rest.api.healthcheck_api import HealthcheckApi
from hatchet_sdk.clients.rest.api.log_api import LogApi
from hatchet_sdk.clients.rest.api.metadata_api import MetadataApi
from hatchet_sdk.clients.rest.api.rate_limits_api import RateLimitsApi
from hatchet_sdk.clients.rest.api.slack_api import SlackApi
from hatchet_sdk.clients.rest.api.sns_api import SNSApi
from hatchet_sdk.clients.rest.api.step_run_api import StepRunApi
Expand Down
Loading
Loading