From 82bffc9046894656f91dd16a7df5d3738777866b Mon Sep 17 00:00:00 2001 From: Ville Tuulos Date: Thu, 25 Jul 2024 00:22:32 -0700 Subject: [PATCH] make deployer docstrings work with API docs --- .../plugins/argo/argo_workflows_deployer.py | 38 +++++-------------- .../step_functions/step_functions_deployer.py | 29 ++++---------- metaflow/runner/deployer.py | 26 ++++++------- 3 files changed, 29 insertions(+), 64 deletions(-) diff --git a/metaflow/plugins/argo/argo_workflows_deployer.py b/metaflow/plugins/argo/argo_workflows_deployer.py index a1a82df5992..57f95dda34d 100644 --- a/metaflow/plugins/argo/argo_workflows_deployer.py +++ b/metaflow/plugins/argo/argo_workflows_deployer.py @@ -14,12 +14,10 @@ def suspend(instance: TriggeredRun, **kwargs): """ - Suspend a running workflow. + Suspend the running workflow. Parameters ---------- - instance : TriggeredRun - The triggered run instance to suspend. **kwargs : Any Additional arguments to pass to the suspend command. @@ -51,12 +49,10 @@ def suspend(instance: TriggeredRun, **kwargs): def unsuspend(instance: TriggeredRun, **kwargs): """ - Unsuspend a suspended workflow. + Unsuspend the suspended workflow. Parameters ---------- - instance : TriggeredRun - The triggered run instance to unsuspend. **kwargs : Any Additional arguments to pass to the unsuspend command. @@ -88,12 +84,10 @@ def unsuspend(instance: TriggeredRun, **kwargs): def terminate(instance: TriggeredRun, **kwargs): """ - Terminate a running workflow. + Terminate the running workflow. Parameters ---------- - instance : TriggeredRun - The triggered run instance to terminate. **kwargs : Any Additional arguments to pass to the terminate command. @@ -125,12 +119,7 @@ def terminate(instance: TriggeredRun, **kwargs): def status(instance: TriggeredRun): """ - Get the status of a triggered run. - - Parameters - ---------- - instance : TriggeredRun - The triggered run instance to get the status of. + Get the status of the triggered run. Returns ------- @@ -151,12 +140,7 @@ def status(instance: TriggeredRun): def production_token(instance: DeployedFlow): """ - Get the production token for a deployed flow. - - Parameters - ---------- - instance : DeployedFlow - The deployed flow instance to get the production token for. + Get the production token for the deployed flow. Returns ------- @@ -174,12 +158,10 @@ def production_token(instance: DeployedFlow): def delete(instance: DeployedFlow, **kwargs): """ - Delete a deployed flow. + Delete the deployed flow. Parameters ---------- - instance : DeployedFlow - The deployed flow instance to delete. **kwargs : Any Additional arguments to pass to the delete command. @@ -208,18 +190,16 @@ def delete(instance: DeployedFlow, **kwargs): def trigger(instance: DeployedFlow, **kwargs): """ - Trigger a new run for a deployed flow. + Trigger a new run for the deployed flow. Parameters ---------- - instance : DeployedFlow - The deployed flow instance to trigger a new run for. **kwargs : Any - Additional arguments to pass to the trigger command. + Additional arguments to pass to the trigger command, `Parameters` in particular Returns ------- - TriggeredRun + ArgoWorkflowsTriggeredRun The triggered run instance. Raises diff --git a/metaflow/plugins/aws/step_functions/step_functions_deployer.py b/metaflow/plugins/aws/step_functions/step_functions_deployer.py index b22af98fc45..1bb5f2cf048 100644 --- a/metaflow/plugins/aws/step_functions/step_functions_deployer.py +++ b/metaflow/plugins/aws/step_functions/step_functions_deployer.py @@ -15,12 +15,10 @@ def terminate(instance: TriggeredRun, **kwargs): """ - Terminate a running workflow. + Terminate the running workflow. Parameters ---------- - instance : TriggeredRun - The triggered run instance to terminate. **kwargs : Any Additional arguments to pass to the terminate command. @@ -52,12 +50,7 @@ def terminate(instance: TriggeredRun, **kwargs): def production_token(instance: DeployedFlow): """ - Get the production token for a deployed flow. - - Parameters - ---------- - instance : DeployedFlow - The deployed flow instance to get the production token for. + Get the production token for the deployed flow. Returns ------- @@ -75,15 +68,13 @@ def production_token(instance: DeployedFlow): def list_runs(instance: DeployedFlow, states: Optional[List[str]] = None): """ - List runs of a deployed flow. + List runs of the deployed flow. Parameters ---------- - instance : DeployedFlow - The deployed flow instance to list runs for. states : Optional[List[str]], optional A list of states to filter the runs by. Allowed values are: - "RUNNING", "SUCCEEDED", "FAILED", "TIMED_OUT", "ABORTED". + RUNNING, SUCCEEDED, FAILED, TIMED_OUT, ABORTED. If not provided, all states will be considered. Returns @@ -134,12 +125,10 @@ def list_runs(instance: DeployedFlow, states: Optional[List[str]] = None): def delete(instance: DeployedFlow, **kwargs): """ - Delete a deployed flow. + Delete the deployed flow. Parameters ---------- - instance : DeployedFlow - The deployed flow instance to delete. **kwargs : Any Additional arguments to pass to the delete command. @@ -168,18 +157,16 @@ def delete(instance: DeployedFlow, **kwargs): def trigger(instance: DeployedFlow, **kwargs): """ - Trigger a new run for a deployed flow. + Trigger a new run for the deployed flow. Parameters ---------- - instance : DeployedFlow - The deployed flow instance to trigger a new run for. **kwargs : Any - Additional arguments to pass to the trigger command. + Additional arguments to pass to the trigger command, `Parameters` in particular Returns ------- - TriggeredRun + StepFunctionsTriggeredRun The triggered run instance. Raises diff --git a/metaflow/runner/deployer.py b/metaflow/runner/deployer.py index c48718bca19..680e8b0a5cd 100644 --- a/metaflow/runner/deployer.py +++ b/metaflow/runner/deployer.py @@ -85,10 +85,8 @@ def get_lower_level_group( class Deployer(object): """ - Deployer class for managing deployment of flows using different provider implementations. - - This class dynamically adds methods for each deployment provider available in - `DEPLOYER_IMPL_PROVIDERS`. + Use the `Deployer` class to configure and access one of the production + orchestrators supported by Metaflow. Parameters ---------- @@ -165,14 +163,10 @@ def f(self, **deployer_kwargs): class TriggeredRun(object): """ - TriggeredRun class represents a run that has been triggered for deployment. + TriggeredRun class represents a run that has been triggered on a production orchestrator. - Parameters - ---------- - deployer : DeployerImpl - Instance of the deployer implementation. - content : str - JSON content containing metadata and pathspec for the run. + Only when the `start` task starts running, the `run` object corresponding to the run + becomes available. """ def __init__( @@ -206,12 +200,15 @@ def _enrich_object(self, env): @property def run(self): """ - Retrieve the Run object for the triggered run. + Retrieve the `Run` object for the triggered run. + + Note that Metaflow `Run` becomes available only when the `start` task + has started executing. Returns ------- Run, optional - Metaflow Run object if available else None. + Metaflow Run object if the `start` step has started executing, otherwise None. """ from metaflow import Run @@ -322,7 +319,8 @@ def create(self, **kwargs) -> DeployedFlow: Parameters ---------- **kwargs : Any - Additional arguments to pass to the `create` method of the deployer implementation. + Additional arguments to pass to `create` corresponding to the + command line arguments of `create` Returns -------