From 6e6709d9ff999c8c973fabd2c8df484975083d8b Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 01:16:22 -0400 Subject: First pass at implementing dedicated default mission environment(s) --- mission/hst/base.yml | 32 ++++++++++++++++++++++++++++++++ src/stasis_main.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 mission/hst/base.yml diff --git a/mission/hst/base.yml b/mission/hst/base.yml new file mode 100644 index 0000000..30b20c1 --- /dev/null +++ b/mission/hst/base.yml @@ -0,0 +1,32 @@ +channels: + - conda-forge +dependencies: + - fitsverify + - hstcal + - pip + - python + - setuptools + - pip: + - acstools + - calcos + - costools + - crds + - drizzlepac + - fitsblender + - gwcs + - hasp + - nictools + - spherical_geometry + - stistools + - stregion + - stsci.image + - stsci.imagestats + - stsci.skypac + - stsci.stimage + - stsci.tools + - stwcs + - tweakwcs + - ullyses + - ullyses-utils + - wfc3tools + - wfpc2tools diff --git a/src/stasis_main.c b/src/stasis_main.c index 737fafc..75d3ed0 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -495,7 +495,53 @@ int main(int argc, char *argv[]) { pathvar = NULL; } + + // + // Implied environment creation modes/actions + // + // 1. No base environment config + // 1a. Caller is warned + // 1b. Caller has full control over all packages + // 2. Default base environment (etc/stasis/mission/[name]/base.yml) + // 2a. Depends on packages defined by base.yml + // 2b. Caller may issue a reduced package set in the INI config + // 2c. Caller must be vigilant to avoid incompatible packages (base.yml + // *should* have no version constraints) + // 3. External base environment (based_on=schema://[release_name].yml) + // 3a. Depends on a previous release or arbitrary yaml configuration + // 3b. Bugs, conflicts, and dependency resolution issues are inherited and + // must be handled in the INI config msg(STASIS_MSG_L1, "Creating release environment(s)\n"); + + char *mission_base = NULL; + if (isempty(ctx.meta.based_on)) { + guard_free(ctx.meta.based_on); + char *mission_base_orig = NULL; + + if (asprintf(&mission_base_orig, "%s/%s/base.yml", ctx.storage.mission_dir, ctx.meta.mission) < 0) { + SYSERROR("Unable to allocate bytes for %s/%s/base.yml path\n", ctx.storage.mission_dir, ctx.meta.mission); + exit(1); + } + + if (access(mission_base_orig, F_OK) < 0) { + msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Mission does not provide a base.yml configuration: %s (%s)\n", + ctx.meta.mission, ctx.storage.mission_dir); + } else { + msg(STASIS_MSG_L2, "Using base environment configuration: %s\n", mission_base_orig); + if (asprintf(&mission_base, "%s/%s-base.yml", ctx.storage.tmpdir, ctx.info.release_name) < 0) { + SYSERROR("%s", "Unable to allocate bytes for temporary base.yml configuration"); + remove(mission_base); + exit(1); + } + copy2(mission_base_orig, mission_base, CT_OWNER | CT_PERM); + char spec[255] = {0}; + snprintf(spec, sizeof(spec) - 1, "- python=%s\n", ctx.meta.python); + file_replace_text(mission_base, "- python\n", spec, 0); + ctx.meta.based_on = mission_base; + } + guard_free(mission_base_orig); + } + if (!isempty(ctx.meta.based_on)) { if (conda_env_remove(env_name)) { msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove release environment: %s\n", env_name); @@ -526,6 +572,8 @@ int main(int argc, char *argv[]) { exit(1); } } + remove(mission_base); + guard_free(mission_base); // Activate test environment msg(STASIS_MSG_L1, "Activating test environment\n"); -- cgit From 55f7ea5a3c0895560f90ff5ef0a2f7081bbecb97 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:11:18 -0400 Subject: Add skeleton base mission environments: * generic * jwst * roman --- mission/generic/base.yml | 2 ++ mission/hst/base.yml | 2 +- mission/jwst/base.yml | 6 ++++++ mission/roman/base.yml | 9 +++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 mission/generic/base.yml create mode 100644 mission/jwst/base.yml create mode 100644 mission/roman/base.yml diff --git a/mission/generic/base.yml b/mission/generic/base.yml new file mode 100644 index 0000000..651b839 --- /dev/null +++ b/mission/generic/base.yml @@ -0,0 +1,2 @@ +channels: + - conda-forge \ No newline at end of file diff --git a/mission/hst/base.yml b/mission/hst/base.yml index 30b20c1..af115cf 100644 --- a/mission/hst/base.yml +++ b/mission/hst/base.yml @@ -29,4 +29,4 @@ dependencies: - ullyses - ullyses-utils - wfc3tools - - wfpc2tools + - wfpc2tools \ No newline at end of file diff --git a/mission/jwst/base.yml b/mission/jwst/base.yml new file mode 100644 index 0000000..e72633c --- /dev/null +++ b/mission/jwst/base.yml @@ -0,0 +1,6 @@ +channels: + - conda-forge +dependencies: + - pip + - python + - setuptools \ No newline at end of file diff --git a/mission/roman/base.yml b/mission/roman/base.yml new file mode 100644 index 0000000..a1d49a0 --- /dev/null +++ b/mission/roman/base.yml @@ -0,0 +1,9 @@ +channels: + - conda-forge +dependencies: + - pip + - python + - setuptools + - pip: + - romancal + - stcal \ No newline at end of file -- cgit From 770aba76dd0780e53dc3ce972de6712361a29ca3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:46:09 -0400 Subject: More like GENERIC python environment * I need to figure out a good way to offer a mode that doesn't require python to be installed in the resulting environment --- mission/generic/base.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mission/generic/base.yml b/mission/generic/base.yml index 651b839..e72633c 100644 --- a/mission/generic/base.yml +++ b/mission/generic/base.yml @@ -1,2 +1,6 @@ channels: - - conda-forge \ No newline at end of file + - conda-forge +dependencies: + - pip + - python + - setuptools \ No newline at end of file -- cgit From 74ce6e826895500cb07bd3d82096bfbd8e431f49 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:48:59 -0400 Subject: Fixes bug found in delivery_overlay_packages_from_env(): * When "pip freeze" does not emit any packages we now avoid replacing the context's pip package list with an empty one. --- src/delivery_install.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/delivery_install.c b/src/delivery_install.c index a7754e8..76c3f4a 100644 --- a/src/delivery_install.c +++ b/src/delivery_install.c @@ -99,8 +99,12 @@ int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_nam } } } - guard_strlist_free(&ctx->conda.pip_packages); - ctx->conda.pip_packages = strlist_copy(new_list); + + // Replace the package manifest as needed + if (strlist_count(new_list)) { + guard_strlist_free(&ctx->conda.pip_packages); + ctx->conda.pip_packages = strlist_copy(new_list); + } guard_strlist_free(&new_list); guard_strlist_free(&frozen_list); return 0; -- cgit From faae3baaba4b656f71e0a37eda82a46e3259a48c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:49:31 -0400 Subject: Not every base environment is a release --- src/stasis_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stasis_main.c b/src/stasis_main.c index 75d3ed0..4354ae3 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -548,7 +548,7 @@ int main(int argc, char *argv[]) { exit(1); } - msg(STASIS_MSG_L2, "Based on release: %s\n", ctx.meta.based_on); + msg(STASIS_MSG_L2, "Based on: %s\n", ctx.meta.based_on); if (conda_env_create_from_uri(env_name, ctx.meta.based_on)) { msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "unable to install release environment using configuration file\n"); exit(1); -- cgit From d1ac3e48064c79d7949ac52f3d6204a3116fa172 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:50:45 -0400 Subject: Do not free mission_base after installation * Because ctx.meta.based_on is replaced by a pointer to mission_base --- src/stasis_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stasis_main.c b/src/stasis_main.c index 4354ae3..2d4c049 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -573,7 +573,6 @@ int main(int argc, char *argv[]) { } } remove(mission_base); - guard_free(mission_base); // Activate test environment msg(STASIS_MSG_L1, "Activating test environment\n"); -- cgit From 49e2e250103b89f5461a591334e4133f3ba8c365 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 8 Oct 2024 09:51:14 -0400 Subject: Note purpose behind removing the temporary environment file --- src/stasis_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stasis_main.c b/src/stasis_main.c index 2d4c049..eecc419 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -572,6 +572,7 @@ int main(int argc, char *argv[]) { exit(1); } } + // The base environment configuration not used past this point remove(mission_base); // Activate test environment -- cgit