-
Notifications
You must be signed in to change notification settings - Fork 177
Provide metadata to easily protect environments #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
d315f8b
ae8fd52
f256750
0c0646b
a3a3442
52df9a4
7023b01
952f910
a1c85a8
cb50798
7bea797
35cedb8
527a2b0
c61bebf
32b3430
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,7 +56,7 @@ | |||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def write_index_cache(info, dst_dir, used_packages): | ||||||
| def write_index_cache(info: dict, dst_dir: str, used_packages): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure myself, which is why I left it hoping someone else would. 😅 |
||||||
| cache_dir = join(dst_dir, "cache") | ||||||
|
|
||||||
| if not isdir(cache_dir): | ||||||
|
|
@@ -147,6 +147,7 @@ def write_files(info: dict, workspace: str): | |||||
|
|
||||||
| - `conda-meta/initial-state.explicit.txt`: Lockfile to provision the base environment. | ||||||
| - `conda-meta/history`: Prepared history file with the right requested specs in input file. | ||||||
| - `conda-meta/frozen`: Frozen marker file used to protect conda environment state. | ||||||
| - `pkgs/urls` and `pkgs/urls.txt`: Direct URLs of packages used, with and without MD5 hashes. | ||||||
| - `pkgs/cache/*.json`: Trimmed repodata to mock offline channels in use. | ||||||
| - `pkgs/channels.txt`: Channels in use. | ||||||
|
|
@@ -199,6 +200,9 @@ def write_files(info: dict, workspace: str): | |||||
| # (list of specs/dists to install) | ||||||
| write_initial_state_explicit_txt(info, join(workspace, "conda-meta"), final_urls_md5s) | ||||||
|
|
||||||
| # base environment frozen marker files | ||||||
| write_frozen(info.get("freeze_base"), join(workspace, "conda-meta")) | ||||||
|
|
||||||
| for fn in files: | ||||||
| os.chmod(join(workspace, fn), 0o664) | ||||||
|
|
||||||
|
|
@@ -218,9 +222,11 @@ def write_files(info: dict, workspace: str): | |||||
| write_channels_txt(info, env_pkgs, env_config) | ||||||
| # shortcuts | ||||||
| write_shortcuts_txt(info, env_pkgs, env_config) | ||||||
| # frozen marker file | ||||||
| write_frozen(env_config.get("freeze_env"), env_conda_meta) | ||||||
|
|
||||||
|
|
||||||
| def write_conda_meta(info, dst_dir, final_urls_md5s, user_requested_specs=None): | ||||||
| def write_conda_meta(info: dict, dst_dir: str, final_urls_md5s: tuple, user_requested_specs=None): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if user_requested_specs is None: | ||||||
| user_requested_specs = info.get("user_requested_specs", info.get("specs", ())) | ||||||
|
|
||||||
|
|
@@ -244,7 +250,15 @@ def write_conda_meta(info, dst_dir, final_urls_md5s, user_requested_specs=None): | |||||
| fh.write("\n".join(builder)) | ||||||
|
|
||||||
|
|
||||||
| def write_repodata_record(info, dst_dir): | ||||||
| def write_frozen(freeze_info: dict | None, dst_dir: str): | ||||||
| if not freeze_info or "conda" not in freeze_info: | ||||||
| return | ||||||
| frozen_path = join(dst_dir, "frozen") | ||||||
| with open(frozen_path, "w") as ff: | ||||||
| json.dump(freeze_info["conda"], ff) | ||||||
|
|
||||||
|
|
||||||
| def write_repodata_record(info: dict, dst_dir: str): | ||||||
| all_dists = info["_dists"].copy() | ||||||
| for env_data in info.get("_extra_envs_info", {}).values(): | ||||||
| all_dists += env_data["_dists"] | ||||||
|
|
@@ -271,7 +285,7 @@ def write_repodata_record(info, dst_dir): | |||||
| json.dump(rr_json, rf, indent=2, sort_keys=True) | ||||||
|
|
||||||
|
|
||||||
| def write_initial_state_explicit_txt(info, dst_dir, urls): | ||||||
| def write_initial_state_explicit_txt(info: dict, dst_dir: str, urls: tuple): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just like with the md5 example above, you may want to add the types of the elements in the tuple |
||||||
| """ | ||||||
| urls is an iterable of tuples with url and md5 values | ||||||
| """ | ||||||
|
|
@@ -293,7 +307,7 @@ def write_initial_state_explicit_txt(info, dst_dir, urls): | |||||
| envf.write(f"{url}#{md5}\n") | ||||||
|
|
||||||
|
|
||||||
| def write_channels_txt(info, dst_dir, env_config): | ||||||
| def write_channels_txt(info: dict, dst_dir: str, env_config: dict): | ||||||
| env_config = env_config.copy() | ||||||
| if "channels" not in env_config: | ||||||
| env_config["channels"] = info.get("channels", ()) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.