{"id":13704939,"url":"https://github.com/firdaus/cadence-python","last_synced_at":"2025-05-05T12:32:45.544Z","repository":{"id":34910191,"uuid":"183893184","full_name":"firdaus/cadence-python","owner":"firdaus","description":"Python framework for Cadence Workflow Service","archived":true,"fork":false,"pushed_at":"2022-07-03T17:42:42.000Z","size":533,"stargazers_count":149,"open_issues_count":16,"forks_count":24,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-29T16:08:25.682Z","etag":null,"topics":["cadence","fault-oblivious","microservices","orchestration","python","workflow"],"latest_commit_sha":null,"homepage":"https://cadenceworkflow.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firdaus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-28T10:25:19.000Z","updated_at":"2025-04-27T12:12:11.000Z","dependencies_parsed_at":"2022-07-08T07:32:37.204Z","dependency_job_id":null,"html_url":"https://github.com/firdaus/cadence-python","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firdaus%2Fcadence-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firdaus%2Fcadence-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firdaus%2Fcadence-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firdaus%2Fcadence-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firdaus","download_url":"https://codeload.github.com/firdaus/cadence-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252497696,"owners_count":21757664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cadence","fault-oblivious","microservices","orchestration","python","workflow"],"created_at":"2024-08-02T22:00:27.265Z","updated_at":"2025-05-05T12:32:45.147Z","avatar_url":"https://github.com/firdaus.png","language":"Python","funding_links":[],"categories":["Python","Cadence"],"sub_categories":[],"readme":"# Intro: Fault-Oblivious Stateful Python Code\n\ncadence-python allows you to create Python functions that have their state (local variables etc..) implicitly saved such that if the process/machine fails the state of the function is not lost and can resume from where it left off. \n\nThis programming model is useful whenever you need to ensure that a function runs to completion. For example:\n\n- Business logic involving multiple micro services\n- CI/CD pipelines\n- Data pipelines\n- RPA\n- ETL\n- Marketing automation / Customer journeys / Customer engagement\n- Zapier/IFTTT like end user automation.\n- Chat bots\n- Multi-step forms\n- Scheduler/Cron jobs\n\nBehind the scenes, cadence-python uses [Cadence](https://github.com/uber/cadence) as its backend. \n\nFor more information about the fault-oblivious programming model refer to the Cadence documentation [here](https://cadenceworkflow.io/docs/03_concepts/01_workflows)\n\n## Install Cadencce\n\n```\nwget https://raw.githubusercontent.com/uber/cadence/master/docker/docker-compose.yml\ndocker-compose up\n```\n\n## Register `sample` domain\n\n```\ndocker run --network=host --rm ubercadence/cli:master --do sample domain register -rd 1\n```\n\n## Installation cadence-python\n\n```\npip install cadence-client==1.0.1\n```\n\n## Hello World Sample\n\n```python\nimport sys\nimport logging\nfrom cadence.activity_method import activity_method\nfrom cadence.workerfactory import WorkerFactory\nfrom cadence.workflow import workflow_method, Workflow, WorkflowClient\n\nlogging.basicConfig(level=logging.DEBUG)\n\nTASK_LIST = \"HelloActivity-python-tasklist\"\nDOMAIN = \"sample\"\n\n\n# Activities Interface\nclass GreetingActivities:\n    @activity_method(task_list=TASK_LIST, schedule_to_close_timeout_seconds=2)\n    def compose_greeting(self, greeting: str, name: str) -\u003e str:\n        raise NotImplementedError\n\n\n# Activities Implementation\nclass GreetingActivitiesImpl:\n    def compose_greeting(self, greeting: str, name: str):\n        return f\"{greeting} {name}!\"\n\n\n# Workflow Interface\nclass GreetingWorkflow:\n    @workflow_method(execution_start_to_close_timeout_seconds=10, task_list=TASK_LIST)\n    async def get_greeting(self, name: str) -\u003e str:\n        raise NotImplementedError\n\n\n# Workflow Implementation\nclass GreetingWorkflowImpl(GreetingWorkflow):\n\n    def __init__(self):\n        self.greeting_activities: GreetingActivities = Workflow.new_activity_stub(GreetingActivities)\n\n    async def get_greeting(self, name):\n        # Place any Python code here that you want to ensure is executed to completion.\n        # Note: code in workflow functions must be deterministic so that the same code paths\n        # are ran during replay.\n        return await self.greeting_activities.compose_greeting(\"Hello\", name)\n\n\nif __name__ == '__main__':\n    factory = WorkerFactory(\"localhost\", 7933, DOMAIN)\n    worker = factory.new_worker(TASK_LIST)\n    worker.register_activities_implementation(GreetingActivitiesImpl(), \"GreetingActivities\")\n    worker.register_workflow_implementation_type(GreetingWorkflowImpl)\n    factory.start()\n\n    client = WorkflowClient.new_client(domain=DOMAIN)\n    greeting_workflow: GreetingWorkflow = client.new_workflow_stub(GreetingWorkflow)\n    result = greeting_workflow.get_greeting(\"Python\")\n    print(result)\n\n    print(\"Stopping workers....\")\n    worker.stop()\n    print(\"Workers stopped...\")\n    sys.exit(0)\n``` \n\n## Status / TODO\n\ncadence-python is still under going heavy development. It should be considered EXPERIMENTAL at the moment. A production\nversion is targeted to be released in ~~September of 2019~~ ~~January 2020~~ ~~March 2020~~ April 2020.\n\n1.0\n- [x] Tchannel implementation\n- [x] Python-friendly wrapper around Cadence's Thrift API\n- [x] Author activities in Python\n- [x] Start workflows (synchronously)\n- [x] Create workflows\n- [x] Workflow execution in coroutines\n- [x] Invoke activities from workflows\n- [x] ActivityCompletionClient heartbeat, complete, complete_exceptionally\n- [x] Activity heartbeat, getHeartbeatDetails and doNotCompleteOnReturn\n- [x] Activity retry\n- [x] Activity getDomain(), getTaskToken(), getWorkflowExecution()\n- [x] Signals\n- [x] Queries\n- [x] Async workflow execution\n- [x] await\n- [x] now (currentTimeMillis)\n- [x] Sleep\n- [x] Loggers\n- [x] newRandom\n- [x] UUID\n- [x] Workflow Versioning\n- [x] WorkflowClient.newWorkflowStub(Class workflowInterface, String workflowId);\n\n1.1\n- [ ] ActivityStub and Workflow.newUntypedActivityStub\n- [ ] Classes as arguments and return values to/from activity and workflow methods\n- [ ] WorkflowStub and WorkflowClient.newUntypedWorkflowStub\n- [ ] Custom workflow ids through start() and new_workflow_stub()\n- [ ] ContinueAsNew\n- [ ] Compatibility with Java client\n- [ ] Compatibility with Golang client\n\n2.0\n- [ ] Sticky workflows\n\nPost 2.0:\n- [ ] sideEffect/mutableSideEffect\n- [ ] Local activity\n- [ ] Parallel activity execution\n- [ ] Timers\n- [ ] Cancellation Scopes\n- [ ] Child Workflows\n- [ ] Explicit activity ids for activity invocations\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirdaus%2Fcadence-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirdaus%2Fcadence-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirdaus%2Fcadence-python/lists"}