hatchet-sdk 1.18.1__py3-none-any.whl → 1.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hatchet-sdk might be problematic. Click here for more details.
- {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/METADATA +2 -3
- {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/RECORD +4 -225
- hatchet_sdk/v0/__init__.py +0 -251
- hatchet_sdk/v0/client.py +0 -119
- hatchet_sdk/v0/clients/admin.py +0 -541
- hatchet_sdk/v0/clients/dispatcher/action_listener.py +0 -422
- hatchet_sdk/v0/clients/dispatcher/dispatcher.py +0 -204
- hatchet_sdk/v0/clients/event_ts.py +0 -28
- hatchet_sdk/v0/clients/events.py +0 -182
- hatchet_sdk/v0/clients/rest/__init__.py +0 -307
- hatchet_sdk/v0/clients/rest/api/__init__.py +0 -19
- hatchet_sdk/v0/clients/rest/api/api_token_api.py +0 -858
- hatchet_sdk/v0/clients/rest/api/default_api.py +0 -2259
- hatchet_sdk/v0/clients/rest/api/event_api.py +0 -2548
- hatchet_sdk/v0/clients/rest/api/github_api.py +0 -331
- hatchet_sdk/v0/clients/rest/api/healthcheck_api.py +0 -483
- hatchet_sdk/v0/clients/rest/api/log_api.py +0 -449
- hatchet_sdk/v0/clients/rest/api/metadata_api.py +0 -728
- hatchet_sdk/v0/clients/rest/api/rate_limits_api.py +0 -423
- hatchet_sdk/v0/clients/rest/api/slack_api.py +0 -577
- hatchet_sdk/v0/clients/rest/api/sns_api.py +0 -872
- hatchet_sdk/v0/clients/rest/api/step_run_api.py +0 -2202
- hatchet_sdk/v0/clients/rest/api/tenant_api.py +0 -4430
- hatchet_sdk/v0/clients/rest/api/user_api.py +0 -2888
- hatchet_sdk/v0/clients/rest/api/worker_api.py +0 -858
- hatchet_sdk/v0/clients/rest/api/workflow_api.py +0 -6312
- hatchet_sdk/v0/clients/rest/api/workflow_run_api.py +0 -1932
- hatchet_sdk/v0/clients/rest/api/workflow_runs_api.py +0 -610
- hatchet_sdk/v0/clients/rest/api_client.py +0 -759
- hatchet_sdk/v0/clients/rest/api_response.py +0 -22
- hatchet_sdk/v0/clients/rest/configuration.py +0 -611
- hatchet_sdk/v0/clients/rest/exceptions.py +0 -200
- hatchet_sdk/v0/clients/rest/models/__init__.py +0 -274
- hatchet_sdk/v0/clients/rest/models/accept_invite_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/api_error.py +0 -102
- hatchet_sdk/v0/clients/rest/models/api_errors.py +0 -100
- hatchet_sdk/v0/clients/rest/models/api_meta.py +0 -144
- hatchet_sdk/v0/clients/rest/models/api_meta_auth.py +0 -85
- hatchet_sdk/v0/clients/rest/models/api_meta_integration.py +0 -88
- hatchet_sdk/v0/clients/rest/models/api_meta_posthog.py +0 -90
- hatchet_sdk/v0/clients/rest/models/api_resource_meta.py +0 -98
- hatchet_sdk/v0/clients/rest/models/api_token.py +0 -105
- hatchet_sdk/v0/clients/rest/models/bulk_create_event_request.py +0 -100
- hatchet_sdk/v0/clients/rest/models/bulk_create_event_response.py +0 -110
- hatchet_sdk/v0/clients/rest/models/cancel_event_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/cancel_step_run_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/concurrency_limit_strategy.py +0 -39
- hatchet_sdk/v0/clients/rest/models/create_api_token_request.py +0 -92
- hatchet_sdk/v0/clients/rest/models/create_api_token_response.py +0 -83
- hatchet_sdk/v0/clients/rest/models/create_cron_workflow_trigger_request.py +0 -98
- hatchet_sdk/v0/clients/rest/models/create_event_request.py +0 -95
- hatchet_sdk/v0/clients/rest/models/create_pull_request_from_step_run.py +0 -83
- hatchet_sdk/v0/clients/rest/models/create_sns_integration_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/create_tenant_alert_email_group_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/create_tenant_invite_request.py +0 -86
- hatchet_sdk/v0/clients/rest/models/create_tenant_request.py +0 -84
- hatchet_sdk/v0/clients/rest/models/cron_workflows.py +0 -131
- hatchet_sdk/v0/clients/rest/models/cron_workflows_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/cron_workflows_method.py +0 -37
- hatchet_sdk/v0/clients/rest/models/cron_workflows_order_by_field.py +0 -37
- hatchet_sdk/v0/clients/rest/models/event.py +0 -143
- hatchet_sdk/v0/clients/rest/models/event_data.py +0 -83
- hatchet_sdk/v0/clients/rest/models/event_key_list.py +0 -98
- hatchet_sdk/v0/clients/rest/models/event_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/event_order_by_direction.py +0 -37
- hatchet_sdk/v0/clients/rest/models/event_order_by_field.py +0 -36
- hatchet_sdk/v0/clients/rest/models/event_update_cancel200_response.py +0 -85
- hatchet_sdk/v0/clients/rest/models/event_workflow_run_summary.py +0 -116
- hatchet_sdk/v0/clients/rest/models/events.py +0 -110
- hatchet_sdk/v0/clients/rest/models/get_step_run_diff_response.py +0 -100
- hatchet_sdk/v0/clients/rest/models/github_app_installation.py +0 -107
- hatchet_sdk/v0/clients/rest/models/github_branch.py +0 -86
- hatchet_sdk/v0/clients/rest/models/github_repo.py +0 -86
- hatchet_sdk/v0/clients/rest/models/info_get_version200_response.py +0 -83
- hatchet_sdk/v0/clients/rest/models/job.py +0 -132
- hatchet_sdk/v0/clients/rest/models/job_run.py +0 -176
- hatchet_sdk/v0/clients/rest/models/job_run_status.py +0 -41
- hatchet_sdk/v0/clients/rest/models/link_github_repository_request.py +0 -106
- hatchet_sdk/v0/clients/rest/models/list_api_tokens_response.py +0 -110
- hatchet_sdk/v0/clients/rest/models/list_github_app_installations_response.py +0 -112
- hatchet_sdk/v0/clients/rest/models/list_pull_requests_response.py +0 -100
- hatchet_sdk/v0/clients/rest/models/list_slack_webhooks.py +0 -110
- hatchet_sdk/v0/clients/rest/models/list_sns_integrations.py +0 -110
- hatchet_sdk/v0/clients/rest/models/log_line.py +0 -94
- hatchet_sdk/v0/clients/rest/models/log_line_level.py +0 -39
- hatchet_sdk/v0/clients/rest/models/log_line_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/log_line_order_by_direction.py +0 -37
- hatchet_sdk/v0/clients/rest/models/log_line_order_by_field.py +0 -36
- hatchet_sdk/v0/clients/rest/models/pagination_response.py +0 -95
- hatchet_sdk/v0/clients/rest/models/pull_request.py +0 -112
- hatchet_sdk/v0/clients/rest/models/pull_request_state.py +0 -37
- hatchet_sdk/v0/clients/rest/models/queue_metrics.py +0 -97
- hatchet_sdk/v0/clients/rest/models/rate_limit.py +0 -117
- hatchet_sdk/v0/clients/rest/models/rate_limit_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_direction.py +0 -37
- hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_field.py +0 -38
- hatchet_sdk/v0/clients/rest/models/recent_step_runs.py +0 -118
- hatchet_sdk/v0/clients/rest/models/reject_invite_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/replay_event_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_response.py +0 -100
- hatchet_sdk/v0/clients/rest/models/rerun_step_run_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/schedule_workflow_run_request.py +0 -92
- hatchet_sdk/v0/clients/rest/models/scheduled_run_status.py +0 -42
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows.py +0 -149
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_method.py +0 -37
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_order_by_field.py +0 -37
- hatchet_sdk/v0/clients/rest/models/semaphore_slots.py +0 -113
- hatchet_sdk/v0/clients/rest/models/slack_webhook.py +0 -127
- hatchet_sdk/v0/clients/rest/models/sns_integration.py +0 -114
- hatchet_sdk/v0/clients/rest/models/step.py +0 -123
- hatchet_sdk/v0/clients/rest/models/step_run.py +0 -202
- hatchet_sdk/v0/clients/rest/models/step_run_archive.py +0 -142
- hatchet_sdk/v0/clients/rest/models/step_run_archive_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/step_run_diff.py +0 -91
- hatchet_sdk/v0/clients/rest/models/step_run_event.py +0 -122
- hatchet_sdk/v0/clients/rest/models/step_run_event_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/step_run_event_reason.py +0 -52
- hatchet_sdk/v0/clients/rest/models/step_run_event_severity.py +0 -38
- hatchet_sdk/v0/clients/rest/models/step_run_status.py +0 -44
- hatchet_sdk/v0/clients/rest/models/tenant.py +0 -118
- hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group.py +0 -98
- hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group_list.py +0 -112
- hatchet_sdk/v0/clients/rest/models/tenant_alerting_settings.py +0 -143
- hatchet_sdk/v0/clients/rest/models/tenant_invite.py +0 -120
- hatchet_sdk/v0/clients/rest/models/tenant_invite_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/tenant_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/tenant_member.py +0 -123
- hatchet_sdk/v0/clients/rest/models/tenant_member_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/tenant_member_role.py +0 -38
- hatchet_sdk/v0/clients/rest/models/tenant_queue_metrics.py +0 -116
- hatchet_sdk/v0/clients/rest/models/tenant_resource.py +0 -40
- hatchet_sdk/v0/clients/rest/models/tenant_resource_limit.py +0 -135
- hatchet_sdk/v0/clients/rest/models/tenant_resource_policy.py +0 -102
- hatchet_sdk/v0/clients/rest/models/tenant_step_run_queue_metrics.py +0 -83
- hatchet_sdk/v0/clients/rest/models/trigger_workflow_run_request.py +0 -91
- hatchet_sdk/v0/clients/rest/models/update_tenant_alert_email_group_request.py +0 -83
- hatchet_sdk/v0/clients/rest/models/update_tenant_invite_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/update_tenant_request.py +0 -137
- hatchet_sdk/v0/clients/rest/models/update_worker_request.py +0 -87
- hatchet_sdk/v0/clients/rest/models/user.py +0 -126
- hatchet_sdk/v0/clients/rest/models/user_change_password_request.py +0 -88
- hatchet_sdk/v0/clients/rest/models/user_login_request.py +0 -86
- hatchet_sdk/v0/clients/rest/models/user_register_request.py +0 -91
- hatchet_sdk/v0/clients/rest/models/user_tenant_memberships_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/user_tenant_public.py +0 -86
- hatchet_sdk/v0/clients/rest/models/webhook_worker.py +0 -100
- hatchet_sdk/v0/clients/rest/models/webhook_worker_create_request.py +0 -94
- hatchet_sdk/v0/clients/rest/models/webhook_worker_create_response.py +0 -98
- hatchet_sdk/v0/clients/rest/models/webhook_worker_created.py +0 -102
- hatchet_sdk/v0/clients/rest/models/webhook_worker_list_response.py +0 -110
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request.py +0 -102
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request_list_response.py +0 -104
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request_method.py +0 -38
- hatchet_sdk/v0/clients/rest/models/worker.py +0 -239
- hatchet_sdk/v0/clients/rest/models/worker_label.py +0 -102
- hatchet_sdk/v0/clients/rest/models/worker_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/worker_runtime_info.py +0 -103
- hatchet_sdk/v0/clients/rest/models/worker_runtime_sdks.py +0 -38
- hatchet_sdk/v0/clients/rest/models/worker_type.py +0 -38
- hatchet_sdk/v0/clients/rest/models/workflow.py +0 -165
- hatchet_sdk/v0/clients/rest/models/workflow_concurrency.py +0 -107
- hatchet_sdk/v0/clients/rest/models/workflow_deployment_config.py +0 -136
- hatchet_sdk/v0/clients/rest/models/workflow_kind.py +0 -38
- hatchet_sdk/v0/clients/rest/models/workflow_list.py +0 -120
- hatchet_sdk/v0/clients/rest/models/workflow_metrics.py +0 -97
- hatchet_sdk/v0/clients/rest/models/workflow_run.py +0 -188
- hatchet_sdk/v0/clients/rest/models/workflow_run_cancel200_response.py +0 -85
- hatchet_sdk/v0/clients/rest/models/workflow_run_list.py +0 -110
- hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_direction.py +0 -37
- hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_field.py +0 -39
- hatchet_sdk/v0/clients/rest/models/workflow_run_shape.py +0 -186
- hatchet_sdk/v0/clients/rest/models/workflow_run_status.py +0 -42
- hatchet_sdk/v0/clients/rest/models/workflow_run_triggered_by.py +0 -112
- hatchet_sdk/v0/clients/rest/models/workflow_runs_cancel_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics.py +0 -94
- hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics_counts.py +0 -104
- hatchet_sdk/v0/clients/rest/models/workflow_tag.py +0 -84
- hatchet_sdk/v0/clients/rest/models/workflow_trigger_cron_ref.py +0 -86
- hatchet_sdk/v0/clients/rest/models/workflow_trigger_event_ref.py +0 -86
- hatchet_sdk/v0/clients/rest/models/workflow_triggers.py +0 -141
- hatchet_sdk/v0/clients/rest/models/workflow_update_request.py +0 -85
- hatchet_sdk/v0/clients/rest/models/workflow_version.py +0 -170
- hatchet_sdk/v0/clients/rest/models/workflow_version_concurrency.py +0 -114
- hatchet_sdk/v0/clients/rest/models/workflow_version_definition.py +0 -85
- hatchet_sdk/v0/clients/rest/models/workflow_version_meta.py +0 -123
- hatchet_sdk/v0/clients/rest/models/workflow_workers_count.py +0 -95
- hatchet_sdk/v0/clients/rest/rest.py +0 -187
- hatchet_sdk/v0/clients/rest/tenacity_utils.py +0 -39
- hatchet_sdk/v0/clients/rest_client.py +0 -622
- hatchet_sdk/v0/clients/run_event_listener.py +0 -260
- hatchet_sdk/v0/clients/workflow_listener.py +0 -277
- hatchet_sdk/v0/connection.py +0 -63
- hatchet_sdk/v0/context/__init__.py +0 -1
- hatchet_sdk/v0/context/context.py +0 -446
- hatchet_sdk/v0/context/worker_context.py +0 -28
- hatchet_sdk/v0/features/cron.py +0 -286
- hatchet_sdk/v0/features/scheduled.py +0 -248
- hatchet_sdk/v0/hatchet.py +0 -310
- hatchet_sdk/v0/labels.py +0 -10
- hatchet_sdk/v0/loader.py +0 -244
- hatchet_sdk/v0/metadata.py +0 -2
- hatchet_sdk/v0/opentelemetry/instrumentor.py +0 -393
- hatchet_sdk/v0/rate_limit.py +0 -126
- hatchet_sdk/v0/semver.py +0 -30
- hatchet_sdk/v0/token.py +0 -27
- hatchet_sdk/v0/utils/aio_utils.py +0 -137
- hatchet_sdk/v0/utils/backoff.py +0 -9
- hatchet_sdk/v0/utils/types.py +0 -8
- hatchet_sdk/v0/utils/typing.py +0 -12
- hatchet_sdk/v0/v2/callable.py +0 -202
- hatchet_sdk/v0/v2/concurrency.py +0 -47
- hatchet_sdk/v0/v2/hatchet.py +0 -224
- hatchet_sdk/v0/worker/__init__.py +0 -1
- hatchet_sdk/v0/worker/action_listener_process.py +0 -294
- hatchet_sdk/v0/worker/runner/run_loop_manager.py +0 -112
- hatchet_sdk/v0/worker/runner/runner.py +0 -460
- hatchet_sdk/v0/worker/runner/utils/capture_logs.py +0 -81
- hatchet_sdk/v0/worker/runner/utils/error_with_traceback.py +0 -6
- hatchet_sdk/v0/worker/worker.py +0 -391
- hatchet_sdk/v0/workflow.py +0 -261
- hatchet_sdk/v0/workflow_run.py +0 -59
- {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
from importlib.metadata import version
|
|
2
|
-
from typing import Any, Callable, Collection, Coroutine
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
from opentelemetry.context import Context
|
|
6
|
-
from opentelemetry.instrumentation.instrumentor import ( # type: ignore[attr-defined]
|
|
7
|
-
BaseInstrumentor,
|
|
8
|
-
)
|
|
9
|
-
from opentelemetry.instrumentation.utils import unwrap
|
|
10
|
-
from opentelemetry.metrics import MeterProvider, NoOpMeterProvider, get_meter
|
|
11
|
-
from opentelemetry.trace import (
|
|
12
|
-
NoOpTracerProvider,
|
|
13
|
-
StatusCode,
|
|
14
|
-
TracerProvider,
|
|
15
|
-
get_tracer,
|
|
16
|
-
get_tracer_provider,
|
|
17
|
-
)
|
|
18
|
-
from opentelemetry.trace.propagation.tracecontext import (
|
|
19
|
-
TraceContextTextMapPropagator,
|
|
20
|
-
)
|
|
21
|
-
from wrapt import wrap_function_wrapper # type: ignore[import-untyped]
|
|
22
|
-
except (RuntimeError, ImportError, ModuleNotFoundError):
|
|
23
|
-
raise ModuleNotFoundError(
|
|
24
|
-
"To use the HatchetInstrumentor, you must install Hatchet's `otel` extra using (e.g.) `pip install hatchet-sdk[otel]`"
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
import hatchet_sdk
|
|
28
|
-
from hatchet_sdk.contracts.events_pb2 import Event
|
|
29
|
-
from hatchet_sdk.v0.clients.admin import (
|
|
30
|
-
AdminClient,
|
|
31
|
-
TriggerWorkflowOptions,
|
|
32
|
-
WorkflowRunDict,
|
|
33
|
-
)
|
|
34
|
-
from hatchet_sdk.v0.clients.dispatcher.action_listener import Action
|
|
35
|
-
from hatchet_sdk.v0.clients.events import (
|
|
36
|
-
BulkPushEventWithMetadata,
|
|
37
|
-
EventClient,
|
|
38
|
-
PushEventOptions,
|
|
39
|
-
)
|
|
40
|
-
from hatchet_sdk.v0.worker.runner.runner import Runner
|
|
41
|
-
from hatchet_sdk.v0.workflow_run import WorkflowRunRef
|
|
42
|
-
|
|
43
|
-
hatchet_sdk_version = version("hatchet-sdk")
|
|
44
|
-
|
|
45
|
-
InstrumentKwargs = TracerProvider | MeterProvider | None
|
|
46
|
-
|
|
47
|
-
OTEL_TRACEPARENT_KEY = "traceparent"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def create_traceparent() -> str | None:
|
|
51
|
-
"""
|
|
52
|
-
Creates and returns a W3C traceparent header value using OpenTelemetry's context propagation.
|
|
53
|
-
|
|
54
|
-
The traceparent header is used to propagate context information across service boundaries
|
|
55
|
-
in distributed tracing systems. It follows the W3C Trace Context specification.
|
|
56
|
-
|
|
57
|
-
:returns: A W3C-formatted traceparent header value if successful, None if the context
|
|
58
|
-
injection fails or no active span exists.\n
|
|
59
|
-
Example: `00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01`
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
carrier: dict[str, str] = {}
|
|
63
|
-
TraceContextTextMapPropagator().inject(carrier)
|
|
64
|
-
|
|
65
|
-
return carrier.get("traceparent")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def parse_carrier_from_metadata(metadata: dict[str, str] | None) -> Context | None:
|
|
69
|
-
"""
|
|
70
|
-
Parses OpenTelemetry trace context from a metadata dictionary.
|
|
71
|
-
|
|
72
|
-
Extracts the trace context from metadata using the W3C Trace Context format,
|
|
73
|
-
specifically looking for the `traceparent` header.
|
|
74
|
-
|
|
75
|
-
:param metadata: A dictionary containing metadata key-value pairs,
|
|
76
|
-
potentially including the `traceparent` header. Can be None.
|
|
77
|
-
|
|
78
|
-
:returns: The extracted OpenTelemetry Context object if a valid `traceparent`
|
|
79
|
-
is found in the metadata, otherwise None.
|
|
80
|
-
|
|
81
|
-
:Example:
|
|
82
|
-
|
|
83
|
-
>>> metadata = {"traceparent": "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01"}
|
|
84
|
-
>>> context = parse_carrier_from_metadata(metadata)
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
if not metadata:
|
|
88
|
-
return None
|
|
89
|
-
|
|
90
|
-
traceparent = metadata.get(OTEL_TRACEPARENT_KEY)
|
|
91
|
-
|
|
92
|
-
if not traceparent:
|
|
93
|
-
return None
|
|
94
|
-
|
|
95
|
-
return TraceContextTextMapPropagator().extract({OTEL_TRACEPARENT_KEY: traceparent})
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def inject_traceparent_into_metadata(
|
|
99
|
-
metadata: dict[str, str], traceparent: str | None = None
|
|
100
|
-
) -> dict[str, str]:
|
|
101
|
-
"""
|
|
102
|
-
Injects OpenTelemetry `traceparent` into a metadata dictionary.
|
|
103
|
-
|
|
104
|
-
Takes a metadata dictionary and an optional `traceparent` string,
|
|
105
|
-
returning a new metadata dictionary with the `traceparent` added under the
|
|
106
|
-
`OTEL_TRACEPARENT_KEY`. If no `traceparent` is provided, it attempts to create one.
|
|
107
|
-
|
|
108
|
-
:param metadata: The metadata dictionary to inject the `traceparent` into.
|
|
109
|
-
|
|
110
|
-
:param traceparent: The `traceparent` string to inject. If None, attempts to use
|
|
111
|
-
the current span.
|
|
112
|
-
|
|
113
|
-
:returns: A new metadata dictionary containing the original metadata plus
|
|
114
|
-
the injected `traceparent`, if one was available or could be created.
|
|
115
|
-
|
|
116
|
-
:Example:
|
|
117
|
-
|
|
118
|
-
>>> metadata = {"key": "value"}
|
|
119
|
-
>>> new_metadata = inject_traceparent(metadata, "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
|
120
|
-
>>> print(new_metadata)
|
|
121
|
-
{"key": "value", "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}
|
|
122
|
-
"""
|
|
123
|
-
|
|
124
|
-
if not traceparent:
|
|
125
|
-
traceparent = create_traceparent()
|
|
126
|
-
|
|
127
|
-
if not traceparent:
|
|
128
|
-
return metadata
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
**metadata,
|
|
132
|
-
OTEL_TRACEPARENT_KEY: traceparent,
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
class HatchetInstrumentor(BaseInstrumentor): # type: ignore[misc]
|
|
137
|
-
def __init__(
|
|
138
|
-
self,
|
|
139
|
-
tracer_provider: TracerProvider | None = None,
|
|
140
|
-
meter_provider: MeterProvider | None = None,
|
|
141
|
-
):
|
|
142
|
-
"""
|
|
143
|
-
Hatchet OpenTelemetry instrumentor.
|
|
144
|
-
|
|
145
|
-
The instrumentor provides an OpenTelemetry integration for Hatchet by setting up
|
|
146
|
-
tracing and metrics collection.
|
|
147
|
-
|
|
148
|
-
:param tracer_provider: TracerProvider | None: The OpenTelemetry TracerProvider to use.
|
|
149
|
-
If not provided, the global tracer provider will be used.
|
|
150
|
-
:param meter_provider: MeterProvider | None: The OpenTelemetry MeterProvider to use.
|
|
151
|
-
If not provided, a no-op meter provider will be used.
|
|
152
|
-
"""
|
|
153
|
-
|
|
154
|
-
self.tracer_provider = tracer_provider or get_tracer_provider()
|
|
155
|
-
self.meter_provider = meter_provider or NoOpMeterProvider()
|
|
156
|
-
|
|
157
|
-
super().__init__()
|
|
158
|
-
|
|
159
|
-
def instrumentation_dependencies(self) -> Collection[str]:
|
|
160
|
-
return tuple()
|
|
161
|
-
|
|
162
|
-
def _instrument(self, **kwargs: InstrumentKwargs) -> None:
|
|
163
|
-
self._tracer = get_tracer(__name__, hatchet_sdk_version, self.tracer_provider)
|
|
164
|
-
self._meter = get_meter(__name__, hatchet_sdk_version, self.meter_provider)
|
|
165
|
-
|
|
166
|
-
wrap_function_wrapper(
|
|
167
|
-
hatchet_sdk,
|
|
168
|
-
"worker.runner.runner.Runner.handle_start_step_run",
|
|
169
|
-
self._wrap_handle_start_step_run,
|
|
170
|
-
)
|
|
171
|
-
wrap_function_wrapper(
|
|
172
|
-
hatchet_sdk,
|
|
173
|
-
"worker.runner.runner.Runner.handle_start_group_key_run",
|
|
174
|
-
self._wrap_handle_get_group_key_run,
|
|
175
|
-
)
|
|
176
|
-
wrap_function_wrapper(
|
|
177
|
-
hatchet_sdk,
|
|
178
|
-
"worker.runner.runner.Runner.handle_cancel_action",
|
|
179
|
-
self._wrap_handle_cancel_action,
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
wrap_function_wrapper(
|
|
183
|
-
hatchet_sdk,
|
|
184
|
-
"clients.events.EventClient.push",
|
|
185
|
-
self._wrap_push_event,
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
wrap_function_wrapper(
|
|
189
|
-
hatchet_sdk,
|
|
190
|
-
"clients.events.EventClient.bulk_push",
|
|
191
|
-
self._wrap_bulk_push_event,
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
wrap_function_wrapper(
|
|
195
|
-
hatchet_sdk,
|
|
196
|
-
"clients.admin.AdminClient.run_workflow",
|
|
197
|
-
self._wrap_run_workflow,
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
wrap_function_wrapper(
|
|
201
|
-
hatchet_sdk,
|
|
202
|
-
"clients.admin.AdminClientAioImpl.run_workflow",
|
|
203
|
-
self._wrap_async_run_workflow,
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
wrap_function_wrapper(
|
|
207
|
-
hatchet_sdk,
|
|
208
|
-
"clients.admin.AdminClient.run_workflows",
|
|
209
|
-
self._wrap_run_workflows,
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
wrap_function_wrapper(
|
|
213
|
-
hatchet_sdk,
|
|
214
|
-
"clients.admin.AdminClientAioImpl.run_workflows",
|
|
215
|
-
self._wrap_async_run_workflows,
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
219
|
-
async def _wrap_handle_start_step_run(
|
|
220
|
-
self,
|
|
221
|
-
wrapped: Callable[[Action], Coroutine[None, None, Exception | None]],
|
|
222
|
-
instance: Runner,
|
|
223
|
-
args: tuple[Action],
|
|
224
|
-
kwargs: Any,
|
|
225
|
-
) -> Exception | None:
|
|
226
|
-
action = args[0]
|
|
227
|
-
traceparent = parse_carrier_from_metadata(action.additional_metadata)
|
|
228
|
-
|
|
229
|
-
with self._tracer.start_as_current_span(
|
|
230
|
-
"hatchet.start_step_run",
|
|
231
|
-
attributes=action.otel_attributes,
|
|
232
|
-
context=traceparent,
|
|
233
|
-
) as span:
|
|
234
|
-
result = await wrapped(*args, **kwargs)
|
|
235
|
-
|
|
236
|
-
if isinstance(result, Exception):
|
|
237
|
-
span.set_status(StatusCode.ERROR, str(result))
|
|
238
|
-
|
|
239
|
-
return result
|
|
240
|
-
|
|
241
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
242
|
-
async def _wrap_handle_get_group_key_run(
|
|
243
|
-
self,
|
|
244
|
-
wrapped: Callable[[Action], Coroutine[None, None, Exception | None]],
|
|
245
|
-
instance: Runner,
|
|
246
|
-
args: tuple[Action],
|
|
247
|
-
kwargs: Any,
|
|
248
|
-
) -> Exception | None:
|
|
249
|
-
action = args[0]
|
|
250
|
-
|
|
251
|
-
with self._tracer.start_as_current_span(
|
|
252
|
-
"hatchet.get_group_key_run",
|
|
253
|
-
attributes=action.otel_attributes,
|
|
254
|
-
) as span:
|
|
255
|
-
result = await wrapped(*args, **kwargs)
|
|
256
|
-
|
|
257
|
-
if isinstance(result, Exception):
|
|
258
|
-
span.set_status(StatusCode.ERROR, str(result))
|
|
259
|
-
|
|
260
|
-
return result
|
|
261
|
-
|
|
262
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
263
|
-
async def _wrap_handle_cancel_action(
|
|
264
|
-
self,
|
|
265
|
-
wrapped: Callable[[str], Coroutine[None, None, Exception | None]],
|
|
266
|
-
instance: Runner,
|
|
267
|
-
args: tuple[str],
|
|
268
|
-
kwargs: Any,
|
|
269
|
-
) -> Exception | None:
|
|
270
|
-
step_run_id = args[0]
|
|
271
|
-
|
|
272
|
-
with self._tracer.start_as_current_span(
|
|
273
|
-
"hatchet.cancel_step_run",
|
|
274
|
-
attributes={
|
|
275
|
-
"hatchet.step_run_id": step_run_id,
|
|
276
|
-
},
|
|
277
|
-
):
|
|
278
|
-
return await wrapped(*args, **kwargs)
|
|
279
|
-
|
|
280
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
281
|
-
def _wrap_push_event(
|
|
282
|
-
self,
|
|
283
|
-
wrapped: Callable[[str, dict[str, Any], PushEventOptions | None], Event],
|
|
284
|
-
instance: EventClient,
|
|
285
|
-
args: tuple[
|
|
286
|
-
str,
|
|
287
|
-
dict[str, Any],
|
|
288
|
-
PushEventOptions | None,
|
|
289
|
-
],
|
|
290
|
-
kwargs: dict[str, str | dict[str, Any] | PushEventOptions | None],
|
|
291
|
-
) -> Event:
|
|
292
|
-
with self._tracer.start_as_current_span(
|
|
293
|
-
"hatchet.push_event",
|
|
294
|
-
):
|
|
295
|
-
return wrapped(*args, **kwargs)
|
|
296
|
-
|
|
297
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
298
|
-
def _wrap_bulk_push_event(
|
|
299
|
-
self,
|
|
300
|
-
wrapped: Callable[
|
|
301
|
-
[list[BulkPushEventWithMetadata], PushEventOptions | None], list[Event]
|
|
302
|
-
],
|
|
303
|
-
instance: EventClient,
|
|
304
|
-
args: tuple[
|
|
305
|
-
list[BulkPushEventWithMetadata],
|
|
306
|
-
PushEventOptions | None,
|
|
307
|
-
],
|
|
308
|
-
kwargs: dict[str, list[BulkPushEventWithMetadata] | PushEventOptions | None],
|
|
309
|
-
) -> list[Event]:
|
|
310
|
-
with self._tracer.start_as_current_span(
|
|
311
|
-
"hatchet.bulk_push_event",
|
|
312
|
-
):
|
|
313
|
-
return wrapped(*args, **kwargs)
|
|
314
|
-
|
|
315
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
316
|
-
def _wrap_run_workflow(
|
|
317
|
-
self,
|
|
318
|
-
wrapped: Callable[[str, Any, TriggerWorkflowOptions | None], WorkflowRunRef],
|
|
319
|
-
instance: AdminClient,
|
|
320
|
-
args: tuple[str, Any, TriggerWorkflowOptions | None],
|
|
321
|
-
kwargs: dict[str, str | Any | TriggerWorkflowOptions | None],
|
|
322
|
-
) -> WorkflowRunRef:
|
|
323
|
-
with self._tracer.start_as_current_span(
|
|
324
|
-
"hatchet.run_workflow",
|
|
325
|
-
):
|
|
326
|
-
return wrapped(*args, **kwargs)
|
|
327
|
-
|
|
328
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
329
|
-
async def _wrap_async_run_workflow(
|
|
330
|
-
self,
|
|
331
|
-
wrapped: Callable[
|
|
332
|
-
[str, Any, TriggerWorkflowOptions | None],
|
|
333
|
-
Coroutine[None, None, WorkflowRunRef],
|
|
334
|
-
],
|
|
335
|
-
instance: AdminClient,
|
|
336
|
-
args: tuple[str, Any, TriggerWorkflowOptions | None],
|
|
337
|
-
kwargs: dict[str, str | Any | TriggerWorkflowOptions | None],
|
|
338
|
-
) -> WorkflowRunRef:
|
|
339
|
-
with self._tracer.start_as_current_span(
|
|
340
|
-
"hatchet.run_workflow",
|
|
341
|
-
):
|
|
342
|
-
return await wrapped(*args, **kwargs)
|
|
343
|
-
|
|
344
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
345
|
-
def _wrap_run_workflows(
|
|
346
|
-
self,
|
|
347
|
-
wrapped: Callable[
|
|
348
|
-
[list[WorkflowRunDict], TriggerWorkflowOptions | None], list[WorkflowRunRef]
|
|
349
|
-
],
|
|
350
|
-
instance: AdminClient,
|
|
351
|
-
args: tuple[
|
|
352
|
-
list[WorkflowRunDict],
|
|
353
|
-
TriggerWorkflowOptions | None,
|
|
354
|
-
],
|
|
355
|
-
kwargs: dict[str, list[WorkflowRunDict] | TriggerWorkflowOptions | None],
|
|
356
|
-
) -> list[WorkflowRunRef]:
|
|
357
|
-
with self._tracer.start_as_current_span(
|
|
358
|
-
"hatchet.run_workflows",
|
|
359
|
-
):
|
|
360
|
-
return wrapped(*args, **kwargs)
|
|
361
|
-
|
|
362
|
-
## IMPORTANT: Keep these types in sync with the wrapped method's signature
|
|
363
|
-
async def _wrap_async_run_workflows(
|
|
364
|
-
self,
|
|
365
|
-
wrapped: Callable[
|
|
366
|
-
[list[WorkflowRunDict], TriggerWorkflowOptions | None],
|
|
367
|
-
Coroutine[None, None, list[WorkflowRunRef]],
|
|
368
|
-
],
|
|
369
|
-
instance: AdminClient,
|
|
370
|
-
args: tuple[
|
|
371
|
-
list[WorkflowRunDict],
|
|
372
|
-
TriggerWorkflowOptions | None,
|
|
373
|
-
],
|
|
374
|
-
kwargs: dict[str, list[WorkflowRunDict] | TriggerWorkflowOptions | None],
|
|
375
|
-
) -> list[WorkflowRunRef]:
|
|
376
|
-
with self._tracer.start_as_current_span(
|
|
377
|
-
"hatchet.run_workflows",
|
|
378
|
-
):
|
|
379
|
-
return await wrapped(*args, **kwargs)
|
|
380
|
-
|
|
381
|
-
def _uninstrument(self, **kwargs: InstrumentKwargs) -> None:
|
|
382
|
-
self.tracer_provider = NoOpTracerProvider()
|
|
383
|
-
self.meter_provider = NoOpMeterProvider()
|
|
384
|
-
|
|
385
|
-
unwrap(hatchet_sdk, "worker.runner.runner.Runner.handle_start_step_run")
|
|
386
|
-
unwrap(hatchet_sdk, "worker.runner.runner.Runner.handle_start_group_key_run")
|
|
387
|
-
unwrap(hatchet_sdk, "worker.runner.runner.Runner.handle_cancel_action")
|
|
388
|
-
unwrap(hatchet_sdk, "clients.events.EventClient.push")
|
|
389
|
-
unwrap(hatchet_sdk, "clients.events.EventClient.bulk_push")
|
|
390
|
-
unwrap(hatchet_sdk, "clients.admin.AdminClient.run_workflow")
|
|
391
|
-
unwrap(hatchet_sdk, "clients.admin.AdminClientAioImpl.run_workflow")
|
|
392
|
-
unwrap(hatchet_sdk, "clients.admin.AdminClient.run_workflows")
|
|
393
|
-
unwrap(hatchet_sdk, "clients.admin.AdminClientAioImpl.run_workflows")
|
hatchet_sdk/v0/rate_limit.py
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from typing import Union
|
|
3
|
-
|
|
4
|
-
from celpy import CELEvalError, Environment
|
|
5
|
-
|
|
6
|
-
from hatchet_sdk.contracts.workflows_pb2 import CreateStepRateLimit
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def validate_cel_expression(expr: str) -> bool:
|
|
10
|
-
env = Environment()
|
|
11
|
-
try:
|
|
12
|
-
env.compile(expr)
|
|
13
|
-
return True
|
|
14
|
-
except CELEvalError:
|
|
15
|
-
return False
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class RateLimitDuration:
|
|
19
|
-
SECOND = "SECOND"
|
|
20
|
-
MINUTE = "MINUTE"
|
|
21
|
-
HOUR = "HOUR"
|
|
22
|
-
DAY = "DAY"
|
|
23
|
-
WEEK = "WEEK"
|
|
24
|
-
MONTH = "MONTH"
|
|
25
|
-
YEAR = "YEAR"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@dataclass
|
|
29
|
-
class RateLimit:
|
|
30
|
-
"""
|
|
31
|
-
Represents a rate limit configuration for a step in a workflow.
|
|
32
|
-
|
|
33
|
-
This class allows for both static and dynamic rate limiting based on various parameters.
|
|
34
|
-
It supports both simple integer values and Common Expression Language (CEL) expressions
|
|
35
|
-
for dynamic evaluation.
|
|
36
|
-
|
|
37
|
-
Attributes:
|
|
38
|
-
static_key (str, optional): A static key for rate limiting.
|
|
39
|
-
dynamic_key (str, optional): A CEL expression for dynamic key evaluation.
|
|
40
|
-
units (int or str, default=1): The number of units or a CEL expression for dynamic unit calculation.
|
|
41
|
-
limit (int or str, optional): The rate limit value or a CEL expression for dynamic limit calculation.
|
|
42
|
-
duration (str, default=RateLimitDuration.MINUTE): The window duration of the rate limit.
|
|
43
|
-
key (str, optional): Deprecated. Use static_key instead.
|
|
44
|
-
|
|
45
|
-
Usage:
|
|
46
|
-
1. Static rate limit:
|
|
47
|
-
rate_limit = RateLimit(static_key="external-api", units=100)
|
|
48
|
-
> NOTE: if you want to use a static key, you must first put the rate limit: hatchet.admin.put_rate_limit("external-api", 200, RateLimitDuration.SECOND)
|
|
49
|
-
|
|
50
|
-
2. Dynamic rate limit with CEL expressions:
|
|
51
|
-
rate_limit = RateLimit(
|
|
52
|
-
dynamic_key="input.user_id",
|
|
53
|
-
units="input.units",
|
|
54
|
-
limit="input.limit * input.user_tier"
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
Note:
|
|
58
|
-
- Either static_key or dynamic_key must be set, but not both.
|
|
59
|
-
- When using dynamic_key, limit must also be set.
|
|
60
|
-
- CEL expressions are validated upon instantiation.
|
|
61
|
-
|
|
62
|
-
Raises:
|
|
63
|
-
ValueError: If invalid combinations of attributes are provided or if CEL expressions are invalid.
|
|
64
|
-
DeprecationWarning: If the deprecated 'key' attribute is used.
|
|
65
|
-
"""
|
|
66
|
-
|
|
67
|
-
key: Union[str, None] = None
|
|
68
|
-
static_key: Union[str, None] = None
|
|
69
|
-
dynamic_key: Union[str, None] = None
|
|
70
|
-
units: Union[int, str] = 1
|
|
71
|
-
limit: Union[int, str, None] = None
|
|
72
|
-
duration: RateLimitDuration = RateLimitDuration.MINUTE
|
|
73
|
-
|
|
74
|
-
_req: CreateStepRateLimit = None
|
|
75
|
-
|
|
76
|
-
def __post_init__(self):
|
|
77
|
-
# juggle the key and key_expr fields
|
|
78
|
-
key = self.static_key
|
|
79
|
-
key_expression = self.dynamic_key
|
|
80
|
-
|
|
81
|
-
if self.key is not None:
|
|
82
|
-
DeprecationWarning(
|
|
83
|
-
"key is deprecated and will be removed in a future release, please use static_key instead"
|
|
84
|
-
)
|
|
85
|
-
key = self.key
|
|
86
|
-
|
|
87
|
-
if key_expression is not None:
|
|
88
|
-
if key is not None:
|
|
89
|
-
raise ValueError("Cannot have both static key and dynamic key set")
|
|
90
|
-
|
|
91
|
-
key = key_expression
|
|
92
|
-
if not validate_cel_expression(key_expression):
|
|
93
|
-
raise ValueError(f"Invalid CEL expression: {key_expression}")
|
|
94
|
-
|
|
95
|
-
# juggle the units and units_expr fields
|
|
96
|
-
units = None
|
|
97
|
-
units_expression = None
|
|
98
|
-
if isinstance(self.units, int):
|
|
99
|
-
units = self.units
|
|
100
|
-
else:
|
|
101
|
-
if not validate_cel_expression(self.units):
|
|
102
|
-
raise ValueError(f"Invalid CEL expression: {self.units}")
|
|
103
|
-
units_expression = self.units
|
|
104
|
-
|
|
105
|
-
# juggle the limit and limit_expr fields
|
|
106
|
-
limit_expression = None
|
|
107
|
-
|
|
108
|
-
if self.limit:
|
|
109
|
-
if isinstance(self.limit, int):
|
|
110
|
-
limit_expression = f"{self.limit}"
|
|
111
|
-
else:
|
|
112
|
-
if not validate_cel_expression(self.limit):
|
|
113
|
-
raise ValueError(f"Invalid CEL expression: {self.limit}")
|
|
114
|
-
limit_expression = self.limit
|
|
115
|
-
|
|
116
|
-
if key_expression is not None and limit_expression is None:
|
|
117
|
-
raise ValueError("CEL based keys requires limit to be set")
|
|
118
|
-
|
|
119
|
-
self._req = CreateStepRateLimit(
|
|
120
|
-
key=key,
|
|
121
|
-
key_expr=key_expression,
|
|
122
|
-
units=units,
|
|
123
|
-
units_expr=units_expression,
|
|
124
|
-
limit_values_expr=limit_expression,
|
|
125
|
-
duration=self.duration,
|
|
126
|
-
)
|
hatchet_sdk/v0/semver.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
def bump_minor_version(version: str) -> str:
|
|
2
|
-
"""
|
|
3
|
-
Bumps the minor version of a semantic version string. NOTE this doesn't follow full semver,
|
|
4
|
-
missing the build metadata and pre-release version.
|
|
5
|
-
|
|
6
|
-
:param version: A semantic version string in the format major.minor.patch
|
|
7
|
-
:return: A string with the minor version bumped and patch version reset to 0
|
|
8
|
-
:raises ValueError: If the input is not a valid semantic version string
|
|
9
|
-
"""
|
|
10
|
-
# if it starts with a v, remove it
|
|
11
|
-
had_v = False
|
|
12
|
-
if version.startswith("v"):
|
|
13
|
-
version = version[1:]
|
|
14
|
-
had_v = True
|
|
15
|
-
|
|
16
|
-
parts = version.split(".")
|
|
17
|
-
if len(parts) != 3:
|
|
18
|
-
raise ValueError(f"Invalid semantic version: {version}")
|
|
19
|
-
|
|
20
|
-
try:
|
|
21
|
-
major, minor, _ = map(int, parts)
|
|
22
|
-
except ValueError:
|
|
23
|
-
raise ValueError(f"Invalid semantic version: {version}")
|
|
24
|
-
|
|
25
|
-
new_minor = minor + 1
|
|
26
|
-
new_version = f"{major}.{new_minor}.0"
|
|
27
|
-
|
|
28
|
-
if had_v:
|
|
29
|
-
new_version = "v" + new_version
|
|
30
|
-
return new_version
|
hatchet_sdk/v0/token.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def get_tenant_id_from_jwt(token: str) -> str:
|
|
6
|
-
claims = extract_claims_from_jwt(token)
|
|
7
|
-
|
|
8
|
-
return claims.get("sub")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def get_addresses_from_jwt(token: str) -> (str, str):
|
|
12
|
-
claims = extract_claims_from_jwt(token)
|
|
13
|
-
|
|
14
|
-
return claims.get("server_url"), claims.get("grpc_broadcast_address")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def extract_claims_from_jwt(token: str):
|
|
18
|
-
parts = token.split(".")
|
|
19
|
-
if len(parts) != 3:
|
|
20
|
-
raise ValueError("Invalid token format")
|
|
21
|
-
|
|
22
|
-
claims_part = parts[1]
|
|
23
|
-
claims_part += "=" * ((4 - len(claims_part) % 4) % 4) # Padding for base64 decoding
|
|
24
|
-
claims_data = base64.urlsafe_b64decode(claims_part)
|
|
25
|
-
claims = json.loads(claims_data)
|
|
26
|
-
|
|
27
|
-
return claims
|