-
Notifications
You must be signed in to change notification settings - Fork 72
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
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this 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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use string interpolation here:
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' |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standardize the quotes used.
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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): |
There was a problem hiding this comment.
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):
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=""): |
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)) |
There was a problem hiding this comment.
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:
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'
There was a problem hiding this 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
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Fix PyTorch SDK Failure for DLC Containers
Incorrect use of paths results in SDK tests failing link
This PR
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.