From 3455a4a2c7a91ffef42725c26de92253f6fcdec3 Mon Sep 17 00:00:00 2001 From: Ben Cumming Date: Tue, 21 May 2024 08:35:10 +0200 Subject: [PATCH 1/7] replace `uenv image create` with `uenv image repo` in error message (#25) Calls to `uenv start` that fail because no uenv repository exists print an error message that suggests the user create a new repository with `uenv image create`, which was replaced with `uenv image repo`. Fix the error message to be the same as the one for calls to `uenv image *`. --- uenv-impl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uenv-impl b/uenv-impl index b0c74ac..275a7ae 100755 --- a/uenv-impl +++ b/uenv-impl @@ -636,9 +636,11 @@ def parse_image_descriptions(mnt_list, repo, uarch): try: fscache = datastore.FileSystemRepo(repo_path) except datastore.RepoNotFoundError as err: - terminal.error(f"""The local repository {repo_path} does not exist. -The repo can be created using the following command: - {colorize(f"uenv image -r {repo_path} create", "white")} + terminal.error(f"""The local repository {path} does not exist. +If this is your first time using uenv, a repo in the default location can be created with this command: + {colorize(f"uenv image repo", "white")} +If you want to create a repo in a custom location, provide the path as follows: + {colorize(f"uenv image repo {repo_path}", "white")} """, abort=False) return [] except datastore.RepoDBError as err: From b2c7d8636078995cb426e949e9fe1f3ec0935356 Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Fri, 24 May 2024 08:17:41 +0200 Subject: [PATCH 2/7] Update activate help (#27) --- activate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activate b/activate index cf03c25..9738a9c 100644 --- a/activate +++ b/activate @@ -19,7 +19,7 @@ function uenv { echo " start start a new shell with an environment loaded" echo " stop stop a shell with an environment loaded" echo " status print information about each running environment" - echo " modules view module status and activate with --use" + echo " modules view module status and activate with 'use'" echo " view activate a view" echo " image query and pull uenv images" echo "" From 1f0a8747cbdde262359bffa74a4d12d84249803d Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi <9337627+albestro@users.noreply.github.com> Date: Tue, 28 May 2024 06:32:17 +0200 Subject: [PATCH 3/7] fix typo (#28) --- uenv-impl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uenv-impl b/uenv-impl index 275a7ae..c960db4 100755 --- a/uenv-impl +++ b/uenv-impl @@ -80,7 +80,7 @@ Here the mount point for each image is specified using a ":". {colorize("Note", "cyan")} - uenv must be mounted at the mount point for which they were built. If mounted at the wrong location, a warning message will be printed, and -features like views and modules wiil be disabled. +features like views and modules will be disabled. {colorize("Example", "blue")} - the run command can be used to execute workflow steps with separate environments: @@ -122,7 +122,7 @@ Here the mount point for each image is specified using a ":". {colorize("Note", "cyan")} - uenv must be mounted at the mount point for which they were built. If mounted at the wrong location, a warning message will be printed, and -features like views and modules wiil be disabled. +features like views and modules will be disabled. """ )) start_parser.add_argument("-a", "--uarch", From a41ad6e4a3736498164e806d5c88990fda13db8e Mon Sep 17 00:00:00 2001 From: Rocco Meli Date: Wed, 29 May 2024 18:25:53 +0200 Subject: [PATCH 4/7] fix top level help message for uenv image (#29) --- uenv-impl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/uenv-impl b/uenv-impl index c960db4..cc2c4ba 100755 --- a/uenv-impl +++ b/uenv-impl @@ -202,6 +202,11 @@ the available views will be printed. default=None, help="the view to load") + #### image + # Dummy sub-parser to print out the correct help when wrong keyword is used + # This is never used since "uenv image" commands are forwarded to "uenv-image" + _ = subparsers.add_parser("image", help="Manage and query uenv images.") + return parser ############################################################################### @@ -985,6 +990,13 @@ if __name__ == "__main__": parser = make_argparser() args = parser.parse_args() + # Generate error if the dummy 'image' parser is called by accident + if args.command == "image": + raise RuntimeError( + "Something is wrong. 'image' sub-parser is a dummy parser. " + "'image' commands should be forwarded to 'uenv-image'." + ) + terminal.use_colored_output(args.no_color) if args.verbose: From a18d22606c3c7485cab44768c74ef50a14dc81b8 Mon Sep 17 00:00:00 2001 From: Ben Cumming Date: Wed, 29 May 2024 22:14:30 +0200 Subject: [PATCH 5/7] Fix/slurm compatibility (#30) Fix small incompatibilities with slurm-uenv v0.9 * handle empty `UENV_MOUNT_LIST` variable by ignoring it * user proper semantic versioning when checking the version of squashfs-mount for compatibility * bump version --- VERSION | 2 +- uenv-impl | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/VERSION b/VERSION index 1454f6e..ee74734 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.1 +4.1.0 diff --git a/uenv-impl b/uenv-impl index cc2c4ba..d3be3be 100755 --- a/uenv-impl +++ b/uenv-impl @@ -12,6 +12,7 @@ import pathlib import sys import subprocess import textwrap +from packaging.version import Version prefix = pathlib.Path(__file__).parent.resolve() libpath = prefix / 'lib' @@ -231,10 +232,7 @@ def get_uenv_version(): stdout=subprocess.PIPE, check=True) version = result.stdout.decode('utf-8') - # remove dev strings like `-dev` - version = version.split('-')[0] - digit = int(version.split('.')[1]) - return digit + return Version(version) except: return None @@ -264,12 +262,14 @@ class environment: if "UENV_MOUNT_LIST" in os.environ: # take care to strip white space and trailing commas raw = os.environ.get("UENV_MOUNT_LIST").strip().strip(',') - mounts = raw.split(',') - for m in mounts: - # remove 'file://' prefix from string. - m = strip_image_prefix(m) - img, mnt = m.split(":") - self._uenvs.append(uenv(pathlib.Path(mnt))) + # if UENV_MOUNT_LIST is set and empty, ignore it + if len(raw)>0: + mounts = raw.split(',') + for m in mounts: + # remove 'file://' prefix from string. + m = strip_image_prefix(m) + img, mnt = m.split(":") + self._uenvs.append(uenv(pathlib.Path(mnt))) # test for the original mount method elif ("UENV_MOUNT_FILE" in os.environ) and ("UENV_MOUNT_POINT" in os.environ): @@ -333,7 +333,7 @@ class environment: # true if the squashfs-mount utility is too old for this version of uenv. @property def old_api(self): - return (not self.has_squashfs_mount) or (self._uenv_version < 5) + return (not self.has_squashfs_mount) or (self._uenv_version < Version("0.5")) class uenv: """ From 333def70bfd08ff2fa4d6827c498336b7abbee20 Mon Sep 17 00:00:00 2001 From: bcumming Date: Wed, 29 May 2024 22:17:47 +0200 Subject: [PATCH 6/7] bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee74734..2c2e449 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.0 +4.1.1-dev From e1961514ae06865aa181032b888f0bf65496cab1 Mon Sep 17 00:00:00 2001 From: Ben Cumming Date: Fri, 31 May 2024 16:16:01 +0200 Subject: [PATCH 7/7] ignore PYTHONPATH; fix error message when repo not found (#32) Fix noisy crashes when invalid inputs were entered: - an infrequently triggered error when `uenv start` is run without a default repo had an incorrectly formatted error message. - fix and made consistent with the equivalent error message for `uenv image` commands. - if PYTHONPATH was set, incompatible python modules were being picked up - launch the commands with `env -u PYTHONPATH -u VIRTUAL_ENV` --- VERSION | 2 +- activate | 4 ++-- test/commands.sh | 4 ++-- uenv-image | 5 +++-- uenv-impl | 10 ++++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 2c2e449..627a3f4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.1-dev +4.1.1 diff --git a/activate b/activate index 9738a9c..44adc4f 100644 --- a/activate +++ b/activate @@ -1,8 +1,8 @@ # only run if bash or zsh [ -n "${BASH_VERSION:-}" ] || return 0 -export UENV_CMD=@@impl@@ -export UENV_IMG_CMD=@@image_impl@@ +export UENV_CMD='env -u PYTHONPATH -u VIRTUAL_ENV @@impl@@' +export UENV_IMG_CMD='env -u PYTHONPATH -u VIRTUAL_ENV @@image_impl@@' export UENV_VERSION=@@version@@ export UENV_PREFIX=@@prefix@@ diff --git a/test/commands.sh b/test/commands.sh index 8f8f25b..8744ab2 100644 --- a/test/commands.sh +++ b/test/commands.sh @@ -10,8 +10,8 @@ echo ==================== image pull uenv image pull --help echo ==================== image ls uenv image ls --help -echo ==================== image create -uenv image create --help +echo ==================== image repo +uenv image repo --help echo ==================== image deploy uenv image deploy --help echo ==================== run diff --git a/uenv-image b/uenv-image index 3acf721..96e51e1 100755 --- a/uenv-image +++ b/uenv-image @@ -364,8 +364,9 @@ def safe_repo_open(path: str) -> datastore.FileSystemRepo: terminal.error(f"""The local repository {path} does not exist. If this is your first time using uenv, a repo in the default location can be created with this command: {colorize(f"uenv image repo", "white")} -If you want to create a repo in a custom location, provide the path as follows: - {colorize(f"uenv image repo {repo_path}", "white")} +If you want to create a repo in a custom location , provide the path as follows: + {colorize("uenv image repo ", "white")} +where {colorize("", "white")} is the desired location. """) except datastore.RepoDBError as err: terminal.error(f"""The local repository {path} had a database error. diff --git a/uenv-impl b/uenv-impl index d3be3be..bbeb7cb 100755 --- a/uenv-impl +++ b/uenv-impl @@ -641,11 +641,13 @@ def parse_image_descriptions(mnt_list, repo, uarch): try: fscache = datastore.FileSystemRepo(repo_path) except datastore.RepoNotFoundError as err: - terminal.error(f"""The local repository {path} does not exist. -If this is your first time using uenv, a repo in the default location can be created with this command: + terminal.error(f"""The local repository {repo_path} does not exist. +If this is your first time using uenv, a repo in the default location can be +created with this command: {colorize(f"uenv image repo", "white")} -If you want to create a repo in a custom location, provide the path as follows: - {colorize(f"uenv image repo {repo_path}", "white")} +If you want to create a repo in a custom location , provide the path as follows: + {colorize("uenv image repo ", "white")} +where {colorize("", "white")} is the desired location. """, abort=False) return [] except datastore.RepoDBError as err: