Skip to content

Commit

Permalink
refactor: remove python workflow support
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgrittner committed Nov 22, 2024
1 parent 7409415 commit 08f4f8a
Show file tree
Hide file tree
Showing 58 changed files with 2,682 additions and 5,116 deletions.
18 changes: 6 additions & 12 deletions admyral/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json

from admyral.cli.cli import cli
from admyral.compiler.workflow_compiler import WorkflowCompiler
from admyral.models import TriggerStatus
from admyral.client import AdmyralClient
from admyral.utils.telemetry import capture
Expand All @@ -14,25 +13,21 @@ def workflow() -> None:
"""Workflow Management"""


# TODO: add option for pushing all used Python actions automatically
@workflow.command(
"push",
help="Push a workflow to Admyral",
)
@click.argument("workflow_name", type=str)
@click.option(
"--file",
"-f",
@click.argument(
"file",
type=str,
help="Path to the Python file containing the workflow",
)
@click.option(
"--activate",
is_flag=True,
help="Activate the workflow after pushing it to Admyral",
)
@click.pass_context
def push(ctx: click.Context, workflow_name: str, file: str, activate: bool) -> None:
def push(ctx: click.Context, file: str, activate: bool) -> None:
"""Push workflow to Admyral"""
capture(event_name="workflow:push")
client: AdmyralClient = ctx.obj
Expand All @@ -43,19 +38,18 @@ def push(ctx: click.Context, workflow_name: str, file: str, activate: bool) -> N
return
with open(file, "r") as f:
workflow_code = f.read()
workflow_dag = WorkflowCompiler().compile_from_module(workflow_code, workflow_name)

# Push workflow to Admyral
try:
workflow_push_response = client.push_workflow(
workflow_name=workflow_name, workflow_dag=workflow_dag, is_active=activate
workflow_code=workflow_code, is_active=activate
)
except Exception as e:
click.echo(f"Failed to push workflow {workflow_name}.")
click.echo(f"Failed to push workflow from {file}.")
click.echo(f"Error: {e}")
return

click.echo(f"Workflow {workflow_name} pushed successfully.")
click.echo("Workflow pushed successfully.")

if workflow_push_response.webhook_id:
click.echo(f"Webhook ID: {workflow_push_response.webhook_id}")
Expand Down
7 changes: 3 additions & 4 deletions admyral/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from admyral.models import (
Workflow,
WorkflowDAG,
PythonAction,
WorkflowPushResponse,
Secret,
Expand Down Expand Up @@ -98,7 +97,7 @@ def get_workflow(self, workflow_name: str) -> Workflow | None:
return Workflow.model_validate(result) if result else None

def push_workflow(
self, workflow_name: str, workflow_dag: WorkflowDAG, is_active: bool = False
self, workflow_code: str, is_active: bool = False
) -> WorkflowPushResponse:
"""
Pushes the workflow to the server.
Expand All @@ -111,9 +110,9 @@ def push_workflow(
if the workflow has webhook enabled.
"""
response = self._post(
f"{API_V1_STR}/workflows/{workflow_name}/push",
f"{API_V1_STR}/workflows/push",
WorkflowPushRequest(
workflow_dag=workflow_dag,
workflow_code=workflow_code,
activate=is_active,
).model_dump(),
)
Expand Down
Loading

0 comments on commit 08f4f8a

Please sign in to comment.