Skip to content

Added: print out billable seconds after training completes #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sagemaker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ def logs_for_job(self, job_name, wait=False, poll=5): # noqa: C901 - suppress c
if dot:
print()
print('===== Job Complete =====')
# Customers are not billed for hardware provisioning, so billable time is less than total time
billable_time = (description['TrainingEndTime'] - description['TrainingStartTime']) * instance_count
print('Billable seconds:', int(billable_time.total_seconds()) + 1)


def container_def(image, model_data_url=None, env=None):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from mock import Mock, patch, call
import sagemaker
from sagemaker import s3_input, Session, get_execution_role
import datetime

from botocore.exceptions import ClientError

Expand Down Expand Up @@ -177,6 +178,11 @@ def test_s3_input_all_arguments():
{'ModelArtifacts': {
'S3ModelArtifacts': S3_OUTPUT + '/model/model.tar.gz'
}})
# TrainingStartTime and TrainingEndTime are for billable seconds calculation
COMPLETED_DESCRIBE_JOB_RESULT.update(
{'TrainingStartTime': datetime.datetime(2018, 2, 17, 7, 15, 0, 103000)})
COMPLETED_DESCRIBE_JOB_RESULT.update(
{'TrainingEndTime': datetime.datetime(2018, 2, 17, 7, 19, 34, 953000)})
IN_PROGRESS_DESCRIBE_JOB_RESULT = dict(DEFAULT_EXPECTED_TRAIN_JOB_ARGS)
IN_PROGRESS_DESCRIBE_JOB_RESULT.update({'TrainingJobStatus': 'InProgress'})

Expand Down