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
- Ngôn ngữ chính
- Python
- Star
- 299
- Fork
- 84
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ lớp Workflow và đọc các entry point create(), update() và attach() của lớp này để hiểu cách xử lý việc tồn tại của state machine và các ARN được trả về. Công việc được xem là hoàn tất khi một phương thức create_or_update() cập nhật một Step Function hiện có hoặc tạo một Step Function còn thiếu, sau đó trả về workflow đã được gắn như mô tả; issue không nêu file hoặc đường dẫn test nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, python
- Lĩnh vực
- cloud
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100