| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import logging |
| 4 |
import sys |
| 5 |
import typing as t |
| 6 |
import uuid |
| 7 |
|
| 8 |
from globus_sdk import GlobusHTTPResponse, client, paging |
| 9 |
from globus_sdk._internal import guards |
| 10 |
from globus_sdk._internal.remarshal import commajoin |
| 11 |
from globus_sdk._missing import MISSING, MissingType |
| 12 |
from globus_sdk.authorizers import GlobusAuthorizer |
| 13 |
from globus_sdk.globus_app import GlobusApp |
| 14 |
from globus_sdk.scopes import ( |
| 15 |
FlowsScopes, |
| 16 |
GCSCollectionScopes, |
| 17 |
Scope, |
| 18 |
SpecificFlowScopes, |
| 19 |
TransferScopes, |
| 20 |
) |
| 21 |
from globus_sdk.transport import RequestsTransport, RetryConfig |
| 22 |
|
| 23 |
from .data import RunActivityNotificationPolicy |
| 24 |
from .errors import FlowsAPIError |
| 25 |
from .response import ( |
| 26 |
IterableFlowsResponse, |
| 27 |
IterableRegisteredAPIsResponse, |
| 28 |
IterableRunLogsResponse, |
| 29 |
IterableRunsResponse, |
| 30 |
) |
| 31 |
|
| 32 |
if sys.version_info >= (3, 11): |
| 33 |
from typing import Self |
| 34 |
else: |
| 35 |
from typing_extensions import Self |
| 36 |
|
| 37 |
log = logging.getLogger(__name__) |
| 38 |
|
| 39 |
|
| 40 |
class FlowsClient(client.BaseClient): |
| 41 |
r""" |
| 42 |
Client for the Globus Flows API. |
| 43 |
|
| 44 |
.. sdk-sphinx-copy-params:: BaseClient |
| 45 |
|
| 46 |
.. automethodlist:: globus_sdk.FlowsClient |
| 47 |
""" |
| 48 |
|
| 49 |
error_class = FlowsAPIError |
| 50 |
service_name = "flows" |
| 51 |
scopes = FlowsScopes |
| 52 |
default_scope_requirements = [FlowsScopes.all] |
| 53 |
|
| 54 |
def create_flow( |
| 55 |
self, |
| 56 |
title: str, |
| 57 |
definition: dict[str, t.Any], |
| 58 |
input_schema: dict[str, t.Any], |
| 59 |
subtitle: str | MissingType = MISSING, |
| 60 |
description: str | MissingType = MISSING, |
| 61 |
flow_viewers: list[str] | MissingType = MISSING, |
| 62 |
flow_starters: list[str] | MissingType = MISSING, |
| 63 |
flow_administrators: list[str] | MissingType = MISSING, |
| 64 |
run_managers: list[str] | MissingType = MISSING, |
| 65 |
run_monitors: list[str] | MissingType = MISSING, |
| 66 |
keywords: list[str] | MissingType = MISSING, |
| 67 |
subscription_id: uuid.UUID | str | None | MissingType = MISSING, |
| 68 |
authentication_policy_id: uuid.UUID | str | None | MissingType = MISSING, |
| 69 |
additional_fields: dict[str, t.Any] | None = None, |
| 70 |
) -> GlobusHTTPResponse: |
| 71 |
""" |
| 72 |
Create a flow |
| 73 |
|
| 74 |
:param title: A non-unique, human-friendly name used for displaying the |
| 75 |
flow to end users. (1 - 128 characters) |
| 76 |
:param definition: JSON object specifying flows states and execution order. For |
| 77 |
a more detailed explanation of the flow definition, see |
| 78 |
`Authoring Flows <https://docs.globus.org/api/flows/authoring-flows>`_ |
| 79 |
:param input_schema: A JSON Schema to which flow run input must conform |
| 80 |
:param subtitle: A concise summary of the flow’s purpose. (0 - 128 characters) |
| 81 |
:param description: A detailed description of the flow's purpose for end user |
| 82 |
display. (0 - 4096 characters) |
| 83 |
:param flow_viewers: A set of Principal URN values, or the value "public", |
| 84 |
indicating entities who can view the flow |
| 85 |
|
| 86 |
.. dropdown:: Example Values |
| 87 |
|
| 88 |
.. code-block:: json |
| 89 |
|
| 90 |
[ "public" ] |
| 91 |
|
| 92 |
.. code-block:: json |
| 93 |
|
| 94 |
[ |
| 95 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 96 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 97 |
] |
| 98 |
|
| 99 |
|
| 100 |
:param flow_starters: A set of Principal URN values, or the value |
| 101 |
"all_authenticated_users", indicating entities who can initiate a *run* of |
| 102 |
the flow |
| 103 |
|
| 104 |
.. dropdown:: Example Values |
| 105 |
|
| 106 |
.. code-block:: json |
| 107 |
|
| 108 |
[ "all_authenticated_users" ] |
| 109 |
|
| 110 |
|
| 111 |
.. code-block:: json |
| 112 |
|
| 113 |
[ |
| 114 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 115 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 116 |
] |
| 117 |
|
| 118 |
:param flow_administrators: A set of Principal URN values indicating entities |
| 119 |
who can perform administrative operations on the flow (create, delete, |
| 120 |
update) |
| 121 |
|
| 122 |
.. dropdown:: Example Values |
| 123 |
|
| 124 |
.. code-block:: json |
| 125 |
|
| 126 |
[ |
| 127 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 128 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 129 |
] |
| 130 |
|
| 131 |
:param run_managers: A set of Principal URN values indicating entities who can |
| 132 |
perform management operations on the flow's *runs*. |
| 133 |
|
| 134 |
.. dropdown:: Example Values |
| 135 |
|
| 136 |
.. code-block:: json |
| 137 |
|
| 138 |
[ |
| 139 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 140 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 141 |
] |
| 142 |
|
| 143 |
:param run_monitors: A set of Principal URN values indicating entities who can |
| 144 |
monitor the flow's *runs*. |
| 145 |
|
| 146 |
.. dropdown:: Example Values |
| 147 |
|
| 148 |
.. code-block:: json |
| 149 |
|
| 150 |
[ |
| 151 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 152 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 153 |
] |
| 154 |
|
| 155 |
:param keywords: A set of terms used to categorize the flow used in query and |
| 156 |
discovery operations (0 - 1024 items) |
| 157 |
:param subscription_id: The ID of the subscription to associate with the flow, |
| 158 |
marking as a subscription tier flow. |
| 159 |
:param authentication_policy_id: The ID of the authentication policy to associate |
| 160 |
with the flow. |
| 161 |
:param additional_fields: Additional Key/Value pairs sent to the create API |
| 162 |
|
| 163 |
.. tab-set:: |
| 164 |
|
| 165 |
.. tab-item:: Example Usage |
| 166 |
|
| 167 |
.. code-block:: python |
| 168 |
|
| 169 |
from globus_sdk import FlowsClient |
| 170 |
|
| 171 |
... |
| 172 |
flows = FlowsClient(...) |
| 173 |
flows.create_flow( |
| 174 |
title="my-cool-flow", |
| 175 |
definition={ |
| 176 |
"StartAt": "the-one-true-state", |
| 177 |
"States": {"the-one-true-state": {"Type": "Pass", "End": True}}, |
| 178 |
}, |
| 179 |
input_schema={ |
| 180 |
"type": "object", |
| 181 |
"properties": { |
| 182 |
"input-a": {"type": "string"}, |
| 183 |
"input-b": {"type": "number"}, |
| 184 |
"input-c": {"type": "boolean"}, |
| 185 |
}, |
| 186 |
}, |
| 187 |
) |
| 188 |
|
| 189 |
.. tab-item:: Example Response Data |
| 190 |
|
| 191 |
.. expandtestfixture:: flows.create_flow |
| 192 |
|
| 193 |
.. tab-item:: API Info |
| 194 |
|
| 195 |
.. extdoclink:: Create Flow |
| 196 |
:service: flows |
| 197 |
:ref: Flows/paths/~1flows/post |
| 198 |
""" # noqa E501 |
| 199 |
|
| 200 |
data = { |
| 201 |
"title": title, |
| 202 |
"definition": definition, |
| 203 |
"input_schema": input_schema, |
| 204 |
"subtitle": subtitle, |
| 205 |
"description": description, |
| 206 |
"flow_viewers": flow_viewers, |
| 207 |
"flow_starters": flow_starters, |
| 208 |
"flow_administrators": flow_administrators, |
| 209 |
"run_managers": run_managers, |
| 210 |
"run_monitors": run_monitors, |
| 211 |
"keywords": keywords, |
| 212 |
"subscription_id": subscription_id, |
| 213 |
"authentication_policy_id": authentication_policy_id, |
| 214 |
**(additional_fields or {}), |
| 215 |
} |
| 216 |
return self.post("/flows", data=data) |
| 217 |
|
| 218 |
def get_flow( |
| 219 |
self, |
| 220 |
flow_id: uuid.UUID | str, |
| 221 |
*, |
| 222 |
query_params: dict[str, t.Any] | None = None, |
| 223 |
) -> GlobusHTTPResponse: |
| 224 |
"""Retrieve a flow by ID |
| 225 |
|
| 226 |
:param flow_id: The ID of the flow to fetch |
| 227 |
:param query_params: Any additional parameters to be passed through |
| 228 |
as query params. |
| 229 |
|
| 230 |
.. tab-set:: |
| 231 |
|
| 232 |
.. tab-item:: API Info |
| 233 |
|
| 234 |
.. extdoclink:: Get Flow |
| 235 |
:service: flows |
| 236 |
:ref: Flows/paths/~1flows~1{flow_id}/get |
| 237 |
""" |
| 238 |
return self.get(f"/flows/{flow_id}", query_params=query_params) |
| 239 |
|
| 240 |
@paging.has_paginator(paging.MarkerPaginator, items_key="flows") |
| 241 |
def list_flows( |
| 242 |
self, |
| 243 |
*, |
| 244 |
filter_roles: str | t.Iterable[str] | MissingType = MISSING, |
| 245 |
filter_fulltext: str | MissingType = MISSING, |
| 246 |
orderby: str | t.Iterable[str] | MissingType = MISSING, |
| 247 |
marker: str | MissingType = MISSING, |
| 248 |
query_params: dict[str, t.Any] | None = None, |
| 249 |
) -> IterableFlowsResponse: |
| 250 |
""" |
| 251 |
List deployed flows |
| 252 |
|
| 253 |
:param filter_roles: A list of role names specifying the roles the user must |
| 254 |
have for a flow to be included in the response. |
| 255 |
:param filter_fulltext: A string to use in a full-text search to filter results |
| 256 |
:param orderby: A criterion for ordering flows in the listing |
| 257 |
:param marker: A marker for pagination |
| 258 |
:param query_params: Any additional parameters to be passed through |
| 259 |
as query params. |
| 260 |
|
| 261 |
**Role Filters** |
| 262 |
|
| 263 |
``filter_roles`` accepts a list of roles which are used to filter the results to |
| 264 |
flows where the caller has any of the specified roles. |
| 265 |
|
| 266 |
The valid role values are: |
| 267 |
|
| 268 |
- ``flow_viewer`` |
| 269 |
- ``flow_starter`` |
| 270 |
- ``flow_administrator`` |
| 271 |
- ``flow_owner`` |
| 272 |
- ``run_monitor`` |
| 273 |
- ``run_manager`` |
| 274 |
|
| 275 |
**OrderBy Values** |
| 276 |
|
| 277 |
Values for ``orderby`` consist of a field name, a space, and an |
| 278 |
ordering mode -- ``ASC`` for "ascending" and ``DESC`` for "descending". |
| 279 |
|
| 280 |
Supported field names are |
| 281 |
|
| 282 |
- ``id`` |
| 283 |
- ``scope_string`` |
| 284 |
- ``flow_owners`` |
| 285 |
- ``flow_administrators`` |
| 286 |
- ``title`` |
| 287 |
- ``created_at`` |
| 288 |
- ``updated_at`` |
| 289 |
|
| 290 |
For example, ``orderby="updated_at DESC"`` requests a descending sort on update |
| 291 |
times, getting the most recently updated flow first. Multiple ``orderby`` values |
| 292 |
may be given as an iterable, e.g. ``orderby=["updated_at DESC", "title ASC"]``. |
| 293 |
|
| 294 |
.. tab-set:: |
| 295 |
|
| 296 |
.. tab-item:: Example Usage |
| 297 |
|
| 298 |
.. code-block:: python |
| 299 |
|
| 300 |
import json |
| 301 |
import textwrap |
| 302 |
|
| 303 |
from globus_sdk import FlowsClient |
| 304 |
|
| 305 |
flows = FlowsClient(...) |
| 306 |
my_frobulate_flows = flows.list_flows( |
| 307 |
filter_roles="flow_owner", |
| 308 |
filter_fulltext="frobulate", |
| 309 |
orderby=("title ASC", "updated_at DESC"), |
| 310 |
) |
| 311 |
for flow_doc in my_frobulate_flows: |
| 312 |
print(f"Title: {flow_doc['title']}") |
| 313 |
print(f"Description: {flow_doc['description']}") |
| 314 |
print("Definition:") |
| 315 |
print( |
| 316 |
textwrap.indent( |
| 317 |
json.dumps( |
| 318 |
flow_doc["definition"], |
| 319 |
indent=2, |
| 320 |
separators=(",", ": "), |
| 321 |
), |
| 322 |
" ", |
| 323 |
) |
| 324 |
) |
| 325 |
print() |
| 326 |
|
| 327 |
.. tab-item:: Paginated Usage |
| 328 |
|
| 329 |
.. paginatedusage:: list_flows |
| 330 |
|
| 331 |
.. tab-item:: API Info |
| 332 |
|
| 333 |
.. extdoclink:: List Flows |
| 334 |
:service: flows |
| 335 |
:ref: Flows/paths/~1flows/get |
| 336 |
""" |
| 337 |
query_params = { |
| 338 |
"filter_roles": commajoin(filter_roles), |
| 339 |
"filter_fulltext": filter_fulltext, |
| 340 |
# if `orderby` is an iterable (e.g., generator expression), it gets |
| 341 |
# converted to a list in this step |
| 342 |
"orderby": ( |
| 343 |
orderby if isinstance(orderby, (str, MissingType)) else list(orderby) |
| 344 |
), |
| 345 |
"marker": marker, |
| 346 |
**(query_params or {}), |
| 347 |
} |
| 348 |
return IterableFlowsResponse(self.get("/flows", query_params=query_params)) |
| 349 |
|
| 350 |
def update_flow( |
| 351 |
self, |
| 352 |
flow_id: uuid.UUID | str, |
| 353 |
*, |
| 354 |
title: str | MissingType = MISSING, |
| 355 |
definition: dict[str, t.Any] | MissingType = MISSING, |
| 356 |
input_schema: dict[str, t.Any] | MissingType = MISSING, |
| 357 |
subtitle: str | MissingType = MISSING, |
| 358 |
description: str | MissingType = MISSING, |
| 359 |
flow_owner: str | MissingType = MISSING, |
| 360 |
flow_viewers: list[str] | MissingType = MISSING, |
| 361 |
flow_starters: list[str] | MissingType = MISSING, |
| 362 |
flow_administrators: list[str] | MissingType = MISSING, |
| 363 |
run_managers: list[str] | MissingType = MISSING, |
| 364 |
run_monitors: list[str] | MissingType = MISSING, |
| 365 |
keywords: list[str] | MissingType = MISSING, |
| 366 |
subscription_id: uuid.UUID | str | t.Literal["DEFAULT"] | MissingType = MISSING, |
| 367 |
authentication_policy_id: uuid.UUID | str | MissingType = MISSING, |
| 368 |
additional_fields: dict[str, t.Any] | None = None, |
| 369 |
) -> GlobusHTTPResponse: |
| 370 |
""" |
| 371 |
Update a flow |
| 372 |
|
| 373 |
Only the parameter `flow_id` is required. |
| 374 |
Any fields omitted from the request will be unchanged |
| 375 |
|
| 376 |
:param flow_id: The ID of the flow to fetch |
| 377 |
:param title: A non-unique, human-friendly name used for displaying the |
| 378 |
flow to end users. (1 - 128 characters) |
| 379 |
:param definition: JSON object specifying flows states and execution order. For |
| 380 |
a more detailed explanation of the flow definition, see |
| 381 |
`Authoring Flows <https://docs.globus.org/api/flows/authoring-flows>`_ |
| 382 |
:param input_schema: A JSON Schema to which flow run input must conform |
| 383 |
:param subtitle: A concise summary of the flow’s purpose. (0 - 128 characters) |
| 384 |
:param description: A detailed description of the flow's purpose for end user |
| 385 |
display. (0 - 4096 characters) |
| 386 |
:param flow_owner: An Auth Identity URN to set as flow owner; this must match |
| 387 |
the Identity URN of the entity calling `update_flow` |
| 388 |
:param flow_viewers: A set of Principal URN values, or the value "public", |
| 389 |
indicating entities who can view the flow |
| 390 |
|
| 391 |
.. dropdown:: Example Values |
| 392 |
|
| 393 |
.. code-block:: json |
| 394 |
|
| 395 |
[ "public" ] |
| 396 |
|
| 397 |
.. code-block:: json |
| 398 |
|
| 399 |
[ |
| 400 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 401 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 402 |
] |
| 403 |
|
| 404 |
:param flow_starters: A set of Principal URN values, or the value |
| 405 |
"all_authenticated_users", indicating entities who can initiate a *run* of |
| 406 |
the flow |
| 407 |
|
| 408 |
.. dropdown:: Example Values |
| 409 |
|
| 410 |
.. code-block:: json |
| 411 |
|
| 412 |
[ "all_authenticated_users" ] |
| 413 |
|
| 414 |
|
| 415 |
.. code-block:: json |
| 416 |
|
| 417 |
[ |
| 418 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 419 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 420 |
] |
| 421 |
|
| 422 |
:param flow_administrators: A set of Principal URN values indicating entities |
| 423 |
who can perform administrative operations on the flow (create, delete, |
| 424 |
update) |
| 425 |
|
| 426 |
.. dropdown:: Example Value |
| 427 |
|
| 428 |
.. code-block:: json |
| 429 |
|
| 430 |
[ |
| 431 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 432 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 433 |
] |
| 434 |
|
| 435 |
:param run_managers: A set of Principal URN values indicating entities who can |
| 436 |
perform management operations on the flow's *runs*. |
| 437 |
|
| 438 |
.. dropdown:: Example Values |
| 439 |
|
| 440 |
.. code-block:: json |
| 441 |
|
| 442 |
[ |
| 443 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 444 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 445 |
] |
| 446 |
|
| 447 |
:param run_monitors: A set of Principal URN values indicating entities who can |
| 448 |
monitor the flow's *runs*. |
| 449 |
|
| 450 |
.. dropdown:: Example Values |
| 451 |
|
| 452 |
.. code-block:: json |
| 453 |
|
| 454 |
[ |
| 455 |
"urn:globus:auth:identity:b44bddda-d274-11e5-978a-9f15789a8150", |
| 456 |
"urn:globus:groups:id:c1dcd951-3f35-4ea3-9f28-a7cdeaf8b68f" |
| 457 |
] |
| 458 |
|
| 459 |
:param keywords: A set of terms used to categorize the flow used in query and |
| 460 |
discovery operations (0 - 1024 items) |
| 461 |
:param subscription_id: A subscription ID to assign to the flow. |
| 462 |
:param authentication_policy_id: An authentication policy to assign to the flow. |
| 463 |
:param additional_fields: Additional Key/Value pairs sent to the create API |
| 464 |
|
| 465 |
.. tab-set:: |
| 466 |
|
| 467 |
.. tab-item:: Example Usage |
| 468 |
|
| 469 |
.. code-block:: python |
| 470 |
|
| 471 |
from globus_sdk import FlowsClient |
| 472 |
|
| 473 |
flows = FlowsClient(...) |
| 474 |
flows.update_flow( |
| 475 |
flow_id="581753c7-45da-43d3-ad73-246b46e7cb6b", |
| 476 |
keywords=["new", "overriding", "keywords"], |
| 477 |
) |
| 478 |
|
| 479 |
.. tab-item:: Example Response Data |
| 480 |
|
| 481 |
.. expandtestfixture:: flows.update_flow |
| 482 |
|
| 483 |
.. tab-item:: API Info |
| 484 |
|
| 485 |
.. extdoclink:: Update Flow |
| 486 |
:service: flows |
| 487 |
:ref: Flows/paths/~1flows~1{flow_id}/put |
| 488 |
""" # noqa E501 |
| 489 |
|
| 490 |
data = { |
| 491 |
"title": title, |
| 492 |
"definition": definition, |
| 493 |
"input_schema": input_schema, |
| 494 |
"subtitle": subtitle, |
| 495 |
"description": description, |
| 496 |
"flow_owner": flow_owner, |
| 497 |
"flow_viewers": flow_viewers, |
| 498 |
"flow_starters": flow_starters, |
| 499 |
"flow_administrators": flow_administrators, |
| 500 |
"run_managers": run_managers, |
| 501 |
"run_monitors": run_monitors, |
| 502 |
"keywords": keywords, |
| 503 |
"subscription_id": subscription_id, |
| 504 |
"authentication_policy_id": authentication_policy_id, |
| 505 |
**(additional_fields or {}), |
| 506 |
} |
| 507 |
return self.put(f"/flows/{flow_id}", data=data) |
| 508 |
|
| 509 |
def delete_flow( |
| 510 |
self, |
| 511 |
flow_id: uuid.UUID | str, |
| 512 |
*, |
| 513 |
query_params: dict[str, t.Any] | None = None, |
| 514 |
) -> GlobusHTTPResponse: |
| 515 |
"""Delete a flow |
| 516 |
|
| 517 |
:param flow_id: The ID of the flow to delete |
| 518 |
:param query_params: Any additional parameters to be passed through |
| 519 |
as query params. |
| 520 |
|
| 521 |
.. tab-set:: |
| 522 |
|
| 523 |
.. tab-item:: API Info |
| 524 |
|
| 525 |
.. extdoclink:: Delete Flow |
| 526 |
:service: flows |
| 527 |
:ref: Flows/paths/~1flows~1{flow_id}/delete |
| 528 |
""" |
| 529 |
return self.delete(f"/flows/{flow_id}", query_params=query_params) |
| 530 |
|
| 531 |
def validate_flow( |
| 532 |
self, |
| 533 |
definition: dict[str, t.Any], |
| 534 |
input_schema: dict[str, t.Any] | MissingType = MISSING, |
| 535 |
) -> GlobusHTTPResponse: |
| 536 |
""" |
| 537 |
Validate a flow |
| 538 |
|
| 539 |
:param definition: JSON object specifying flow states and execution order. For |
| 540 |
a more detailed explanation of the flow definition, see |
| 541 |
`Authoring Flows <https://docs.globus.org/api/flows/authoring-flows>`_ |
| 542 |
:param input_schema: A JSON Schema to which flow run input must conform |
| 543 |
|
| 544 |
.. tab-set:: |
| 545 |
|
| 546 |
.. tab-item:: Example Usage |
| 547 |
|
| 548 |
.. code-block:: python |
| 549 |
|
| 550 |
from globus_sdk import FlowsClient |
| 551 |
|
| 552 |
... |
| 553 |
flows = FlowsClient(...) |
| 554 |
flows.validate_flow( |
| 555 |
definition={ |
| 556 |
"StartAt": "the-one-true-state", |
| 557 |
"States": {"the-one-true-state": {"Type": "Pass", "End": True}}, |
| 558 |
}, |
| 559 |
input_schema={ |
| 560 |
"type": "object", |
| 561 |
"properties": { |
| 562 |
"input-a": {"type": "string"}, |
| 563 |
"input-b": {"type": "number"}, |
| 564 |
"input-c": {"type": "boolean"}, |
| 565 |
}, |
| 566 |
}, |
| 567 |
) |
| 568 |
|
| 569 |
.. tab-item:: Example Response Data |
| 570 |
|
| 571 |
.. expandtestfixture:: flows.validate_flow |
| 572 |
|
| 573 |
.. tab-item:: API Info |
| 574 |
|
| 575 |
.. extdoclink:: Validate Flow |
| 576 |
:service: flows |
| 577 |
:ref: Flows/paths/~1flows~1validate/post |
| 578 |
""" # noqa E501 |
| 579 |
|
| 580 |
data = { |
| 581 |
"definition": definition, |
| 582 |
"input_schema": input_schema, |
| 583 |
} |
| 584 |
return self.post("/flows/validate", data=data) |
| 585 |
|
| 586 |
@paging.has_paginator(paging.MarkerPaginator, items_key="runs") |
| 587 |
def list_runs( |
| 588 |
self, |
| 589 |
*, |
| 590 |
filter_flow_id: ( |
| 591 |
t.Iterable[uuid.UUID | str] | uuid.UUID | str | MissingType |
| 592 |
) = MISSING, |
| 593 |
filter_roles: str | t.Iterable[str] | MissingType = MISSING, |
| 594 |
marker: str | MissingType = MISSING, |
| 595 |
query_params: dict[str, t.Any] | None = None, |
| 596 |
) -> IterableRunsResponse: |
| 597 |
""" |
| 598 |
List all runs. |
| 599 |
|
| 600 |
:param filter_flow_id: One or more flow IDs used to filter the results |
| 601 |
:param filter_roles: A list of role names used to filter the results |
| 602 |
:param marker: A pagination marker, used to get the next page of results. |
| 603 |
:param query_params: Any additional parameters to be passed through |
| 604 |
|
| 605 |
**Filter Roles Values** |
| 606 |
|
| 607 |
The valid values for ``role`` are: |
| 608 |
|
| 609 |
- ``run_owner`` |
| 610 |
- ``run_manager`` |
| 611 |
- ``run_monitor`` |
| 612 |
- ``flow_run_manager`` |
| 613 |
- ``flow_run_monitor`` |
| 614 |
|
| 615 |
.. tab-set:: |
| 616 |
|
| 617 |
.. tab-item:: Example Usage |
| 618 |
|
| 619 |
.. code-block:: python |
| 620 |
|
| 621 |
flows = globus_sdk.FlowsClient(...) |
| 622 |
for run in flows.list_runs(): |
| 623 |
print(run["run_id"]) |
| 624 |
|
| 625 |
.. tab-item:: Example Response Data |
| 626 |
|
| 627 |
.. expandtestfixture:: flows.list_runs |
| 628 |
|
| 629 |
.. tab-item:: API Info |
| 630 |
|
| 631 |
.. extdoclink:: List Runs |
| 632 |
:service: flows |
| 633 |
:ref: Runs/paths/~1runs/get |
| 634 |
""" |
| 635 |
query_params = { |
| 636 |
"filter_flow_id": commajoin(filter_flow_id), |
| 637 |
"filter_roles": commajoin(filter_roles), |
| 638 |
"marker": marker, |
| 639 |
**(query_params or {}), |
| 640 |
} |
| 641 |
return IterableRunsResponse(self.get("/runs", query_params=query_params)) |
| 642 |
|
| 643 |
@paging.has_paginator(paging.MarkerPaginator, items_key="entries") |
| 644 |
def get_run_logs( |
| 645 |
self, |
| 646 |
run_id: uuid.UUID | str, |
| 647 |
*, |
| 648 |
limit: int | MissingType = MISSING, |
| 649 |
reverse_order: bool | MissingType = MISSING, |
| 650 |
marker: str | MissingType = MISSING, |
| 651 |
query_params: dict[str, t.Any] | None = None, |
| 652 |
) -> IterableRunLogsResponse: |
| 653 |
""" |
| 654 |
Retrieve the execution logs associated with a run |
| 655 |
|
| 656 |
These logs describe state transitions and associated payloads for a run |
| 657 |
|
| 658 |
:param run_id: Run ID to retrieve logs for |
| 659 |
:param limit: Maximum number of log entries to return (server default: 10) |
| 660 |
(value between 1 and 100 inclusive) |
| 661 |
:param reverse_order: Return results in reverse chronological order (server |
| 662 |
default: false) |
| 663 |
:param marker: Marker for the next page of results (provided by the server) |
| 664 |
:param query_params: Any additional parameters to be passed through |
| 665 |
|
| 666 |
.. tab-set:: |
| 667 |
|
| 668 |
.. tab-item:: Paginated Usage |
| 669 |
|
| 670 |
.. paginatedusage:: get_run_logs |
| 671 |
|
| 672 |
.. tab-item:: Example Response Data |
| 673 |
|
| 674 |
.. expandtestfixture:: flows.get_run_logs |
| 675 |
|
| 676 |
.. tab-item:: API Info |
| 677 |
|
| 678 |
.. extdoclink:: Get Run Logs |
| 679 |
:service: flows |
| 680 |
:ref: Runs/paths/~1runs~1{action_id}~1log/get |
| 681 |
""" |
| 682 |
|
| 683 |
query_params = { |
| 684 |
"limit": limit, |
| 685 |
"reverse_order": reverse_order, |
| 686 |
"marker": marker, |
| 687 |
**(query_params or {}), |
| 688 |
} |
| 689 |
return IterableRunLogsResponse( |
| 690 |
self.get(f"/runs/{run_id}/log", query_params=query_params) |
| 691 |
) |
| 692 |
|
| 693 |
def get_run( |
| 694 |
self, |
| 695 |
run_id: uuid.UUID | str, |
| 696 |
*, |
| 697 |
include_flow_description: bool | MissingType = MISSING, |
| 698 |
query_params: dict[str, t.Any] | None = None, |
| 699 |
) -> GlobusHTTPResponse: |
| 700 |
""" |
| 701 |
Retrieve information about a particular run of a flow |
| 702 |
|
| 703 |
:param run_id: The ID of the run to get |
| 704 |
:param include_flow_description: If set to true, the lookup will attempt to |
| 705 |
attach metadata about the flow to the run to the run response under the key |
| 706 |
"flow_description" (default: False) |
| 707 |
:param query_params: Any additional parameters to be passed through |
| 708 |
|
| 709 |
|
| 710 |
.. tab-set:: |
| 711 |
|
| 712 |
.. tab-item:: Example Usage |
| 713 |
|
| 714 |
.. code-block:: python |
| 715 |
|
| 716 |
from globus_sdk import FlowsClient |
| 717 |
|
| 718 |
flows = FlowsClient(...) |
| 719 |
flows.get_run("581753c7-45da-43d3-ad73-246b46e7cb6b") |
| 720 |
|
| 721 |
.. tab-item:: Example Response Data |
| 722 |
|
| 723 |
.. expandtestfixture:: flows.get_run |
| 724 |
|
| 725 |
.. tab-item:: API Info |
| 726 |
|
| 727 |
.. extdoclink:: Get Run |
| 728 |
:service: flows |
| 729 |
:ref: Flows/paths/~1runs~1{run_id}/get |
| 730 |
""" |
| 731 |
query_params = { |
| 732 |
"include_flow_description": include_flow_description, |
| 733 |
**(query_params or {}), |
| 734 |
} |
| 735 |
return self.get(f"/runs/{run_id}", query_params=query_params) |
| 736 |
|
| 737 |
def get_run_definition( |
| 738 |
self, |
| 739 |
run_id: uuid.UUID | str, |
| 740 |
) -> GlobusHTTPResponse: |
| 741 |
""" |
| 742 |
Get the flow definition and input schema at the time the run was started. |
| 743 |
|
| 744 |
:param run_id: The ID of the run to get |
| 745 |
|
| 746 |
.. tab-set:: |
| 747 |
|
| 748 |
.. tab-item:: Example Usage |
| 749 |
|
| 750 |
.. code-block:: python |
| 751 |
|
| 752 |
from globus_sdk import FlowsClient |
| 753 |
|
| 754 |
flows = FlowsClient(...) |
| 755 |
flows.get_run_definition("581753c7-45da-43d3-ad73-246b46e7cb6b") |
| 756 |
|
| 757 |
.. tab-item:: Example Response Data |
| 758 |
|
| 759 |
.. expandtestfixture:: flows.get_run_definition |
| 760 |
|
| 761 |
.. tab-item:: API Info |
| 762 |
|
| 763 |
.. extdoclink:: Get Run Definition |
| 764 |
:service: flows |
| 765 |
:ref: Flows/paths/~1runs~1{run_id}~1definition/get |
| 766 |
""" |
| 767 |
|
| 768 |
return self.get(f"/runs/{run_id}/definition") |
| 769 |
|
| 770 |
def cancel_run(self, run_id: uuid.UUID | str) -> GlobusHTTPResponse: |
| 771 |
""" |
| 772 |
Cancel a run. |
| 773 |
|
| 774 |
:param run_id: The ID of the run to cancel |
| 775 |
|
| 776 |
|
| 777 |
.. tab-set:: |
| 778 |
|
| 779 |
.. tab-item:: Example Usage |
| 780 |
|
| 781 |
.. code-block:: python |
| 782 |
|
| 783 |
from globus_sdk import FlowsClient |
| 784 |
|
| 785 |
flows = FlowsClient(...) |
| 786 |
flows.cancel_run("581753c7-45da-43d3-ad73-246b46e7cb6b") |
| 787 |
|
| 788 |
.. tab-item:: Example Response Data |
| 789 |
|
| 790 |
.. expandtestfixture:: flows.cancel_run |
| 791 |
|
| 792 |
.. tab-item:: API Info |
| 793 |
|
| 794 |
.. extdoclink:: Cancel Run |
| 795 |
:service: flows |
| 796 |
:ref: Runs/paths/~1runs~1{run_id}~1cancel/post |
| 797 |
""" |
| 798 |
|
| 799 |
return self.post(f"/runs/{run_id}/cancel") |
| 800 |
|
| 801 |
def update_run( |
| 802 |
self, |
| 803 |
run_id: uuid.UUID | str, |
| 804 |
*, |
| 805 |
label: str | MissingType = MISSING, |
| 806 |
tags: list[str] | MissingType = MISSING, |
| 807 |
run_monitors: list[str] | MissingType = MISSING, |
| 808 |
run_managers: list[str] | MissingType = MISSING, |
| 809 |
additional_fields: dict[str, t.Any] | None = None, |
| 810 |
) -> GlobusHTTPResponse: |
| 811 |
""" |
| 812 |
Update the metadata of a specific run. |
| 813 |
|
| 814 |
:param run_id: The ID of the run to update |
| 815 |
:param label: A short human-readable title (1 - 64 chars) |
| 816 |
:param tags: A collection of searchable tags associated with the run. |
| 817 |
Tags are normalized by stripping leading and trailing whitespace, |
| 818 |
and replacing all whitespace with a single space. |
| 819 |
:param run_monitors: A list of authenticated entities (identified by URN) |
| 820 |
authorized to view this run in addition to the run owner |
| 821 |
:param run_managers: A list of authenticated entities (identified by URN) |
| 822 |
authorized to view & cancel this run in addition to the run owner |
| 823 |
:param additional_fields: Additional Key/Value pairs sent to the run API |
| 824 |
(this parameter is used to bypass local sdk key validation helping) |
| 825 |
|
| 826 |
|
| 827 |
.. tab-set:: |
| 828 |
|
| 829 |
.. tab-item:: Example Usage |
| 830 |
|
| 831 |
.. code-block:: python |
| 832 |
|
| 833 |
from globus_sdk import FlowsClient |
| 834 |
|
| 835 |
flows = FlowsClient(...) |
| 836 |
flows.update_run( |
| 837 |
"581753c7-45da-43d3-ad73-246b46e7cb6b", |
| 838 |
label="Crunch numbers for experiment xDA202-batch-10", |
| 839 |
) |
| 840 |
|
| 841 |
.. tab-item:: Example Response Data |
| 842 |
|
| 843 |
.. expandtestfixture:: flows.update_run |
| 844 |
|
| 845 |
.. tab-item:: API Info |
| 846 |
|
| 847 |
.. extdoclink:: Update Run |
| 848 |
:service: flows |
| 849 |
:ref: Runs/paths/~1runs~1{run_id}/put |
| 850 |
""" |
| 851 |
|
| 852 |
data = { |
| 853 |
"tags": tags, |
| 854 |
"label": label, |
| 855 |
"run_monitors": run_monitors, |
| 856 |
"run_managers": run_managers, |
| 857 |
**(additional_fields or {}), |
| 858 |
} |
| 859 |
return self.put(f"/runs/{run_id}", data=data) |
| 860 |
|
| 861 |
def delete_run(self, run_id: uuid.UUID | str) -> GlobusHTTPResponse: |
| 862 |
""" |
| 863 |
Delete a run. |
| 864 |
|
| 865 |
:param run_id: The ID of the run to delete |
| 866 |
|
| 867 |
|
| 868 |
.. tab-set:: |
| 869 |
|
| 870 |
.. tab-item:: Example Usage |
| 871 |
|
| 872 |
.. code-block:: python |
| 873 |
|
| 874 |
from globus_sdk import FlowsClient |
| 875 |
|
| 876 |
flows = FlowsClient(...) |
| 877 |
flows.delete_run("581753c7-45da-43d3-ad73-246b46e7cb6b") |
| 878 |
|
| 879 |
.. tab-item:: Example Response Data |
| 880 |
|
| 881 |
.. expandtestfixture:: flows.delete_run |
| 882 |
|
| 883 |
.. tab-item:: API Info |
| 884 |
|
| 885 |
.. extdoclink:: Delete Run |
| 886 |
:service: flows |
| 887 |
:ref: Runs/paths/~1runs~1{run_id}~1release/post |
| 888 |
""" |
| 889 |
|
| 890 |
return self.post(f"/runs/{run_id}/release") |
| 891 |
|
| 892 |
def get_registered_api( |
| 893 |
self, |
| 894 |
registered_api_id: uuid.UUID | str, |
| 895 |
*, |
| 896 |
query_params: dict[str, t.Any] | None = None, |
| 897 |
) -> GlobusHTTPResponse: |
| 898 |
""" |
| 899 |
Retrieve a registered API by ID. |
| 900 |
|
| 901 |
:param registered_api_id: The ID of the registered API to fetch |
| 902 |
:param query_params: Any additional parameters to be passed through |
| 903 |
as query params. |
| 904 |
|
| 905 |
.. tab-set:: |
| 906 |
|
| 907 |
.. tab-item:: Example Usage |
| 908 |
|
| 909 |
.. code-block:: python |
| 910 |
|
| 911 |
from globus_sdk import FlowsClient |
| 912 |
|
| 913 |
flows = FlowsClient(...) |
| 914 |
flows.get_registered_api("a1b2c3d4-e5f6-7890-abcd-ef1234567890") |
| 915 |
|
| 916 |
.. tab-item:: Example Response Data |
| 917 |
|
| 918 |
.. expandtestfixture:: flows.get_registered_api |
| 919 |
|
| 920 |
.. tab-item:: API Info |
| 921 |
|
| 922 |
.. extdoclink:: Get Registered API |
| 923 |
:service: flows |
| 924 |
:ref: Registered APIs/paths/~1registered_apis~1 |
| 925 |
{registered_api_id}/get |
| 926 |
""" |
| 927 |
return self.get( |
| 928 |
f"/registered_apis/{registered_api_id}", query_params=query_params |
| 929 |
) |
| 930 |
|
| 931 |
@paging.has_paginator(paging.MarkerPaginator, items_key="registered_apis") |
| 932 |
def list_registered_apis( |
| 933 |
self, |
| 934 |
*, |
| 935 |
filter_roles: str | t.Iterable[str] | MissingType = MISSING, |
| 936 |
orderby: str | t.Iterable[str] | MissingType = MISSING, |
| 937 |
per_page: int | MissingType = MISSING, |
| 938 |
marker: str | MissingType = MISSING, |
| 939 |
query_params: dict[str, t.Any] | None = None, |
| 940 |
) -> IterableRegisteredAPIsResponse: |
| 941 |
""" |
| 942 |
List registered APIs. |
| 943 |
|
| 944 |
:param filter_roles: Role names to filter results (owner, administrator, viewer) |
| 945 |
:param orderby: Field and order for sorting results |
| 946 |
:param per_page: Number of results per page |
| 947 |
:param marker: Pagination marker for continuing results |
| 948 |
:param query_params: Any additional parameters to be passed through |
| 949 |
as query params. |
| 950 |
|
| 951 |
.. tab-set:: |
| 952 |
|
| 953 |
.. tab-item:: Example Usage |
| 954 |
|
| 955 |
.. code-block:: python |
| 956 |
|
| 957 |
from globus_sdk import FlowsClient |
| 958 |
|
| 959 |
flows = FlowsClient(...) |
| 960 |
for api in flows.list_registered_apis(filter_roles="owner"): |
| 961 |
print(f"API: {api['name']}") |
| 962 |
|
| 963 |
.. tab-item:: Paginated Usage |
| 964 |
|
| 965 |
.. paginatedusage:: list_registered_apis |
| 966 |
|
| 967 |
.. tab-item:: API Info |
| 968 |
|
| 969 |
.. extdoclink:: List Registered APIs |
| 970 |
:service: flows |
| 971 |
:ref: Registered APIs/paths/~1registered_apis/get |
| 972 |
""" |
| 973 |
query_params = { |
| 974 |
"filter_roles": commajoin(filter_roles), |
| 975 |
"orderby": ( |
| 976 |
orderby if isinstance(orderby, (str, MissingType)) else list(orderby) |
| 977 |
), |
| 978 |
"marker": marker, |
| 979 |
"per_page": per_page, |
| 980 |
**(query_params or {}), |
| 981 |
} |
| 982 |
return IterableRegisteredAPIsResponse( |
| 983 |
self.get("/registered_apis", query_params=query_params) |
| 984 |
) |
| 985 |
|
| 986 |
|
| 987 |
class SpecificFlowClient(client.BaseClient): |
| 988 |
r""" |
| 989 |
Client for interacting with a specific flow through the Globus Flows API. |
| 990 |
|
| 991 |
Unlike other client types, this must be provided with a specific flow id. All other |
| 992 |
arguments are the same as those for :class:`~globus_sdk.BaseClient`. |
| 993 |
|
| 994 |
.. sdk-sphinx-copy-params:: BaseClient |
| 995 |
|
| 996 |
:param flow_id: The generated UUID associated with a flow |
| 997 |
|
| 998 |
.. automethodlist:: globus_sdk.SpecificFlowClient |
| 999 |
""" |
| 1000 |
|
| 1001 |
error_class = FlowsAPIError |
| 1002 |
service_name = "flows" |
| 1003 |
scopes: SpecificFlowScopes = SpecificFlowScopes._build_class_stub() |
| 1004 |
|
| 1005 |
def __init__( |
| 1006 |
self, |
| 1007 |
flow_id: uuid.UUID | str, |
| 1008 |
*, |
| 1009 |
environment: str | None = None, |
| 1010 |
app: GlobusApp | None = None, |
| 1011 |
app_scopes: list[Scope] | None = None, |
| 1012 |
authorizer: GlobusAuthorizer | None = None, |
| 1013 |
app_name: str | None = None, |
| 1014 |
transport: RequestsTransport | None = None, |
| 1015 |
retry_config: RetryConfig | None = None, |
| 1016 |
) -> None: |
| 1017 |
self._flow_id = flow_id |
| 1018 |
self.scopes = SpecificFlowScopes(flow_id) |
| 1019 |
super().__init__( |
| 1020 |
app=app, |
| 1021 |
app_scopes=app_scopes, |
| 1022 |
environment=environment, |
| 1023 |
authorizer=authorizer, |
| 1024 |
app_name=app_name, |
| 1025 |
transport=transport, |
| 1026 |
retry_config=retry_config, |
| 1027 |
) |
| 1028 |
|
| 1029 |
@property |
| 1030 |
def default_scope_requirements(self) -> list[Scope]: |
| 1031 |
return [self.scopes.user] |
| 1032 |
|
| 1033 |
def add_app_transfer_data_access_scope( |
| 1034 |
self, collection_ids: uuid.UUID | str | t.Iterable[uuid.UUID | str] |
| 1035 |
) -> Self: |
| 1036 |
""" |
| 1037 |
Add a dependent ``data_access`` scope for one or more given ``collection_ids`` |
| 1038 |
to this client's ``GlobusApp``, under the Transfer ``all`` scope. |
| 1039 |
Useful for preventing ``ConsentRequired`` errors when starting or resuming runs |
| 1040 |
of flows that use Globus Connect Server mapped collection(s). |
| 1041 |
|
| 1042 |
.. warning:: |
| 1043 |
|
| 1044 |
This method must only be used on ``collection_ids`` for non-High-Assurance |
| 1045 |
GCS Mapped Collections. |
| 1046 |
|
| 1047 |
Use on other collection types, e.g., on GCP Mapped Collections or any form |
| 1048 |
of Guest Collection, will result in "Unknown Scope" errors during the login |
| 1049 |
flow. |
| 1050 |
|
| 1051 |
Returns ``self`` for chaining. |
| 1052 |
|
| 1053 |
Raises ``GlobusSDKUsageError`` if this client was not initialized with an app. |
| 1054 |
|
| 1055 |
:param collection_ids: a collection ID or an iterable of IDs. |
| 1056 |
|
| 1057 |
.. tab-set:: |
| 1058 |
|
| 1059 |
.. tab-item:: Example Usage |
| 1060 |
|
| 1061 |
.. code-block:: python |
| 1062 |
|
| 1063 |
flow_id = ... |
| 1064 |
COLLECTION_ID = ... |
| 1065 |
app = UserApp("myapp", client_id=NATIVE_APP_CLIENT_ID) |
| 1066 |
client = SpecificFlowClient(FLOW_ID, app=app).add_app_transfer_data_access_scope( |
| 1067 |
COLLECTION_ID |
| 1068 |
) |
| 1069 |
|
| 1070 |
client.run_flow({"collection": COLLECTION_ID}) |
| 1071 |
""" # noqa: E501 |
| 1072 |
if isinstance(collection_ids, (str, uuid.UUID)): |
| 1073 |
guards.validators.uuidlike("collection_ids", collection_ids) |
| 1074 |
# wrap the collection_ids input in a list for consistent iteration below |
| 1075 |
collection_ids_ = [collection_ids] |
| 1076 |
else: |
| 1077 |
# copy to a list so that ephemeral iterables can be iterated multiple times |
| 1078 |
collection_ids_ = list(collection_ids) |
| 1079 |
for i, c in enumerate(collection_ids_): |
| 1080 |
guards.validators.uuidlike(f"collection_ids[{i}]", c) |
| 1081 |
|
| 1082 |
transfer_scope = TransferScopes.all.with_optional(True) |
| 1083 |
for coll_id in collection_ids_: |
| 1084 |
data_access_scope = GCSCollectionScopes( |
| 1085 |
str(coll_id) |
| 1086 |
).data_access.with_optional(True) |
| 1087 |
transfer_scope = transfer_scope.with_dependency(data_access_scope) |
| 1088 |
|
| 1089 |
specific_flow_scope = self.scopes.user.with_dependency(transfer_scope) |
| 1090 |
self.add_app_scope(specific_flow_scope) |
| 1091 |
return self |
| 1092 |
|
| 1093 |
def run_flow( |
| 1094 |
self, |
| 1095 |
body: dict[str, t.Any], |
| 1096 |
*, |
| 1097 |
label: str | MissingType = MISSING, |
| 1098 |
tags: list[str] | MissingType = MISSING, |
| 1099 |
activity_notification_policy: ( |
| 1100 |
dict[str, t.Any] | RunActivityNotificationPolicy | MissingType |
| 1101 |
) = MISSING, |
| 1102 |
run_monitors: list[str] | MissingType = MISSING, |
| 1103 |
run_managers: list[str] | MissingType = MISSING, |
| 1104 |
additional_fields: dict[str, t.Any] | None = None, |
| 1105 |
) -> GlobusHTTPResponse: |
| 1106 |
""" |
| 1107 |
:param body: The input json object handed to the first flow state. The flows |
| 1108 |
service will validate this object against the flow's supplied input schema. |
| 1109 |
:param label: A short human-readable title (1 - 64 chars) |
| 1110 |
:param tags: A collection of searchable tags associated with the run. Tags are |
| 1111 |
normalized by stripping leading and trailing whitespace, and replacing all |
| 1112 |
whitespace with a single space. |
| 1113 |
:param activity_notification_policy: A policy document which declares when the |
| 1114 |
run will send notification emails. By default, notifications are only sent |
| 1115 |
when a run status changes to ``"INACTIVE"``. |
| 1116 |
:param run_monitors: A list of authenticated entities (identified by URN) |
| 1117 |
authorized to view this run in addition to the run owner |
| 1118 |
:param run_managers: A list of authenticated entities (identified by URN) |
| 1119 |
authorized to view & cancel this run in addition to the run owner |
| 1120 |
:param additional_fields: Additional Key/Value pairs sent to the run API |
| 1121 |
(this parameter is used to bypass local sdk key validation helping) |
| 1122 |
|
| 1123 |
.. tab-set:: |
| 1124 |
|
| 1125 |
.. tab-item:: API Info |
| 1126 |
|
| 1127 |
.. extdoclink:: Run Flow |
| 1128 |
:service: flows |
| 1129 |
:ref: ~1flows~1{flow_id}~1run/post |
| 1130 |
""" |
| 1131 |
data = { |
| 1132 |
"body": body, |
| 1133 |
"tags": tags, |
| 1134 |
"label": label, |
| 1135 |
"activity_notification_policy": activity_notification_policy, |
| 1136 |
"run_monitors": run_monitors, |
| 1137 |
"run_managers": run_managers, |
| 1138 |
**(additional_fields or {}), |
| 1139 |
} |
| 1140 |
return self.post(f"/flows/{self._flow_id}/run", data=data) |
| 1141 |
|
| 1142 |
def resume_run(self, run_id: uuid.UUID | str) -> GlobusHTTPResponse: |
| 1143 |
""" |
| 1144 |
:param run_id: The ID of the run to resume |
| 1145 |
|
| 1146 |
.. tab-set:: |
| 1147 |
|
| 1148 |
.. tab-item:: Example Usage |
| 1149 |
|
| 1150 |
.. code-block:: python |
| 1151 |
|
| 1152 |
from globus_sdk import SpecificFlowClient |
| 1153 |
|
| 1154 |
... |
| 1155 |
flow = SpecificFlowClient(flow_id, ...) |
| 1156 |
flow.resume_run(run_id) |
| 1157 |
|
| 1158 |
.. tab-item:: Example Response Data |
| 1159 |
|
| 1160 |
.. expandtestfixture:: flows.resume_run |
| 1161 |
|
| 1162 |
.. tab-item:: API Info |
| 1163 |
|
| 1164 |
.. extdoclink:: Resume Run |
| 1165 |
:service: flows |
| 1166 |
:ref: Runs/paths/~1flows~1{flow_id}~1runs~1{run_id}~1resume/post |
| 1167 |
""" |
| 1168 |
return self.post(f"/runs/{run_id}/resume") |
| 1169 |
|
| 1170 |
def validate_run( |
| 1171 |
self, |
| 1172 |
body: dict[str, t.Any], |
| 1173 |
*, |
| 1174 |
label: str | MissingType = MISSING, |
| 1175 |
tags: list[str] | MissingType = MISSING, |
| 1176 |
run_monitors: list[str] | MissingType = MISSING, |
| 1177 |
run_managers: list[str] | MissingType = MISSING, |
| 1178 |
activity_notification_policy: ( |
| 1179 |
dict[str, t.Any] | RunActivityNotificationPolicy | MissingType |
| 1180 |
) = MISSING, |
| 1181 |
additional_fields: dict[str, t.Any] | None = None, |
| 1182 |
) -> GlobusHTTPResponse: |
| 1183 |
""" |
| 1184 |
:param body: The parameters to validate against the flow's input schema. |
| 1185 |
:param label: A short human-readable title. |
| 1186 |
:param tags: A collection of searchable tags associated with the run. |
| 1187 |
Tags are normalized by stripping leading and trailing whitespace, |
| 1188 |
and replacing all whitespace with a single space. |
| 1189 |
:param run_monitors: A list of Globus Auth principals (identified by URN) |
| 1190 |
authorized to monitor this run (in addition to the run owner). |
| 1191 |
:param run_managers: A list of Globus Auth principals (identified by URN) |
| 1192 |
authorized to manage this run (in addition to the run owner). |
| 1193 |
:param activity_notification_policy: |
| 1194 |
A policy document which declares when the Flows service will send |
| 1195 |
notification emails regarding the run's activity. |
| 1196 |
:param additional_fields: Additional key/value pairs sent to the run API. |
| 1197 |
This parameter can be used to bypass SDK parameter validation. |
| 1198 |
|
| 1199 |
.. tab-set:: |
| 1200 |
|
| 1201 |
.. tab-item:: Example Usage |
| 1202 |
|
| 1203 |
.. code-block:: python |
| 1204 |
|
| 1205 |
from globus_sdk import SpecificFlowClient |
| 1206 |
|
| 1207 |
... |
| 1208 |
flow = SpecificFlowClient(flow_id, ...) |
| 1209 |
flow.validate_run(body={"param": "value"}) |
| 1210 |
.. tab-item:: Example Response Data |
| 1211 |
|
| 1212 |
.. expandtestfixture:: flows.validate_run |
| 1213 |
""" |
| 1214 |
|
| 1215 |
data = { |
| 1216 |
"body": body, |
| 1217 |
"tags": tags, |
| 1218 |
"label": label, |
| 1219 |
"run_monitors": run_monitors, |
| 1220 |
"run_managers": run_managers, |
| 1221 |
"activity_notification_policy": activity_notification_policy, |
| 1222 |
} |
| 1223 |
data.update(additional_fields or {}) |
| 1224 |
|
| 1225 |
return self.post(f"/flows/{self._flow_id}/validate_run", data=data) |