aws / aws/aws-step-functions-data-science-sdk-python
Feature Request: Add Workflow.create_or_update() to update workflow if it exists or create it if it doesn't
- 主要言語
- Python
- スター
- 299
- フォーク
- 84
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
When running notebooks in an automated fashion many times the StepFunction created by the workflow.create() method already exists. The same for when running the workflow.update() method when defining the Workflow for the first time.
We could extend the Workflow class with a create_or_update method that would check if the stepfunction exists, if it does, attach to that otherwise, update it.
```python
# Grab account/region from Boto/Sagemaker Session
class CustomWorkflow(Workflow):
def __init__(self, name, definition, role, update_sleep_seconds=8, **kwargs):
super(CustomWorkflow, self).__init__(name, definition, role, **kwargs)
self.update_sleep_seconds = update_sleep_seconds
self.expected_arn = f"arn:aws:states:{region}:{account_id}:stateMachine:{self.name}"
def create_or_update(self):
try:
target_wf = Workflow.attach(self.expected_arn)
print('State Machine Exists. Attaching and updating')
target_wf.update(definition=self.definition, role=self.role)
# Sleep to allow infrastructure to update before executing a new job
time.sleep(self.update_sleep_seconds)
except boto3.client('stepfunctions').exceptions.StateMachineDoesNotExist:
print('State Machine Not found, creating')
self.expected_arn = self.create()
return Workflow.attach(self.expected_arn)
```
コントリビューションガイド
調査の方向性
Workflow クラスから始め、create()、update()、attach() のエントリーポイントを読んで、ステートマシンの存在と返される ARN がどのように扱われるかを理解します。create_or_update() メソッドが既存の Step Function を更新するか、存在しないものを作成し、その後、説明されているとおりにアタッチされた workflow を返せば完了です。issue ではファイルやテストパスは指定されていません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- aws, python
- 領域
- cloud
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100