Skip to content

Instantly share code, notes, and snippets.

@philschmid
Created June 23, 2021 12:34
Show Gist options
  • Select an option

  • Save philschmid/a93ed3eb9c63086f19a13064c406164c to your computer and use it in GitHub Desktop.

Select an option

Save philschmid/a93ed3eb9c63086f19a13064c406164c to your computer and use it in GitHub Desktop.
Archive model for Amazon SageMaker
import tarfile
import os
root = "./endpoint"
def main():
cwd = os.getcwd()
os.chdir(root)
files = [os.path.join(path, name) for path, _, files in os.walk(".") for name in files]
with tarfile.open(os.path.join(cwd, "model.tar.gz"), "w:gz") as tar:
for file in files:
tar.add(file)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment