diff --git a/conda-store-server/conda_store_server/app.py b/conda-store-server/conda_store_server/app.py index d7626baba..9e13676b9 100644 --- a/conda-store-server/conda_store_server/app.py +++ b/conda-store-server/conda_store_server/app.py @@ -244,6 +244,7 @@ def create_build(self, specification_sha256): ( tasks.task_update_storage_metrics.si() | tasks.task_build_conda_environment.si(build.id) + | tasks.task_build_conda_env_export.si(build.id) | tasks.task_build_conda_pack.si(build.id) | tasks.task_build_conda_docker.si(build.id) | tasks.task_update_storage_metrics.si() diff --git a/conda-store-server/conda_store_server/build.py b/conda-store-server/conda_store_server/build.py index dd30490f1..b9bffa344 100644 --- a/conda-store-server/conda_store_server/build.py +++ b/conda-store-server/conda_store_server/build.py @@ -151,6 +151,26 @@ def build_conda_environment(conda_store, build): set_build_failed(conda_store, build, traceback.format_exc().encode("utf-8")) +def build_conda_env_export(conda_store, build): + conda_prefix = build.build_path(conda_store.store_directory) + + output = subprocess.check_output( + [conda_store.conda_command, "env", "export", "-p", conda_prefix] + ) + + parsed = yaml.safe_load(output) + if "dependencies" not in parsed: + raise ValueError(f"conda env export` did not produce valid YAML:\n{output}") + + conda_store.storage.set( + conda_store.db, + build.id, + build.conda_env_export_key, + output, + content_type="text/yaml", + ) + + def build_conda_pack(conda_store, build): conda_prefix = build.build_path(conda_store.store_directory) diff --git a/conda-store-server/conda_store_server/orm.py b/conda-store-server/conda_store_server/orm.py index 959e46db4..50e57cddf 100644 --- a/conda-store-server/conda_store_server/orm.py +++ b/conda-store-server/conda_store_server/orm.py @@ -112,6 +112,10 @@ def build_key(self): def log_key(self): return f"logs/{self.build_key}.log" + @property + def conda_env_export_key(self): + return f"yaml/{self.build_key}.yml" + @property def conda_pack_key(self): return f"archive/{self.build_key}.tar.gz" diff --git a/conda-store-server/conda_store_server/server/templates/build.html b/conda-store-server/conda_store_server/server/templates/build.html index f66803ea2..41097148f 100644 --- a/conda-store-server/conda_store_server/server/templates/build.html +++ b/conda-store-server/conda_store_server/server/templates/build.html @@ -65,6 +65,7 @@