Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
RizaFarheen committed Mar 27, 2024
1 parent c739241 commit 77b82dd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Conductor OSS Python SDK

Python SDK for working with https://github.com/conductor-oss/conductor
Python SDK for working with https://github.com/conductor-oss/conductor.

[Conductor](https://www.conductor-oss.org/) is the leading open-source orchestration platform allowing developers to build highly scalable distributed applications.

Expand Down Expand Up @@ -28,7 +28,7 @@ Show support for the Conductor OSS. Please help spread the awareness by starrin
- [Running Workflows on Conductor Standalone (Installed Locally)](#running-workflows-on-conductor-standalone-installed-locally)
- [Setup Environment Variable](#setup-environment-variable)
- [Start Conductor Server](#start-conductor-server)
- [Execute the Hello World application](#execute-the-hello-world-application)
- [Execute Hello World Application](#execute-hello-world-application)
- [Running Workflows on Orkes Conductor](#running-workflows-on-orkes-conductor)
- [Learn More about Conductor Python SDK](#learn-more-about-conductor-python-sdk)
- [Create and Run Conductor Workers](#create-and-run-conductor-workers)
Expand All @@ -39,7 +39,7 @@ Show support for the Conductor OSS. Please help spread the awareness by starrin

## Install Conductor Python SDK

Before installing Conductor Python SDK, it is a good practice to setup a dedicated virtual environment as follow:
Before installing Conductor Python SDK, it is a good practice to set up a dedicated virtual environment as follows:

```shell
virtualenv conductor
Expand Down Expand Up @@ -127,7 +127,7 @@ def greet(name: str) -> str:
return f'Hello {name}'

```
Now we are ready to write our main application that will execute our workflow.
Now, we are ready to write our main application, which will execute our workflow.

### Step 3: Write _Hello World_ Application

Expand Down Expand Up @@ -189,21 +189,21 @@ docker run --init -p 8080:8080 -p 5000:5000 conductoross/conductor-standalone:3.
```
To ensure the server has started successfully, open Conductor UI on http://localhost:5000.

### Execute the Hello World application
### Execute Hello World Application

To run the application, type the following command:

```
python helloworld.py
```

Now the workflow is executed, and its execution status can be viewed from Conductor UI (http://localhost:5000).
Now, the workflow is executed, and its execution status can be viewed from Conductor UI (http://localhost:5000).

Navigate to the **Executions** tab to view the workflow execution.

<img width="1434" alt="Screenshot 2024-03-18 at 12 30 07" src="https://github.com/Srividhya-S-Subramanian/conductor-python-v1/assets/163816773/11e829b6-d46a-4b47-b2cf-0bf524a6ebdc">

Open the Workbench tab and try running the 'grettings' workflow. You will notice that the workflow execution fails. This is because the task_handler.stop_processes() [helloworld.py] function is called and stops all workers included in the app and therefore there is no worker up and running to execute the tasks.
Open the Workbench tab and try running the 'greetings' workflow. You will notice that the workflow execution fails. This is because the task_handler.stop_processes() [helloworld.py] function is called and stops all workers included in the app, and therefore, there is no worker up and running to execute the tasks.

Now, let's update the app `helloworld.py`

Expand Down Expand Up @@ -258,7 +258,7 @@ For running the workflow in Orkes Conductor,
export CONDUCTOR_SERVER_URL=https://[cluster-name].orkesconductor.io/api
```

- If you want to run the workflow on the Orkes Conductor Playground, set the Conductor Server variable as follow:
- If you want to run the workflow on the Orkes Conductor Playground, set the Conductor Server variable as follows:

```shell
export CONDUCTOR_SERVER_URL=https://play.orkes.io/api
Expand All @@ -271,7 +271,7 @@ export CONDUCTOR_AUTH_KEY=your_key
export CONDUCTOR_AUTH_SECRET=your_key_secret
```

Run the application and view the executions status from Conductor's UI Console.
Run the application and view the execution status from Conductor's UI Console.

> [!NOTE]
> That's it - you just created and executed your first distributed Python app!
Expand Down
1 change: 0 additions & 1 deletion workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ A Workflow task represents a unit of business logic that achieves a specific goa
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [](#)
- [Implementing Workers](#implementing-workers)
- [Managing Workers in Application](#managing-workers-in-application)
- [Design Principles for Workers](#design-principles-for-workers)
Expand Down
46 changes: 29 additions & 17 deletions workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ workflow_client = clients.get_workflow_client()
```
### Execute Workflow Asynchronously

UUseful when workflows are long-running.
Useful when workflows are long-running.

```python
from conductor.client.http.models import StartWorkflowRequest
Expand Down Expand Up @@ -193,25 +193,33 @@ workflow_client = clients.get_workflow_client()

The following method lets you query the status of the workflow execution given the id. When the `include_tasks` is set, the response also includes all the completed and in-progress tasks.

`get_workflow(workflow_id: str, include_tasks: Optional[bool] = True) -> Workflow`
```python
get_workflow(workflow_id: str, include_tasks: Optional[bool] = True) -> Workflow
```

### Update Workflow State Variables

Variables inside a workflow are the equivalent of global variables in a program.

`update_variables(self, workflow_id: str, variables: dict[str, object] = {})`
```python
update_variables(self, workflow_id: str, variables: dict[str, object] = {})
```

### Terminate Running Workflows

Used to terminate a running workflow. Any pending tasks are canceled, and no further work is scheduled for this workflow upon termination. A failure workflow will be triggered but can be avoided if `trigger_failure_workflow` is set to False.

`terminate_workflow(self, workflow_id: str, reason: Optional[str] = None, trigger_failure_workflow: bool = False)`
```python
terminate_workflow(self, workflow_id: str, reason: Optional[str] = None, trigger_failure_workflow: bool = False)
```

### Retry Failed Workflows

If the workflow has failed due to one of the task failures after exhausting the retries for the task, the workflow can still be resumed by calling the retry.

`retry_workflow(self, workflow_id: str, resume_subworkflow_tasks: Optional[bool] = False)`
```python
retry_workflow(self, workflow_id: str, resume_subworkflow_tasks: Optional[bool] = False)
```

When a sub-workflow inside a workflow has failed, there are two options:

Expand All @@ -222,13 +230,17 @@ When a sub-workflow inside a workflow has failed, there are two options:

A workflow in the terminal state (COMPLETED, TERMINATED, FAILED) can be restarted from the beginning. Useful when retrying from the last failed task is insufficient, and the whole workflow must be started again.

`restart_workflow(self, workflow_id: str, use_latest_def: Optional[bool] = False)`
```python
restart_workflow(self, workflow_id: str, use_latest_def: Optional[bool] = False)
```

### Rerun Workflow from a Specific Task

In the cases where a workflow needs to be restarted from a specific task rather than from the beginning, rerun provides that option. When issuing the rerun command to the workflow, you can specify the task ID from where the workflow should be restarted (as opposed to from the beginning), and optionally, the workflow's input can also be changed.

`rerun_workflow(self, workflow_id: str, rerun_workflow_request: RerunWorkflowRequest)`
```python
rerun_workflow(self, workflow_id: str, rerun_workflow_request: RerunWorkflowRequest)
```

> [!tip]
> Rerun is one of the most powerful features Conductor has, giving you unparalleled control over the workflow restart.
Expand All @@ -238,19 +250,25 @@ In the cases where a workflow needs to be restarted from a specific task rather

A running workflow can be put to a PAUSED status. A paused workflow lets the currently running tasks complete but does not schedule any new tasks until resumed.

`pause_workflow(self, workflow_id: str)`
```python
pause_workflow(self, workflow_id: str)
```

### Resume Paused Workflow

Resume operation resumes the currently paused workflow, immediately evaluating its state and scheduling the next set of tasks.

`resume_workflow(self, workflow_id: str)`
```python
resume_workflow(self, workflow_id: str)
```

## Searching for Workflows

Workflow executions are retained until removed from the Conductor. This gives complete visibility into all the executions an application has - regardless of the number of executions. Conductor has a powerful search API that allows you to search for workflow executions.

`search(self, start, size, free_text: str = '*', query: str = None) -> ScrollableSearchResultWorkflowSummary`
```python
search(self, start, size, free_text: str = '*', query: str = None) -> ScrollableSearchResultWorkflowSummary
```

* **free_text**: Free text search to look for specific words in the workflow and task input/output.
* **query** SQL-like query to search against specific fields in the workflow.
Expand Down Expand Up @@ -350,10 +368,4 @@ def main():
POST /api/metadata/taskdef -d @task_def.json
```

See [task_configure.py](examples/task_configure.py) for a detailed working app.






See [task_configure.py](examples/task_configure.py) for a detailed working app.

0 comments on commit 77b82dd

Please sign in to comment.