aws / aws/aws-step-functions-data-science-sdk-python

Execution list_events html output fails with boolean properties for inputDetails.

Aperta
#93 4 commenti 1 reazione 0 assegnatari Vedi su GitHub
bug
Lingua principale
Python
Stelle
299
Fork
84
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

When an event includes boolean properties the `execution.list_events(html=True)` method fails with error:

```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 execution.list_events(html=True) # Bug

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/stepfunctions.py in list_events(self, max_items, reverse_order, html)
487
488 if html:
--> 489 return HTML(events_list.to_html())
490 else:
491 return events_list

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/stepfunctions.py in to_html(self)
45
46 def to_html(self):
---> 47 return EventsTableWidget(self).show()
48
49

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in __init__(self, events)
141 timestamp=format_time(event.get("timestamp")),
142 event_detail=self._format_event_detail(event)
--> 143 ) for event in events]
144
145 self.template = Template(TABLE_TEMPLATE.format(table_rows='\n'.join(table_rows)))

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in (.0)
141 timestamp=format_time(event.get("timestamp")),
142 event_detail=self._format_event_detail(event)
--> 143 ) for event in events]
144
145 self.template = Template(TABLE_TEMPLATE.format(table_rows='\n'.join(table_rows)))

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in _format_event_detail(self, event)
307 def _format_event_detail(self, event):
308 event_details = self._get_step_detail(event)
--> 309 self._unpack_to_proper_dict(event_details)
310 return json.dumps(event_details, indent=4)
311

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in _unpack_to_proper_dict(self, dictionary)
313 for k, v in dictionary.items():
314 if isinstance(v, dict):
--> 315 self._unpack_to_proper_dict(v)
316 else:
317 dictionary[k] = self._load_json(v)

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in _unpack_to_proper_dict(self, dictionary)
315 self._unpack_to_proper_dict(v)
316 else:
--> 317 dictionary[k] = self._load_json(v)
318
319 def _load_json(self, value):

~/anaconda3/envs/python3/lib/python3.6/site-packages/stepfunctions/workflow/widgets/events_table.py in _load_json(self, value)
319 def _load_json(self, value):
320 try:
--> 321 return json.loads(value)
322 except ValueError as e:
323 return value

~/anaconda3/envs/python3/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 if not isinstance(s, (bytes, bytearray)):
347 raise TypeError('the JSON object must be str, bytes or bytearray, '
--> 348 'not {!r}'.format(s.__class__.__name__))
349 s = s.decode(detect_encoding(s), 'surrogatepass')
350

TypeError: the JSON object must be str, bytes or bytearray, not 'bool'
```

This is due to the `{'truncated': False}` value in the following event:

```
{'timestamp': datetime.datetime(2020, 10, 6, 2, 41, 57, 614000, tzinfo=tzlocal()),
'type': 'ExecutionStarted',
'id': 1,
'previousEventId': 0,
'executionStartedEventDetails': {'input': '{\n "ExperimentName": "mlops-nyctaxi",\n "TrialName": "mlops-nyctaxi-7f99979c077d11ebbed6ad48a7dcc771",\n "GitBranch": "master",\n "GitCommitHash": "xxx",\n "DataVersionId": "yyy",\n "BaselineJobName": "mlops-nyctaxi-7f99979c077d11ebbed6ad48a7dcc771",\n "BaselineOutputUri": "s3://sagemaker-us-east-1-691313291965/nyctaxi/monitoring/baseline/mlops-nyctaxi-pbl-7f99979c077d11ebbed6ad48a7dcc771",\n "TrainingJobName": "mlops-nyctaxi-7f99979c077d11ebbed6ad48a7dcc771"\n}',
'inputDetails': {'truncated': False},
'roleArn': 'arn:aws:iam::691313291965:role/mlops-nyctaxi-sfn-execution-role'}}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in stepfunctions/workflow/widgets/events_table.py, in particolare in _unpack_to_proper_dict e _load_json, quindi riproduci il problema con execution.list_events(html=True) usando un evento il cui inputDetails contiene truncated: False. Il lavoro è completato quando l’output HTML dell’evento viene visualizzato senza un TypeError, preservando le proprietà booleane.

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

Valutazione

Stack tecnologico
aws, python
Ambito
backend
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.