-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing common utils and functions
- Loading branch information
Showing
9 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
tests/fixtures | ||
__pycache__ | ||
samconfig.toml | ||
packaged.yaml |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import boto3 | ||
|
||
from common.json_utils import clean_json | ||
|
||
sagemaker_client = boto3.client('sagemaker') | ||
|
||
def lambda_handler(event, context): | ||
training_name = event['training_info']['TrainingJobName'] | ||
training_info = sagemaker_client.describe_training_job(TrainingJobName=training_name) | ||
event['training_info'] = clean_json(training_info) | ||
return event |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import json | ||
from datetime import datetime, date | ||
|
||
def json_serial(obj): | ||
'''JSON serializer for objects not serializable by default json code''' | ||
if isinstance(obj, (datetime, date)): | ||
return obj.isoformat() | ||
raise TypeError(f'Type {type(obj)} not serializable') | ||
|
||
def clean_json(obj): | ||
''' Cleans a json object from datettimes. ''' | ||
return json.loads(json.dumps(obj, default=json_serial)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters