aws / aws/aws-step-functions-data-science-sdk-python
Execution list_events html output fails with boolean properties for inputDetails.
- 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 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'}}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu trong stepfunctions/workflow/widgets/events_table.py, đặc biệt là _unpack_to_proper_dict và _load_json, sau đó tái hiện lỗi bằng execution.list_events(html=True) với một event có inputDetails chứa truncated: False. Được xem là hoàn thành khi đầu ra HTML của event được render mà không có TypeError, đồng thời giữ nguyên các thuộc tính boolean.
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
- backend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100