Skip to content

Commit 40e9adc

Browse files
authored
add mounts to empack packed environment (#14)
* add mounts to empack packed environment * try-catch block arround empack
1 parent 9ed2ea4 commit 40e9adc

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

pyjs_code_runner/js/utils.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ async function make_pyjs(print, error) {
2525
".", /* package_tarballs_root_url */
2626
false /* verbose */
2727
);
28-
29-
await fetchMounts(pyjs);
30-
//await Promise.all([promise_env, promise_mount]);
31-
32-
//await pyjs.init()
33-
3428
globalThis.pyjs = pyjs
3529
return pyjs
3630
}

pyjs_code_runner/run.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import tempfile
66
from pathlib import Path
7-
from empack.pack import pack_env, pack_directory
7+
from empack.pack import pack_env, pack_directory,add_tarfile_to_env_meta
88
from empack.pack import DEFAULT_CONFIG_PATH as EMPACK_DEFAULT_CONFIG_PATH
99
from empack.file_patterns import pkg_file_filter_from_yaml
1010

@@ -36,6 +36,7 @@ def pack_mounts(mounts, host_work_dir, backend_type):
3636
)
3737
with open(Path(host_work_dir) / "mounts.json", "w") as f:
3838
json.dump(mount_js_files, f, indent=4)
39+
return mount_js_files
3940

4041

4142
def conda_env_to_cache_name(conda_env, backend_type):
@@ -124,14 +125,26 @@ def run(
124125
cache_dir=cache_dir,
125126
outdir=host_work_dir,
126127
compresslevel=9,
127-
)
128+
)
129+
env_meta_filename = Path(host_work_dir) / "empack_env_meta.json"
130+
131+
128132

133+
#raise RuntimeError("stop here")
129134
# pack all the mounts
130-
pack_mounts(
135+
mount_files = pack_mounts(
131136
mounts=mounts,
132137
backend_type=backend_type,
133138
host_work_dir=host_work_dir,
134139
)
140+
for mount_file in mount_files:
141+
print(f"mount_file: {mount_file}")
142+
try:
143+
add_tarfile_to_env_meta(
144+
env_meta_filename=env_meta_filename, tarfile=mount_file
145+
)
146+
except shutil.SameFileError:
147+
pass
135148

136149
# get the backend where the wasm code runs (ie node/browser-main/browser-worker)
137150
backend = get_backend_cls(backend_type=backend_type)(

0 commit comments

Comments
 (0)