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
- Lenguaje dominante
- Python
- Estrellas
- 299
- Forks
- 84
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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)
```
Guía de contribución
Línea de trabajo
Empieza por la clase Workflow y lee sus puntos de entrada create(), update() y attach() para entender cómo se gestionan la existencia de la máquina de estados y los ARNs devueltos. Se considera terminado cuando un método create_or_update() actualiza una Step Function existente o crea una que falta y, después, devuelve el workflow adjunto tal como se describe; el issue no indica ningún archivo ni ruta de pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- aws, python
- Área
- cloud
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100