Created
June 23, 2021 12:34
-
-
Save philschmid/a93ed3eb9c63086f19a13064c406164c to your computer and use it in GitHub Desktop.
Archive model for Amazon SageMaker
This file contains hidden or 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
| 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