Skip to content

Commit 3921ed3

Browse files
PaliCpytorchmergebot
authored andcommitted
Use multipy.package in multipy/runtime (#111) (pytorch#82690)
Summary: This change points multipy::runtime to use multipy.package instead of torch.package by copying `_deploy.py` (which is used in order to pass objects in and out of interpreters) into multipy as well as making the neccessary changes to allow `multipy::runtime` to access `multipy.package` and `_deploy.py`. X-link: pytorch/multipy#111 Reviewed By: d4l3k Differential Revision: D38337551 Pulled By: PaliC Pull Request resolved: pytorch#82690 Approved by: https://github.com/d4l3k
1 parent 14b660f commit 3921ed3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

torch/utils/_zip.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def remove_prefix(text, prefix):
3030
return text[len(prefix):]
3131
return text
3232

33-
def write_to_zip(file_path, strip_file_path, zf):
34-
stripped_file_path = remove_prefix(file_path, strip_file_dir + "/")
33+
def write_to_zip(file_path, strip_file_path, zf, prepend_str=""):
34+
stripped_file_path = prepend_str + remove_prefix(file_path, strip_file_dir + "/")
3535
path = Path(stripped_file_path)
3636
if path.name in DENY_LIST:
3737
return
@@ -42,18 +42,21 @@ def write_to_zip(file_path, strip_file_path, zf):
4242
parser.add_argument("paths", nargs="*", help="Paths to zip.")
4343
parser.add_argument("--install_dir", help="Root directory for all output files")
4444
parser.add_argument("--strip_dir", help="The absolute directory we want to remove from zip")
45+
parser.add_argument("--prepend_str", help="A string to prepend onto all paths of a file in the zip", default="")
4546
parser.add_argument("--zip_name", help="Output zip name")
47+
4648
args = parser.parse_args()
4749

4850
zip_file_name = args.install_dir + '/' + args.zip_name
4951
strip_file_dir = args.strip_dir
52+
prepend_str = args.prepend_str
5053
zf = ZipFile(zip_file_name, mode='w')
5154

5255
for p in args.paths:
5356
if os.path.isdir(p):
5457
files = glob.glob(p + "/**/*.py", recursive=True)
5558
for file_path in files:
5659
# strip the absolute path
57-
write_to_zip(file_path, strip_file_dir + "/", zf)
60+
write_to_zip(file_path, strip_file_dir + "/", zf, prepend_str=prepend_str)
5861
else:
59-
write_to_zip(p, strip_file_dir + "/", zf)
62+
write_to_zip(p, strip_file_dir + "/", zf, prepend_str=prepend_str)

0 commit comments

Comments
 (0)