Skip to content

fix: construct correct code path and correctly tar up contents #84

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 10 commits into from
Sep 2, 2020
Merged

fix: construct correct code path and correctly tar up contents #84

merged 10 commits into from
Sep 2, 2020

Conversation

dk19y
Copy link
Contributor

@dk19y dk19y commented Sep 2, 2020

Fix PyTorch SDK Failure for DLC Containers

Incorrect use of paths results in SDK tests failing link

This PR

  • Fixes the issue
  • Updates framework version in buildspec
  • Updates test Docker to use DLC images directly.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 8e6d29d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 8e6d29d
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: bb0acc5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: bb0acc5
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: c050581
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: c050581
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 5378d68
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 5378d68
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 358b4cc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 358b4cc
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 77faf02
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 77faf02
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 3e03702
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 3e03702
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 67f9a23
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 67f9a23
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 7cd8cbb
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 7cd8cbb
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-container-pr
  • Commit ID: 508a8a2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 508a8a2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link

@metrizable metrizable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the submission. i included a few suggestions.

@@ -121,7 +122,7 @@ def _adapt_to_ts_format(handler_service):
"--export-path",
DEFAULT_TS_MODEL_DIRECTORY,
"--extra-files",
os.path.join(environment.model_dir, environment.Environment().module_name + ".py"),
os.path.join(environment.model_dir, DEFAULT_TS_CODE_DIR, environment.Environment().module_name + ".py"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use string interpolation here:

Suggested change
os.path.join(environment.model_dir, DEFAULT_TS_CODE_DIR, environment.Environment().module_name + ".py"),
os.path.join(environment.model_dir, DEFAULT_TS_CODE_DIR, "{}.py".format(environment.Environment().module_name)),

@@ -23,36 +23,41 @@
cpu_sub_dir = 'model_cpu'
gpu_sub_dir = 'model_gpu'
eia_sub_dir = 'model_eia'
code_sub_dir = 'code'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply black formatter and favor double-quotes here and throughout


model_cpu_dir = os.path.join(mnist_path, cpu_sub_dir)
mnist_cpu_script = os.path.join(model_cpu_dir, 'mnist.py')
mnist_cpu_script = os.path.join(model_cpu_dir, code_sub_dir, 'mnist.py')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standardize the quotes used.

Suggested change
mnist_cpu_script = os.path.join(model_cpu_dir, code_sub_dir, 'mnist.py')
mnist_cpu_script = os.path.join(model_cpu_dir, code_sub_dir, "mnist.py")

applying black formatter will standardize code and increase readability. we'll introduce black to this package to auto-format, increase code quality, and eliminate these nits

os.path.join(environment.model_dir, environment.Environment().module_name + ".py"),
os.path.join(environment.model_dir,
torchserve.DEFAULT_TS_CODE_DIR,
environment.Environment().module_name + ".py"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
environment.Environment().module_name + ".py"),
"{}.py".format(environment.Environment().module_name)),

@@ -16,9 +16,12 @@
import tarfile


def make_tarfile(script, model, output_path, filename="model.tar.gz"):
def make_tarfile(script, model, output_path, filename="model.tar.gz", script_path=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default to empty string and then later you can simplify code (plus it matches the type expected):

Suggested change
def make_tarfile(script, model, output_path, filename="model.tar.gz", script_path=None):
def make_tarfile(script, model, output_path, filename="model.tar.gz", script_path=""):

Comment on lines +22 to +25
if(script_path):
tar.add(script, arcname=os.path.join(script_path, os.path.basename(script)))
else:
tar.add(script, arcname=os.path.basename(script))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming script_path is defaulted to empty string:

Suggested change
if(script_path):
tar.add(script, arcname=os.path.join(script_path, os.path.basename(script)))
else:
tar.add(script, arcname=os.path.basename(script))
tar.add(script, arcname=os.path.join(script_path, os.path.basename(script)))

this is because os.path.join with empty string arg has no effect on the resulting path:

>>> os.path.join("", "/tmp/foo")
'/tmp/foo'
>>> os.path.join("", "/tmp", "foo")
'/tmp/foo'
>>> os.path.join("", "tmp", "foo")
'tmp/foo'

Copy link

@metrizable metrizable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-follow on suggestions

@metrizable metrizable merged commit 9a6869e into aws:master Sep 2, 2020
@metrizable metrizable changed the title Fix PyTorch SDK Failure for DLC Containers fix: construct correct code path and correctly tar up contents Sep 2, 2020
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-pytorch-inference-toolkit-pr
  • Commit ID: 508a8a2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants