Package: conductor-python
Conductor OSS Python SDKPython SDK for working withhttps://github.com/conductor-oss/conductorConductoris an open source distributed, scalable and highly available
orchestration platform that allows developers to build powerful distributed applications.
You can find the documentation for Conductor here:Conductor Docs⭐ Conductor OSSShow support for the Conductor OSS.  Please help spread the awareness by starring Conductor repo.ContentInstall SDKGet Conductor Python SDKSetup SDKStart Conductor ServerSimple Hello World Application using ConductorStep 1: Create a WorkflowStep 2: Write WorkerStep 3: WriteyourapplicationUsing Conductor in your applicationCreate and Run Conductor WorkersCreate Conductor WorkflowsUsing Conductor in your ApplicationInstall SDKCreate a virtual environment to build your packagevirtualenvconductorsourceconductor/bin/activateGet Conductor Python SDKSDK needs Python 3.9+.python3-mpipinstallconductor-pythonSetup SDKPoint the SDK to the Conductor Server API endpointexportCONDUCTOR_SERVER_URL=http://localhost:8080/api(Optionally) If you are using a Conductor server that requires authenticationHow to obtain the key and secret from the conductor serverexportCONDUCTOR_AUTH_KEY=your_keyexportCONDUCTOR_AUTH_SECRET=your_key_secretStart Conductor Serverdockerrun--init-p8080:8080-p5000:5000conductoross/conductor-standalone:3.15.0After starting the server navigate tohttp://localhost:1234to ensure the server has started successfully.Simple Hello World Application using ConductorIn this section, we will create a simple "Hello World" application that uses Conductor.Step 1: Create a WorkflowUse Code to create workflowsCreategreetings_workflow.pywith the following:fromconductor.client.workflow.conductor_workflowimportConductorWorkflowfromconductor.client.workflow.executor.workflow_executorimportWorkflowExecutorfromgreetingsimportgreetdefgreetings_workflow(workflow_executor:WorkflowExecutor)->ConductorWorkflow:name='hello'workflow=ConductorWorkflow(name=name,executor=workflow_executor)workflow.version=1workflow>>greet(task_ref_name='greet_ref',name=workflow.input('name'))returnworkflow(alternatively) Use JSON to create workflowsCreate workflow.json with the following:{"name":"hello","description":"hello workflow","version":1,"tasks":[{"name":"greet","taskReferenceName":"greet_ref","type":"SIMPLE","inputParameters":{"name":"${workflow.input.name}"}}],"timeoutPolicy":"TIME_OUT_WF","timeoutSeconds":60}Now, register this workflow with the server:curl-XPOST-H"Content-Type:application/json"\http://localhost:8080/api/metadata/workflow-d@workflow.jsonStep 2: Write WorkerCreategreetings.pywith a simple worker and a workflow function.[!note]
A single workflow application can have workers written in different languages.fromconductor.client.worker.worker_taskimportworker_task@worker_task(task_definition_name='greet')defgreet(name:str)->str:returnf'Hello my friend{name}'Step 3: WriteyourapplicationLet's addgreetings_main.pywith themainmethod:fromconductor.client.automator.task_handlerimportTaskHandlerfromconductor.client.configuration.configurationimportConfigurationfromconductor.client.workflow.conductor_workflowimportConductorWorkflowfromconductor.client.workflow.executor.workflow_executorimportWorkflowExecutorfromgreetings_workflowimportgreetings_workflowdefregister_workflow(workflow_executor:WorkflowExecutor)->ConductorWorkflow:workflow=greetings_workflow(workflow_executor=workflow_executor)workflow.register(True)returnworkflowdefmain():# points to http://localhost:8080/api by defaultapi_config=Configuration()workflow_executor=WorkflowExecutor(configuration=api_config)# Needs to be done only when registering a workflow one-timeworkflow=register_workflow(workflow_executor)task_handler=TaskHandler(configuration=api_config)task_handler.start_processes()workflow_run=workflow_executor.execute(name=workflow.name,version=workflow.version,workflow_input={'name':'Orkes'})print(f'\nworkflow result:{workflow_run.output["result"]}\n')print(f'see the workflow execution here:{api_config.ui_host}/execution/{workflow_run.workflow_id}\n')task_handler.stop_processes()if__name__=='__main__':main()[!NOTE]
That's it - you just created your first distributed python app!Using Conductor in your applicationThere are three main ways you will use Conductor when building durable, resilient, distributed applications.Write service workers that implements business logic to accomplish a specific goal - such as initiate payment transfer, get user information from database etc.Create Conductor workflows that implements application state - A typical workflow implements SAGA patternUse Conductor SDK and APIs to manage workflows from your application.In this guide, we will dive deeper into each of these topic.Create and Run Conductor WorkersCreate Conductor WorkflowsUsing Conductor in your Application