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

Aperta
#168 1 commento 2 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
299
Fork
84
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Parti dalla classe Workflow e leggi i suoi punti di ingresso create(), update() e attach() per capire come vengono gestiti l’esistenza della macchina a stati e gli ARN restituiti. Il lavoro è completo quando un metodo create_or_update() aggiorna una Step Function esistente oppure ne crea una mancante, quindi restituisce il workflow collegato come descritto; l’issue non indica alcun file o percorso di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, python
Ambito
cloud
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.