hatchet-sdk 0.47.1__py3-none-any.whl → 1.0.0a1__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/__init__.py +45 -25
- hatchet_sdk/client.py +19 -94
- hatchet_sdk/clients/admin.py +309 -389
- hatchet_sdk/clients/dispatcher/action_listener.py +131 -109
- hatchet_sdk/clients/dispatcher/dispatcher.py +39 -37
- hatchet_sdk/clients/durable_event_listener.py +327 -0
- hatchet_sdk/clients/event_ts.py +23 -10
- hatchet_sdk/clients/events.py +96 -99
- hatchet_sdk/clients/rest/__init__.py +35 -0
- hatchet_sdk/clients/rest/api/__init__.py +2 -0
- hatchet_sdk/clients/rest/api/log_api.py +258 -0
- hatchet_sdk/clients/rest/api/task_api.py +2200 -0
- hatchet_sdk/clients/rest/api/workflow_runs_api.py +1274 -116
- hatchet_sdk/clients/rest/api_client.py +1 -1
- hatchet_sdk/clients/rest/configuration.py +8 -1
- hatchet_sdk/clients/rest/exceptions.py +21 -0
- hatchet_sdk/clients/rest/models/__init__.py +33 -0
- hatchet_sdk/clients/rest/models/tenant.py +4 -0
- hatchet_sdk/clients/rest/models/tenant_version.py +37 -0
- hatchet_sdk/clients/rest/models/update_tenant_request.py +7 -0
- hatchet_sdk/clients/rest/models/v1_cancel_task_request.py +104 -0
- hatchet_sdk/clients/rest/models/v1_dag_children.py +102 -0
- hatchet_sdk/clients/rest/models/v1_log_line.py +94 -0
- hatchet_sdk/clients/rest/models/v1_log_line_level.py +39 -0
- hatchet_sdk/clients/rest/models/v1_log_line_list.py +110 -0
- hatchet_sdk/clients/rest/models/v1_replay_task_request.py +104 -0
- hatchet_sdk/clients/rest/models/v1_task.py +174 -0
- hatchet_sdk/clients/rest/models/v1_task_event.py +118 -0
- hatchet_sdk/clients/rest/models/v1_task_event_list.py +110 -0
- hatchet_sdk/clients/rest/models/v1_task_event_type.py +55 -0
- hatchet_sdk/clients/rest/models/v1_task_filter.py +106 -0
- hatchet_sdk/clients/rest/models/v1_task_point_metric.py +92 -0
- hatchet_sdk/clients/rest/models/v1_task_point_metrics.py +100 -0
- hatchet_sdk/clients/rest/models/v1_task_run_metric.py +88 -0
- hatchet_sdk/clients/rest/models/v1_task_run_status.py +40 -0
- hatchet_sdk/clients/rest/models/v1_task_status.py +40 -0
- hatchet_sdk/clients/rest/models/v1_task_summary.py +228 -0
- hatchet_sdk/clients/rest/models/v1_task_summary_list.py +110 -0
- hatchet_sdk/clients/rest/models/v1_trigger_workflow_run_request.py +95 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run.py +171 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run_details.py +145 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run_display_name.py +98 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run_display_name_list.py +114 -0
- hatchet_sdk/clients/rest/models/v1_workflow_type.py +37 -0
- hatchet_sdk/clients/rest/models/workflow_run_shape_item_for_workflow_run_details.py +104 -0
- hatchet_sdk/clients/rest/rest.py +37 -26
- hatchet_sdk/clients/rest/tenacity_utils.py +1 -1
- hatchet_sdk/clients/rest_client.py +153 -116
- hatchet_sdk/clients/run_event_listener.py +65 -60
- hatchet_sdk/clients/workflow_listener.py +75 -66
- hatchet_sdk/config.py +117 -0
- hatchet_sdk/connection.py +27 -13
- hatchet_sdk/context/__init__.py +0 -1
- hatchet_sdk/context/context.py +118 -280
- hatchet_sdk/contracts/dispatcher_pb2_grpc.py +1 -1
- hatchet_sdk/contracts/events_pb2.py +2 -2
- hatchet_sdk/contracts/events_pb2_grpc.py +1 -1
- hatchet_sdk/contracts/v1/dispatcher_pb2.py +36 -0
- hatchet_sdk/contracts/v1/dispatcher_pb2.pyi +38 -0
- hatchet_sdk/contracts/v1/dispatcher_pb2_grpc.py +145 -0
- hatchet_sdk/contracts/v1/shared/condition_pb2.py +39 -0
- hatchet_sdk/contracts/v1/shared/condition_pb2.pyi +72 -0
- hatchet_sdk/contracts/v1/shared/condition_pb2_grpc.py +29 -0
- hatchet_sdk/contracts/v1/workflows_pb2.py +67 -0
- hatchet_sdk/contracts/v1/workflows_pb2.pyi +228 -0
- hatchet_sdk/contracts/v1/workflows_pb2_grpc.py +234 -0
- hatchet_sdk/contracts/workflows_pb2_grpc.py +1 -1
- hatchet_sdk/features/cron.py +43 -57
- hatchet_sdk/features/scheduled.py +60 -74
- hatchet_sdk/hatchet.py +491 -218
- hatchet_sdk/labels.py +4 -6
- hatchet_sdk/metadata.py +1 -1
- hatchet_sdk/opentelemetry/instrumentor.py +17 -18
- hatchet_sdk/rate_limit.py +40 -55
- hatchet_sdk/runnables/contextvars.py +12 -0
- hatchet_sdk/runnables/standalone.py +194 -0
- hatchet_sdk/runnables/task.py +144 -0
- hatchet_sdk/runnables/types.py +138 -0
- hatchet_sdk/runnables/workflow.py +764 -0
- hatchet_sdk/token.py +13 -9
- hatchet_sdk/utils/aio_utils.py +0 -119
- hatchet_sdk/utils/proto_enums.py +47 -0
- hatchet_sdk/utils/timedelta_to_expression.py +23 -0
- hatchet_sdk/utils/typing.py +10 -2
- hatchet_sdk/v0/__init__.py +251 -0
- hatchet_sdk/v0/client.py +119 -0
- hatchet_sdk/v0/clients/admin.py +541 -0
- hatchet_sdk/v0/clients/dispatcher/action_listener.py +422 -0
- hatchet_sdk/v0/clients/dispatcher/dispatcher.py +204 -0
- hatchet_sdk/v0/clients/event_ts.py +28 -0
- hatchet_sdk/v0/clients/events.py +182 -0
- hatchet_sdk/v0/clients/rest/__init__.py +307 -0
- hatchet_sdk/v0/clients/rest/api/__init__.py +19 -0
- hatchet_sdk/v0/clients/rest/api/api_token_api.py +858 -0
- hatchet_sdk/v0/clients/rest/api/default_api.py +2259 -0
- hatchet_sdk/v0/clients/rest/api/event_api.py +2548 -0
- hatchet_sdk/v0/clients/rest/api/github_api.py +331 -0
- hatchet_sdk/v0/clients/rest/api/healthcheck_api.py +483 -0
- hatchet_sdk/v0/clients/rest/api/log_api.py +449 -0
- hatchet_sdk/v0/clients/rest/api/metadata_api.py +728 -0
- hatchet_sdk/v0/clients/rest/api/rate_limits_api.py +423 -0
- hatchet_sdk/v0/clients/rest/api/slack_api.py +577 -0
- hatchet_sdk/v0/clients/rest/api/sns_api.py +872 -0
- hatchet_sdk/v0/clients/rest/api/step_run_api.py +2202 -0
- hatchet_sdk/v0/clients/rest/api/tenant_api.py +4430 -0
- hatchet_sdk/v0/clients/rest/api/user_api.py +2888 -0
- hatchet_sdk/v0/clients/rest/api/worker_api.py +858 -0
- hatchet_sdk/v0/clients/rest/api/workflow_api.py +6312 -0
- hatchet_sdk/v0/clients/rest/api/workflow_run_api.py +1932 -0
- hatchet_sdk/v0/clients/rest/api/workflow_runs_api.py +610 -0
- hatchet_sdk/v0/clients/rest/api_client.py +759 -0
- hatchet_sdk/v0/clients/rest/api_response.py +22 -0
- hatchet_sdk/v0/clients/rest/configuration.py +611 -0
- hatchet_sdk/v0/clients/rest/exceptions.py +200 -0
- hatchet_sdk/v0/clients/rest/models/__init__.py +274 -0
- hatchet_sdk/v0/clients/rest/models/accept_invite_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/api_error.py +102 -0
- hatchet_sdk/v0/clients/rest/models/api_errors.py +100 -0
- hatchet_sdk/v0/clients/rest/models/api_meta.py +144 -0
- hatchet_sdk/v0/clients/rest/models/api_meta_auth.py +85 -0
- hatchet_sdk/v0/clients/rest/models/api_meta_integration.py +88 -0
- hatchet_sdk/v0/clients/rest/models/api_meta_posthog.py +90 -0
- hatchet_sdk/v0/clients/rest/models/api_resource_meta.py +98 -0
- hatchet_sdk/v0/clients/rest/models/api_token.py +105 -0
- hatchet_sdk/v0/clients/rest/models/bulk_create_event_request.py +100 -0
- hatchet_sdk/v0/clients/rest/models/bulk_create_event_response.py +110 -0
- hatchet_sdk/v0/clients/rest/models/cancel_event_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/cancel_step_run_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/concurrency_limit_strategy.py +39 -0
- hatchet_sdk/v0/clients/rest/models/create_api_token_request.py +92 -0
- hatchet_sdk/v0/clients/rest/models/create_api_token_response.py +83 -0
- hatchet_sdk/v0/clients/rest/models/create_cron_workflow_trigger_request.py +98 -0
- hatchet_sdk/v0/clients/rest/models/create_event_request.py +95 -0
- hatchet_sdk/v0/clients/rest/models/create_pull_request_from_step_run.py +83 -0
- hatchet_sdk/v0/clients/rest/models/create_sns_integration_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/create_tenant_alert_email_group_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/create_tenant_invite_request.py +86 -0
- hatchet_sdk/v0/clients/rest/models/create_tenant_request.py +84 -0
- hatchet_sdk/v0/clients/rest/models/cron_workflows.py +131 -0
- hatchet_sdk/v0/clients/rest/models/cron_workflows_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/cron_workflows_method.py +37 -0
- hatchet_sdk/v0/clients/rest/models/cron_workflows_order_by_field.py +37 -0
- hatchet_sdk/v0/clients/rest/models/event.py +143 -0
- hatchet_sdk/v0/clients/rest/models/event_data.py +83 -0
- hatchet_sdk/v0/clients/rest/models/event_key_list.py +98 -0
- hatchet_sdk/v0/clients/rest/models/event_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/event_order_by_direction.py +37 -0
- hatchet_sdk/v0/clients/rest/models/event_order_by_field.py +36 -0
- hatchet_sdk/v0/clients/rest/models/event_update_cancel200_response.py +85 -0
- hatchet_sdk/v0/clients/rest/models/event_workflow_run_summary.py +116 -0
- hatchet_sdk/v0/clients/rest/models/events.py +110 -0
- hatchet_sdk/v0/clients/rest/models/get_step_run_diff_response.py +100 -0
- hatchet_sdk/v0/clients/rest/models/github_app_installation.py +107 -0
- hatchet_sdk/v0/clients/rest/models/github_branch.py +86 -0
- hatchet_sdk/v0/clients/rest/models/github_repo.py +86 -0
- hatchet_sdk/v0/clients/rest/models/info_get_version200_response.py +83 -0
- hatchet_sdk/v0/clients/rest/models/job.py +132 -0
- hatchet_sdk/v0/clients/rest/models/job_run.py +176 -0
- hatchet_sdk/v0/clients/rest/models/job_run_status.py +41 -0
- hatchet_sdk/v0/clients/rest/models/link_github_repository_request.py +106 -0
- hatchet_sdk/v0/clients/rest/models/list_api_tokens_response.py +110 -0
- hatchet_sdk/v0/clients/rest/models/list_github_app_installations_response.py +112 -0
- hatchet_sdk/v0/clients/rest/models/list_pull_requests_response.py +100 -0
- hatchet_sdk/v0/clients/rest/models/list_slack_webhooks.py +110 -0
- hatchet_sdk/v0/clients/rest/models/list_sns_integrations.py +110 -0
- hatchet_sdk/v0/clients/rest/models/log_line.py +94 -0
- hatchet_sdk/v0/clients/rest/models/log_line_level.py +39 -0
- hatchet_sdk/v0/clients/rest/models/log_line_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/log_line_order_by_direction.py +37 -0
- hatchet_sdk/v0/clients/rest/models/log_line_order_by_field.py +36 -0
- hatchet_sdk/v0/clients/rest/models/pagination_response.py +95 -0
- hatchet_sdk/v0/clients/rest/models/pull_request.py +112 -0
- hatchet_sdk/v0/clients/rest/models/pull_request_state.py +37 -0
- hatchet_sdk/v0/clients/rest/models/queue_metrics.py +97 -0
- hatchet_sdk/v0/clients/rest/models/rate_limit.py +117 -0
- hatchet_sdk/v0/clients/rest/models/rate_limit_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_direction.py +37 -0
- hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_field.py +38 -0
- hatchet_sdk/v0/clients/rest/models/recent_step_runs.py +118 -0
- hatchet_sdk/v0/clients/rest/models/reject_invite_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/replay_event_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_response.py +100 -0
- hatchet_sdk/v0/clients/rest/models/rerun_step_run_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/schedule_workflow_run_request.py +92 -0
- hatchet_sdk/v0/clients/rest/models/scheduled_run_status.py +42 -0
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows.py +149 -0
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_method.py +37 -0
- hatchet_sdk/v0/clients/rest/models/scheduled_workflows_order_by_field.py +37 -0
- hatchet_sdk/v0/clients/rest/models/semaphore_slots.py +113 -0
- hatchet_sdk/v0/clients/rest/models/slack_webhook.py +127 -0
- hatchet_sdk/v0/clients/rest/models/sns_integration.py +114 -0
- hatchet_sdk/v0/clients/rest/models/step.py +123 -0
- hatchet_sdk/v0/clients/rest/models/step_run.py +202 -0
- hatchet_sdk/v0/clients/rest/models/step_run_archive.py +142 -0
- hatchet_sdk/v0/clients/rest/models/step_run_archive_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/step_run_diff.py +91 -0
- hatchet_sdk/v0/clients/rest/models/step_run_event.py +122 -0
- hatchet_sdk/v0/clients/rest/models/step_run_event_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/step_run_event_reason.py +52 -0
- hatchet_sdk/v0/clients/rest/models/step_run_event_severity.py +38 -0
- hatchet_sdk/v0/clients/rest/models/step_run_status.py +44 -0
- hatchet_sdk/v0/clients/rest/models/tenant.py +118 -0
- hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group.py +98 -0
- hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group_list.py +112 -0
- hatchet_sdk/v0/clients/rest/models/tenant_alerting_settings.py +143 -0
- hatchet_sdk/v0/clients/rest/models/tenant_invite.py +120 -0
- hatchet_sdk/v0/clients/rest/models/tenant_invite_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/tenant_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/tenant_member.py +123 -0
- hatchet_sdk/v0/clients/rest/models/tenant_member_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/tenant_member_role.py +38 -0
- hatchet_sdk/v0/clients/rest/models/tenant_queue_metrics.py +116 -0
- hatchet_sdk/v0/clients/rest/models/tenant_resource.py +40 -0
- hatchet_sdk/v0/clients/rest/models/tenant_resource_limit.py +135 -0
- hatchet_sdk/v0/clients/rest/models/tenant_resource_policy.py +102 -0
- hatchet_sdk/v0/clients/rest/models/tenant_step_run_queue_metrics.py +83 -0
- hatchet_sdk/v0/clients/rest/models/trigger_workflow_run_request.py +91 -0
- hatchet_sdk/v0/clients/rest/models/update_tenant_alert_email_group_request.py +83 -0
- hatchet_sdk/v0/clients/rest/models/update_tenant_invite_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/update_tenant_request.py +137 -0
- hatchet_sdk/v0/clients/rest/models/update_worker_request.py +87 -0
- hatchet_sdk/v0/clients/rest/models/user.py +126 -0
- hatchet_sdk/v0/clients/rest/models/user_change_password_request.py +88 -0
- hatchet_sdk/v0/clients/rest/models/user_login_request.py +86 -0
- hatchet_sdk/v0/clients/rest/models/user_register_request.py +91 -0
- hatchet_sdk/v0/clients/rest/models/user_tenant_memberships_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/user_tenant_public.py +86 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker.py +100 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_create_request.py +94 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_create_response.py +98 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_created.py +102 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_list_response.py +110 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request.py +102 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request_list_response.py +104 -0
- hatchet_sdk/v0/clients/rest/models/webhook_worker_request_method.py +38 -0
- hatchet_sdk/v0/clients/rest/models/worker.py +239 -0
- hatchet_sdk/v0/clients/rest/models/worker_label.py +102 -0
- hatchet_sdk/v0/clients/rest/models/worker_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/worker_runtime_info.py +103 -0
- hatchet_sdk/v0/clients/rest/models/worker_runtime_sdks.py +38 -0
- hatchet_sdk/v0/clients/rest/models/worker_type.py +38 -0
- hatchet_sdk/v0/clients/rest/models/workflow.py +165 -0
- hatchet_sdk/v0/clients/rest/models/workflow_concurrency.py +107 -0
- hatchet_sdk/v0/clients/rest/models/workflow_deployment_config.py +136 -0
- hatchet_sdk/v0/clients/rest/models/workflow_kind.py +38 -0
- hatchet_sdk/v0/clients/rest/models/workflow_list.py +120 -0
- hatchet_sdk/v0/clients/rest/models/workflow_metrics.py +97 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run.py +188 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_cancel200_response.py +85 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_list.py +110 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_direction.py +37 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_field.py +39 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_shape.py +186 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_status.py +42 -0
- hatchet_sdk/v0/clients/rest/models/workflow_run_triggered_by.py +112 -0
- hatchet_sdk/v0/clients/rest/models/workflow_runs_cancel_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics.py +94 -0
- hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics_counts.py +104 -0
- hatchet_sdk/v0/clients/rest/models/workflow_tag.py +84 -0
- hatchet_sdk/v0/clients/rest/models/workflow_trigger_cron_ref.py +86 -0
- hatchet_sdk/v0/clients/rest/models/workflow_trigger_event_ref.py +86 -0
- hatchet_sdk/v0/clients/rest/models/workflow_triggers.py +141 -0
- hatchet_sdk/v0/clients/rest/models/workflow_update_request.py +85 -0
- hatchet_sdk/v0/clients/rest/models/workflow_version.py +170 -0
- hatchet_sdk/v0/clients/rest/models/workflow_version_concurrency.py +114 -0
- hatchet_sdk/v0/clients/rest/models/workflow_version_definition.py +85 -0
- hatchet_sdk/v0/clients/rest/models/workflow_version_meta.py +123 -0
- hatchet_sdk/v0/clients/rest/models/workflow_workers_count.py +95 -0
- hatchet_sdk/v0/clients/rest/rest.py +187 -0
- hatchet_sdk/v0/clients/rest/tenacity_utils.py +39 -0
- hatchet_sdk/v0/clients/rest_client.py +622 -0
- hatchet_sdk/v0/clients/run_event_listener.py +260 -0
- hatchet_sdk/v0/clients/workflow_listener.py +277 -0
- hatchet_sdk/v0/connection.py +63 -0
- hatchet_sdk/v0/context/__init__.py +1 -0
- hatchet_sdk/v0/context/context.py +446 -0
- hatchet_sdk/v0/context/worker_context.py +28 -0
- hatchet_sdk/v0/contracts/dispatcher_pb2.py +102 -0
- hatchet_sdk/v0/contracts/dispatcher_pb2.pyi +387 -0
- hatchet_sdk/v0/contracts/dispatcher_pb2_grpc.py +621 -0
- hatchet_sdk/v0/contracts/events_pb2.py +46 -0
- hatchet_sdk/v0/contracts/events_pb2.pyi +87 -0
- hatchet_sdk/v0/contracts/events_pb2_grpc.py +274 -0
- hatchet_sdk/v0/contracts/workflows_pb2.py +80 -0
- hatchet_sdk/v0/contracts/workflows_pb2.pyi +312 -0
- hatchet_sdk/v0/contracts/workflows_pb2_grpc.py +277 -0
- hatchet_sdk/v0/features/cron.py +286 -0
- hatchet_sdk/v0/features/scheduled.py +248 -0
- hatchet_sdk/v0/hatchet.py +310 -0
- hatchet_sdk/v0/labels.py +10 -0
- hatchet_sdk/v0/logger.py +13 -0
- hatchet_sdk/v0/metadata.py +2 -0
- hatchet_sdk/v0/opentelemetry/instrumentor.py +396 -0
- hatchet_sdk/v0/rate_limit.py +126 -0
- hatchet_sdk/v0/token.py +27 -0
- hatchet_sdk/v0/utils/aio_utils.py +137 -0
- hatchet_sdk/v0/utils/backoff.py +9 -0
- hatchet_sdk/v0/utils/typing.py +12 -0
- hatchet_sdk/{v2 → v0/v2}/callable.py +8 -8
- hatchet_sdk/{v2 → v0/v2}/concurrency.py +2 -2
- hatchet_sdk/{v2 → v0/v2}/hatchet.py +10 -10
- hatchet_sdk/v0/worker/__init__.py +1 -0
- hatchet_sdk/v0/worker/action_listener_process.py +294 -0
- hatchet_sdk/v0/worker/runner/run_loop_manager.py +112 -0
- hatchet_sdk/v0/worker/runner/runner.py +460 -0
- hatchet_sdk/v0/worker/runner/utils/capture_logs.py +81 -0
- hatchet_sdk/v0/worker/worker.py +391 -0
- hatchet_sdk/{workflow.py → v0/workflow.py} +4 -4
- hatchet_sdk/v0/workflow_run.py +59 -0
- hatchet_sdk/waits.py +120 -0
- hatchet_sdk/worker/__init__.py +0 -1
- hatchet_sdk/worker/action_listener_process.py +80 -55
- hatchet_sdk/worker/runner/run_loop_manager.py +46 -34
- hatchet_sdk/worker/runner/runner.py +82 -87
- hatchet_sdk/worker/runner/utils/capture_logs.py +26 -23
- hatchet_sdk/worker/worker.py +172 -149
- hatchet_sdk/workflow_run.py +7 -21
- {hatchet_sdk-0.47.1.dist-info → hatchet_sdk-1.0.0a1.dist-info}/METADATA +2 -2
- hatchet_sdk-1.0.0a1.dist-info/RECORD +505 -0
- {hatchet_sdk-0.47.1.dist-info → hatchet_sdk-1.0.0a1.dist-info}/entry_points.txt +2 -0
- hatchet_sdk/utils/serialization.py +0 -18
- hatchet_sdk-0.47.1.dist-info/RECORD +0 -237
- /hatchet_sdk/{loader.py → v0/loader.py} +0 -0
- /hatchet_sdk/{semver.py → v0/semver.py} +0 -0
- /hatchet_sdk/{utils → v0/utils}/types.py +0 -0
- /hatchet_sdk/{worker → v0/worker}/runner/utils/error_with_traceback.py +0 -0
- {hatchet_sdk-0.47.1.dist-info → hatchet_sdk-1.0.0a1.dist-info}/WHEEL +0 -0
|
@@ -2,7 +2,7 @@ import asyncio
|
|
|
2
2
|
import atexit
|
|
3
3
|
import datetime
|
|
4
4
|
import threading
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Coroutine, TypeVar
|
|
6
6
|
|
|
7
7
|
from pydantic import StrictInt
|
|
8
8
|
|
|
@@ -15,11 +15,11 @@ from hatchet_sdk.clients.rest.api.workflow_run_api import WorkflowRunApi
|
|
|
15
15
|
from hatchet_sdk.clients.rest.api.workflow_runs_api import WorkflowRunsApi
|
|
16
16
|
from hatchet_sdk.clients.rest.api_client import ApiClient
|
|
17
17
|
from hatchet_sdk.clients.rest.configuration import Configuration
|
|
18
|
-
from hatchet_sdk.clients.rest.models import TriggerWorkflowRunRequest
|
|
19
18
|
from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import (
|
|
20
19
|
CreateCronWorkflowTriggerRequest,
|
|
21
20
|
)
|
|
22
21
|
from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows
|
|
22
|
+
from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList
|
|
23
23
|
from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import (
|
|
24
24
|
CronWorkflowsOrderByField,
|
|
25
25
|
)
|
|
@@ -28,6 +28,9 @@ from hatchet_sdk.clients.rest.models.event_order_by_direction import (
|
|
|
28
28
|
EventOrderByDirection,
|
|
29
29
|
)
|
|
30
30
|
from hatchet_sdk.clients.rest.models.event_order_by_field import EventOrderByField
|
|
31
|
+
from hatchet_sdk.clients.rest.models.event_update_cancel200_response import (
|
|
32
|
+
EventUpdateCancel200Response,
|
|
33
|
+
)
|
|
31
34
|
from hatchet_sdk.clients.rest.models.log_line_level import LogLineLevel
|
|
32
35
|
from hatchet_sdk.clients.rest.models.log_line_list import LogLineList
|
|
33
36
|
from hatchet_sdk.clients.rest.models.log_line_order_by_direction import (
|
|
@@ -45,16 +48,19 @@ from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import (
|
|
|
45
48
|
ScheduleWorkflowRunRequest,
|
|
46
49
|
)
|
|
47
50
|
from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows
|
|
51
|
+
from hatchet_sdk.clients.rest.models.scheduled_workflows_list import (
|
|
52
|
+
ScheduledWorkflowsList,
|
|
53
|
+
)
|
|
48
54
|
from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import (
|
|
49
55
|
ScheduledWorkflowsOrderByField,
|
|
50
56
|
)
|
|
57
|
+
from hatchet_sdk.clients.rest.models.trigger_workflow_run_request import (
|
|
58
|
+
TriggerWorkflowRunRequest,
|
|
59
|
+
)
|
|
51
60
|
from hatchet_sdk.clients.rest.models.workflow import Workflow
|
|
52
61
|
from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind
|
|
53
62
|
from hatchet_sdk.clients.rest.models.workflow_list import WorkflowList
|
|
54
63
|
from hatchet_sdk.clients.rest.models.workflow_run import WorkflowRun
|
|
55
|
-
from hatchet_sdk.clients.rest.models.workflow_run_cancel200_response import (
|
|
56
|
-
WorkflowRunCancel200Response,
|
|
57
|
-
)
|
|
58
64
|
from hatchet_sdk.clients.rest.models.workflow_run_list import WorkflowRunList
|
|
59
65
|
from hatchet_sdk.clients.rest.models.workflow_run_order_by_direction import (
|
|
60
66
|
WorkflowRunOrderByDirection,
|
|
@@ -67,9 +73,21 @@ from hatchet_sdk.clients.rest.models.workflow_runs_cancel_request import (
|
|
|
67
73
|
WorkflowRunsCancelRequest,
|
|
68
74
|
)
|
|
69
75
|
from hatchet_sdk.clients.rest.models.workflow_version import WorkflowVersion
|
|
76
|
+
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
77
|
+
|
|
78
|
+
## Type variables to use with coroutines.
|
|
79
|
+
## See https://stackoverflow.com/questions/73240620/the-right-way-to-type-hint-a-coroutine-function
|
|
80
|
+
## Return type
|
|
81
|
+
R = TypeVar("R")
|
|
70
82
|
|
|
83
|
+
## Yield type
|
|
84
|
+
Y = TypeVar("Y")
|
|
71
85
|
|
|
72
|
-
|
|
86
|
+
## Send type
|
|
87
|
+
S = TypeVar("S")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class RestApi:
|
|
73
91
|
def __init__(self, host: str, api_key: str, tenant_id: str):
|
|
74
92
|
self.tenant_id = tenant_id
|
|
75
93
|
|
|
@@ -78,73 +96,104 @@ class AsyncRestApi:
|
|
|
78
96
|
access_token=api_key,
|
|
79
97
|
)
|
|
80
98
|
|
|
81
|
-
self.
|
|
82
|
-
self.
|
|
83
|
-
self.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
self.
|
|
99
|
+
self._loop = asyncio.new_event_loop()
|
|
100
|
+
self._thread = threading.Thread(target=self._run_event_loop, daemon=True)
|
|
101
|
+
self._thread.start()
|
|
102
|
+
|
|
103
|
+
# Register the cleanup method to be called on exit
|
|
104
|
+
atexit.register(self._cleanup)
|
|
105
|
+
|
|
106
|
+
## IMPORTANT: These clients need to be instantiated lazily because they rely on
|
|
107
|
+
## an event loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
108
|
+
self._api_client: ApiClient | None = None
|
|
109
|
+
self._workflow_api: WorkflowApi | None = None
|
|
110
|
+
self._workflow_run_api: WorkflowRunApi | None = None
|
|
111
|
+
self._workflow_runs_api: WorkflowRunsApi | None = None
|
|
112
|
+
self._step_run_api: StepRunApi | None = None
|
|
113
|
+
self._event_api: EventApi | None = None
|
|
114
|
+
self._log_api: LogApi | None = None
|
|
87
115
|
self._worker_api: WorkerApi | None = None
|
|
88
116
|
|
|
89
117
|
@property
|
|
90
|
-
def api_client(self):
|
|
118
|
+
def api_client(self) -> ApiClient:
|
|
119
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
120
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
91
121
|
if self._api_client is None:
|
|
92
122
|
self._api_client = ApiClient(configuration=self.config)
|
|
93
123
|
return self._api_client
|
|
94
124
|
|
|
95
125
|
@property
|
|
96
|
-
def workflow_api(self):
|
|
126
|
+
def workflow_api(self) -> WorkflowApi:
|
|
127
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
128
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
97
129
|
if self._workflow_api is None:
|
|
98
130
|
self._workflow_api = WorkflowApi(self.api_client)
|
|
99
131
|
return self._workflow_api
|
|
100
132
|
|
|
101
133
|
@property
|
|
102
|
-
def workflow_run_api(self):
|
|
134
|
+
def workflow_run_api(self) -> WorkflowRunApi:
|
|
135
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
136
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
103
137
|
if self._workflow_run_api is None:
|
|
104
138
|
self._workflow_run_api = WorkflowRunApi(self.api_client)
|
|
105
139
|
return self._workflow_run_api
|
|
106
140
|
|
|
107
141
|
@property
|
|
108
|
-
def
|
|
142
|
+
def workflow_runs_api(self) -> WorkflowRunsApi:
|
|
143
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
144
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
145
|
+
if self._workflow_runs_api is None:
|
|
146
|
+
self._workflow_runs_api = WorkflowRunsApi(self.api_client)
|
|
147
|
+
return self._workflow_runs_api
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def worker_api(self) -> WorkerApi:
|
|
151
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
152
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
109
153
|
if self._worker_api is None:
|
|
110
154
|
self._worker_api = WorkerApi(self.api_client)
|
|
111
155
|
|
|
112
156
|
return self._worker_api
|
|
113
157
|
|
|
114
158
|
@property
|
|
115
|
-
def step_run_api(self):
|
|
159
|
+
def step_run_api(self) -> StepRunApi:
|
|
160
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
161
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
116
162
|
if self._step_run_api is None:
|
|
117
163
|
self._step_run_api = StepRunApi(self.api_client)
|
|
118
164
|
return self._step_run_api
|
|
119
165
|
|
|
120
166
|
@property
|
|
121
|
-
def event_api(self):
|
|
167
|
+
def event_api(self) -> EventApi:
|
|
168
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
169
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
122
170
|
if self._event_api is None:
|
|
123
171
|
self._event_api = EventApi(self.api_client)
|
|
124
172
|
return self._event_api
|
|
125
173
|
|
|
126
174
|
@property
|
|
127
|
-
def log_api(self):
|
|
175
|
+
def log_api(self) -> LogApi:
|
|
176
|
+
## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
|
|
177
|
+
## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
|
|
128
178
|
if self._log_api is None:
|
|
129
179
|
self._log_api = LogApi(self.api_client)
|
|
130
180
|
return self._log_api
|
|
131
181
|
|
|
132
|
-
async def close(self):
|
|
182
|
+
async def close(self) -> None:
|
|
133
183
|
# Ensure the aiohttp client session is closed
|
|
134
|
-
|
|
135
|
-
await self._api_client.close()
|
|
184
|
+
await self.api_client.close() # type: ignore[no-untyped-call]
|
|
136
185
|
|
|
137
|
-
async def
|
|
186
|
+
async def aio_list_workflows(self) -> WorkflowList:
|
|
138
187
|
return await self.workflow_api.workflow_list(
|
|
139
188
|
tenant=self.tenant_id,
|
|
140
189
|
)
|
|
141
190
|
|
|
142
|
-
async def
|
|
191
|
+
async def aio_get_workflow(self, workflow_id: str) -> Workflow:
|
|
143
192
|
return await self.workflow_api.workflow_get(
|
|
144
193
|
workflow=workflow_id,
|
|
145
194
|
)
|
|
146
195
|
|
|
147
|
-
async def
|
|
196
|
+
async def aio_get_workflow_version(
|
|
148
197
|
self, workflow_id: str, version: str | None = None
|
|
149
198
|
) -> WorkflowVersion:
|
|
150
199
|
return await self.workflow_api.workflow_version_get(
|
|
@@ -152,7 +201,7 @@ class AsyncRestApi:
|
|
|
152
201
|
version=version,
|
|
153
202
|
)
|
|
154
203
|
|
|
155
|
-
async def
|
|
204
|
+
async def aio_list_workflow_runs(
|
|
156
205
|
self,
|
|
157
206
|
workflow_id: str | None = None,
|
|
158
207
|
offset: int | None = None,
|
|
@@ -181,25 +230,25 @@ class AsyncRestApi:
|
|
|
181
230
|
order_by_direction=order_by_direction,
|
|
182
231
|
)
|
|
183
232
|
|
|
184
|
-
async def
|
|
233
|
+
async def aio_get_workflow_run(self, workflow_run_id: str) -> WorkflowRun:
|
|
185
234
|
return await self.workflow_api.workflow_run_get(
|
|
186
235
|
tenant=self.tenant_id,
|
|
187
236
|
workflow_run=workflow_run_id,
|
|
188
237
|
)
|
|
189
238
|
|
|
190
|
-
async def
|
|
239
|
+
async def aio_replay_workflow_run(
|
|
191
240
|
self, workflow_run_ids: list[str]
|
|
192
241
|
) -> ReplayWorkflowRunsResponse:
|
|
193
242
|
return await self.workflow_run_api.workflow_run_update_replay(
|
|
194
243
|
tenant=self.tenant_id,
|
|
195
244
|
replay_workflow_runs_request=ReplayWorkflowRunsRequest(
|
|
196
|
-
|
|
245
|
+
workflowRunIds=workflow_run_ids,
|
|
197
246
|
),
|
|
198
247
|
)
|
|
199
248
|
|
|
200
|
-
async def
|
|
249
|
+
async def aio_cancel_workflow_run(
|
|
201
250
|
self, workflow_run_id: str
|
|
202
|
-
) ->
|
|
251
|
+
) -> EventUpdateCancel200Response:
|
|
203
252
|
return await self.workflow_run_api.workflow_run_cancel(
|
|
204
253
|
tenant=self.tenant_id,
|
|
205
254
|
workflow_runs_cancel_request=WorkflowRunsCancelRequest(
|
|
@@ -207,9 +256,9 @@ class AsyncRestApi:
|
|
|
207
256
|
),
|
|
208
257
|
)
|
|
209
258
|
|
|
210
|
-
async def
|
|
259
|
+
async def aio_bulk_cancel_workflow_runs(
|
|
211
260
|
self, workflow_run_ids: list[str]
|
|
212
|
-
) ->
|
|
261
|
+
) -> EventUpdateCancel200Response:
|
|
213
262
|
return await self.workflow_run_api.workflow_run_cancel(
|
|
214
263
|
tenant=self.tenant_id,
|
|
215
264
|
workflow_runs_cancel_request=WorkflowRunsCancelRequest(
|
|
@@ -217,48 +266,48 @@ class AsyncRestApi:
|
|
|
217
266
|
),
|
|
218
267
|
)
|
|
219
268
|
|
|
220
|
-
async def
|
|
269
|
+
async def aio_create_workflow_run(
|
|
221
270
|
self,
|
|
222
271
|
workflow_id: str,
|
|
223
|
-
input:
|
|
272
|
+
input: JSONSerializableMapping,
|
|
224
273
|
version: str | None = None,
|
|
225
|
-
additional_metadata:
|
|
274
|
+
additional_metadata: JSONSerializableMapping = {},
|
|
226
275
|
) -> WorkflowRun:
|
|
227
276
|
return await self.workflow_run_api.workflow_run_create(
|
|
228
277
|
workflow=workflow_id,
|
|
229
278
|
version=version,
|
|
230
279
|
trigger_workflow_run_request=TriggerWorkflowRunRequest(
|
|
231
|
-
input=input,
|
|
232
|
-
|
|
280
|
+
input=dict(input),
|
|
281
|
+
additionalMetadata=dict(additional_metadata),
|
|
233
282
|
),
|
|
234
283
|
)
|
|
235
284
|
|
|
236
|
-
async def
|
|
285
|
+
async def aio_create_cron(
|
|
237
286
|
self,
|
|
238
287
|
workflow_name: str,
|
|
239
288
|
cron_name: str,
|
|
240
289
|
expression: str,
|
|
241
|
-
input:
|
|
242
|
-
additional_metadata:
|
|
243
|
-
):
|
|
290
|
+
input: JSONSerializableMapping,
|
|
291
|
+
additional_metadata: JSONSerializableMapping,
|
|
292
|
+
) -> CronWorkflows:
|
|
244
293
|
return await self.workflow_run_api.cron_workflow_trigger_create(
|
|
245
294
|
tenant=self.tenant_id,
|
|
246
295
|
workflow=workflow_name,
|
|
247
296
|
create_cron_workflow_trigger_request=CreateCronWorkflowTriggerRequest(
|
|
248
297
|
cronName=cron_name,
|
|
249
298
|
cronExpression=expression,
|
|
250
|
-
input=input,
|
|
251
|
-
|
|
299
|
+
input=dict(input),
|
|
300
|
+
additionalMetadata=dict(additional_metadata),
|
|
252
301
|
),
|
|
253
302
|
)
|
|
254
303
|
|
|
255
|
-
async def
|
|
256
|
-
|
|
304
|
+
async def aio_delete_cron(self, cron_trigger_id: str) -> None:
|
|
305
|
+
await self.workflow_api.workflow_cron_delete(
|
|
257
306
|
tenant=self.tenant_id,
|
|
258
307
|
cron_workflow=cron_trigger_id,
|
|
259
308
|
)
|
|
260
309
|
|
|
261
|
-
async def
|
|
310
|
+
async def aio_list_crons(
|
|
262
311
|
self,
|
|
263
312
|
offset: StrictInt | None = None,
|
|
264
313
|
limit: StrictInt | None = None,
|
|
@@ -266,7 +315,7 @@ class AsyncRestApi:
|
|
|
266
315
|
additional_metadata: list[str] | None = None,
|
|
267
316
|
order_by_field: CronWorkflowsOrderByField | None = None,
|
|
268
317
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
269
|
-
):
|
|
318
|
+
) -> CronWorkflowsList:
|
|
270
319
|
return await self.workflow_api.cron_workflow_list(
|
|
271
320
|
tenant=self.tenant_id,
|
|
272
321
|
offset=offset,
|
|
@@ -277,36 +326,36 @@ class AsyncRestApi:
|
|
|
277
326
|
order_by_direction=order_by_direction,
|
|
278
327
|
)
|
|
279
328
|
|
|
280
|
-
async def
|
|
329
|
+
async def aio_get_cron(self, cron_trigger_id: str) -> CronWorkflows:
|
|
281
330
|
return await self.workflow_api.workflow_cron_get(
|
|
282
331
|
tenant=self.tenant_id,
|
|
283
332
|
cron_workflow=cron_trigger_id,
|
|
284
333
|
)
|
|
285
334
|
|
|
286
|
-
async def
|
|
335
|
+
async def aio_create_schedule(
|
|
287
336
|
self,
|
|
288
337
|
name: str,
|
|
289
338
|
trigger_at: datetime.datetime,
|
|
290
|
-
input:
|
|
291
|
-
additional_metadata:
|
|
292
|
-
):
|
|
339
|
+
input: JSONSerializableMapping,
|
|
340
|
+
additional_metadata: JSONSerializableMapping,
|
|
341
|
+
) -> ScheduledWorkflows:
|
|
293
342
|
return await self.workflow_run_api.scheduled_workflow_run_create(
|
|
294
343
|
tenant=self.tenant_id,
|
|
295
344
|
workflow=name,
|
|
296
345
|
schedule_workflow_run_request=ScheduleWorkflowRunRequest(
|
|
297
346
|
triggerAt=trigger_at,
|
|
298
|
-
input=input,
|
|
299
|
-
|
|
347
|
+
input=dict(input),
|
|
348
|
+
additionalMetadata=dict(additional_metadata),
|
|
300
349
|
),
|
|
301
350
|
)
|
|
302
351
|
|
|
303
|
-
async def
|
|
304
|
-
|
|
352
|
+
async def aio_delete_schedule(self, scheduled_trigger_id: str) -> None:
|
|
353
|
+
await self.workflow_api.workflow_scheduled_delete(
|
|
305
354
|
tenant=self.tenant_id,
|
|
306
355
|
scheduled_workflow_run=scheduled_trigger_id,
|
|
307
356
|
)
|
|
308
357
|
|
|
309
|
-
async def
|
|
358
|
+
async def aio_list_schedule(
|
|
310
359
|
self,
|
|
311
360
|
offset: StrictInt | None = None,
|
|
312
361
|
limit: StrictInt | None = None,
|
|
@@ -316,7 +365,7 @@ class AsyncRestApi:
|
|
|
316
365
|
parent_step_run_id: str | None = None,
|
|
317
366
|
order_by_field: ScheduledWorkflowsOrderByField | None = None,
|
|
318
367
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
319
|
-
):
|
|
368
|
+
) -> ScheduledWorkflowsList:
|
|
320
369
|
return await self.workflow_api.workflow_scheduled_list(
|
|
321
370
|
tenant=self.tenant_id,
|
|
322
371
|
offset=offset,
|
|
@@ -329,13 +378,13 @@ class AsyncRestApi:
|
|
|
329
378
|
order_by_direction=order_by_direction,
|
|
330
379
|
)
|
|
331
380
|
|
|
332
|
-
async def
|
|
381
|
+
async def aio_get_schedule(self, scheduled_trigger_id: str) -> ScheduledWorkflows:
|
|
333
382
|
return await self.workflow_api.workflow_scheduled_get(
|
|
334
383
|
tenant=self.tenant_id,
|
|
335
384
|
scheduled_workflow_run=scheduled_trigger_id,
|
|
336
385
|
)
|
|
337
386
|
|
|
338
|
-
async def
|
|
387
|
+
async def aio_list_logs(
|
|
339
388
|
self,
|
|
340
389
|
step_run_id: str,
|
|
341
390
|
offset: int | None = None,
|
|
@@ -355,7 +404,7 @@ class AsyncRestApi:
|
|
|
355
404
|
order_by_direction=order_by_direction,
|
|
356
405
|
)
|
|
357
406
|
|
|
358
|
-
async def
|
|
407
|
+
async def aio_list_events(
|
|
359
408
|
self,
|
|
360
409
|
offset: int | None = None,
|
|
361
410
|
limit: int | None = None,
|
|
@@ -380,44 +429,32 @@ class AsyncRestApi:
|
|
|
380
429
|
additional_metadata=additional_metadata,
|
|
381
430
|
)
|
|
382
431
|
|
|
383
|
-
async def
|
|
432
|
+
async def aio_replay_events(self, event_ids: list[str] | EventList) -> EventList:
|
|
384
433
|
if isinstance(event_ids, EventList):
|
|
385
|
-
|
|
434
|
+
rows = event_ids.rows or []
|
|
435
|
+
event_ids = [r.metadata.id for r in rows]
|
|
386
436
|
|
|
387
|
-
return self.event_api.event_update_replay(
|
|
437
|
+
return await self.event_api.event_update_replay(
|
|
388
438
|
tenant=self.tenant_id,
|
|
389
439
|
replay_event_request=ReplayEventRequest(eventIds=event_ids),
|
|
390
440
|
)
|
|
391
441
|
|
|
392
|
-
|
|
393
|
-
class RestApi:
|
|
394
|
-
def __init__(self, host: str, api_key: str, tenant_id: str):
|
|
395
|
-
self._loop = asyncio.new_event_loop()
|
|
396
|
-
self._thread = threading.Thread(target=self._run_event_loop, daemon=True)
|
|
397
|
-
self._thread.start()
|
|
398
|
-
|
|
399
|
-
# Initialize AsyncRestApi inside the event loop to ensure an active loop
|
|
400
|
-
self.aio = AsyncRestApi(host, api_key, tenant_id)
|
|
401
|
-
|
|
402
|
-
# Register the cleanup method to be called on exit
|
|
403
|
-
atexit.register(self._cleanup)
|
|
404
|
-
|
|
405
|
-
def _cleanup(self):
|
|
442
|
+
def _cleanup(self) -> None:
|
|
406
443
|
"""
|
|
407
444
|
Stop the running thread and clean up the event loop.
|
|
408
445
|
"""
|
|
409
|
-
self._run_coroutine(self.
|
|
446
|
+
self._run_coroutine(self.close())
|
|
410
447
|
self._loop.call_soon_threadsafe(self._loop.stop)
|
|
411
448
|
self._thread.join()
|
|
412
449
|
|
|
413
|
-
def _run_event_loop(self):
|
|
450
|
+
def _run_event_loop(self) -> None:
|
|
414
451
|
"""
|
|
415
452
|
Run the asyncio event loop in a separate thread.
|
|
416
453
|
"""
|
|
417
454
|
asyncio.set_event_loop(self._loop)
|
|
418
455
|
self._loop.run_forever()
|
|
419
456
|
|
|
420
|
-
def _run_coroutine(self, coro) ->
|
|
457
|
+
def _run_coroutine(self, coro: Coroutine[Y, S, R]) -> R:
|
|
421
458
|
"""
|
|
422
459
|
Execute a coroutine in the event loop and return the result.
|
|
423
460
|
"""
|
|
@@ -425,15 +462,15 @@ class RestApi:
|
|
|
425
462
|
return future.result()
|
|
426
463
|
|
|
427
464
|
def workflow_list(self) -> WorkflowList:
|
|
428
|
-
return self._run_coroutine(self.
|
|
465
|
+
return self._run_coroutine(self.aio_list_workflows())
|
|
429
466
|
|
|
430
467
|
def workflow_get(self, workflow_id: str) -> Workflow:
|
|
431
|
-
return self._run_coroutine(self.
|
|
468
|
+
return self._run_coroutine(self.aio_get_workflow(workflow_id))
|
|
432
469
|
|
|
433
470
|
def workflow_version_get(
|
|
434
471
|
self, workflow_id: str, version: str | None = None
|
|
435
472
|
) -> WorkflowVersion:
|
|
436
|
-
return self._run_coroutine(self.
|
|
473
|
+
return self._run_coroutine(self.aio_get_workflow_version(workflow_id, version))
|
|
437
474
|
|
|
438
475
|
def workflow_run_list(
|
|
439
476
|
self,
|
|
@@ -450,7 +487,7 @@ class RestApi:
|
|
|
450
487
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
451
488
|
) -> WorkflowRunList:
|
|
452
489
|
return self._run_coroutine(
|
|
453
|
-
self.
|
|
490
|
+
self.aio_list_workflow_runs(
|
|
454
491
|
workflow_id=workflow_id,
|
|
455
492
|
offset=offset,
|
|
456
493
|
limit=limit,
|
|
@@ -466,25 +503,25 @@ class RestApi:
|
|
|
466
503
|
)
|
|
467
504
|
|
|
468
505
|
def workflow_run_get(self, workflow_run_id: str) -> WorkflowRun:
|
|
469
|
-
return self._run_coroutine(self.
|
|
506
|
+
return self._run_coroutine(self.aio_get_workflow_run(workflow_run_id))
|
|
470
507
|
|
|
471
|
-
def workflow_run_cancel(self, workflow_run_id: str) ->
|
|
472
|
-
return self._run_coroutine(self.
|
|
508
|
+
def workflow_run_cancel(self, workflow_run_id: str) -> EventUpdateCancel200Response:
|
|
509
|
+
return self._run_coroutine(self.aio_cancel_workflow_run(workflow_run_id))
|
|
473
510
|
|
|
474
511
|
def workflow_run_bulk_cancel(
|
|
475
512
|
self, workflow_run_ids: list[str]
|
|
476
|
-
) ->
|
|
477
|
-
return self._run_coroutine(self.
|
|
513
|
+
) -> EventUpdateCancel200Response:
|
|
514
|
+
return self._run_coroutine(self.aio_bulk_cancel_workflow_runs(workflow_run_ids))
|
|
478
515
|
|
|
479
516
|
def workflow_run_create(
|
|
480
517
|
self,
|
|
481
518
|
workflow_id: str,
|
|
482
|
-
input:
|
|
519
|
+
input: JSONSerializableMapping,
|
|
483
520
|
version: str | None = None,
|
|
484
|
-
additional_metadata:
|
|
521
|
+
additional_metadata: JSONSerializableMapping = {},
|
|
485
522
|
) -> WorkflowRun:
|
|
486
523
|
return self._run_coroutine(
|
|
487
|
-
self.
|
|
524
|
+
self.aio_create_workflow_run(
|
|
488
525
|
workflow_id, input, version, additional_metadata
|
|
489
526
|
)
|
|
490
527
|
)
|
|
@@ -494,17 +531,17 @@ class RestApi:
|
|
|
494
531
|
workflow_name: str,
|
|
495
532
|
cron_name: str,
|
|
496
533
|
expression: str,
|
|
497
|
-
input:
|
|
498
|
-
additional_metadata:
|
|
534
|
+
input: JSONSerializableMapping,
|
|
535
|
+
additional_metadata: JSONSerializableMapping,
|
|
499
536
|
) -> CronWorkflows:
|
|
500
537
|
return self._run_coroutine(
|
|
501
|
-
self.
|
|
538
|
+
self.aio_create_cron(
|
|
502
539
|
workflow_name, cron_name, expression, input, additional_metadata
|
|
503
540
|
)
|
|
504
541
|
)
|
|
505
542
|
|
|
506
|
-
def cron_delete(self, cron_trigger_id: str):
|
|
507
|
-
|
|
543
|
+
def cron_delete(self, cron_trigger_id: str) -> None:
|
|
544
|
+
self._run_coroutine(self.aio_delete_cron(cron_trigger_id))
|
|
508
545
|
|
|
509
546
|
def cron_list(
|
|
510
547
|
self,
|
|
@@ -514,9 +551,9 @@ class RestApi:
|
|
|
514
551
|
additional_metadata: list[str] | None = None,
|
|
515
552
|
order_by_field: CronWorkflowsOrderByField | None = None,
|
|
516
553
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
517
|
-
):
|
|
554
|
+
) -> CronWorkflowsList:
|
|
518
555
|
return self._run_coroutine(
|
|
519
|
-
self.
|
|
556
|
+
self.aio_list_crons(
|
|
520
557
|
offset,
|
|
521
558
|
limit,
|
|
522
559
|
workflow_id,
|
|
@@ -526,24 +563,24 @@ class RestApi:
|
|
|
526
563
|
)
|
|
527
564
|
)
|
|
528
565
|
|
|
529
|
-
def cron_get(self, cron_trigger_id: str):
|
|
530
|
-
return self._run_coroutine(self.
|
|
566
|
+
def cron_get(self, cron_trigger_id: str) -> CronWorkflows:
|
|
567
|
+
return self._run_coroutine(self.aio_get_cron(cron_trigger_id))
|
|
531
568
|
|
|
532
569
|
def schedule_create(
|
|
533
570
|
self,
|
|
534
571
|
workflow_name: str,
|
|
535
572
|
trigger_at: datetime.datetime,
|
|
536
|
-
input:
|
|
537
|
-
additional_metadata:
|
|
538
|
-
):
|
|
573
|
+
input: JSONSerializableMapping,
|
|
574
|
+
additional_metadata: JSONSerializableMapping,
|
|
575
|
+
) -> ScheduledWorkflows:
|
|
539
576
|
return self._run_coroutine(
|
|
540
|
-
self.
|
|
577
|
+
self.aio_create_schedule(
|
|
541
578
|
workflow_name, trigger_at, input, additional_metadata
|
|
542
579
|
)
|
|
543
580
|
)
|
|
544
581
|
|
|
545
|
-
def schedule_delete(self, scheduled_trigger_id: str):
|
|
546
|
-
|
|
582
|
+
def schedule_delete(self, scheduled_trigger_id: str) -> None:
|
|
583
|
+
self._run_coroutine(self.aio_delete_schedule(scheduled_trigger_id))
|
|
547
584
|
|
|
548
585
|
def schedule_list(
|
|
549
586
|
self,
|
|
@@ -553,9 +590,9 @@ class RestApi:
|
|
|
553
590
|
additional_metadata: list[str] | None = None,
|
|
554
591
|
order_by_field: CronWorkflowsOrderByField | None = None,
|
|
555
592
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
556
|
-
):
|
|
593
|
+
) -> ScheduledWorkflowsList:
|
|
557
594
|
return self._run_coroutine(
|
|
558
|
-
self.
|
|
595
|
+
self.aio_list_schedule(
|
|
559
596
|
offset,
|
|
560
597
|
limit,
|
|
561
598
|
workflow_id,
|
|
@@ -565,8 +602,8 @@ class RestApi:
|
|
|
565
602
|
)
|
|
566
603
|
)
|
|
567
604
|
|
|
568
|
-
def schedule_get(self, scheduled_trigger_id: str):
|
|
569
|
-
return self._run_coroutine(self.
|
|
605
|
+
def schedule_get(self, scheduled_trigger_id: str) -> ScheduledWorkflows:
|
|
606
|
+
return self._run_coroutine(self.aio_get_schedule(scheduled_trigger_id))
|
|
570
607
|
|
|
571
608
|
def list_logs(
|
|
572
609
|
self,
|
|
@@ -579,7 +616,7 @@ class RestApi:
|
|
|
579
616
|
order_by_direction: LogLineOrderByDirection | None = None,
|
|
580
617
|
) -> LogLineList:
|
|
581
618
|
return self._run_coroutine(
|
|
582
|
-
self.
|
|
619
|
+
self.aio_list_logs(
|
|
583
620
|
step_run_id=step_run_id,
|
|
584
621
|
offset=offset,
|
|
585
622
|
limit=limit,
|
|
@@ -603,7 +640,7 @@ class RestApi:
|
|
|
603
640
|
additional_metadata: list[str] | None = None,
|
|
604
641
|
) -> EventList:
|
|
605
642
|
return self._run_coroutine(
|
|
606
|
-
self.
|
|
643
|
+
self.aio_list_events(
|
|
607
644
|
offset=offset,
|
|
608
645
|
limit=limit,
|
|
609
646
|
keys=keys,
|
|
@@ -617,4 +654,4 @@ class RestApi:
|
|
|
617
654
|
)
|
|
618
655
|
|
|
619
656
|
def events_replay(self, event_ids: list[str] | EventList) -> EventList:
|
|
620
|
-
return self._run_coroutine(self.
|
|
657
|
+
return self._run_coroutine(self.aio_replay_events(event_ids))
|