Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
bcumming committed Jun 5, 2024
2 parents d93504d + e196151 commit 4f04d8f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
6 changes: 3 additions & 3 deletions activate
Original file line number Diff line number Diff line change
@@ -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@@
export UENV_WRAPPER_CMD=@@wrapper@@
Expand All @@ -20,7 +20,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 ""
Expand Down
4 changes: 2 additions & 2 deletions test/commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions uenv-image
Original file line number Diff line number Diff line change
Expand Up @@ -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 <repo_path>", "white")}
where {colorize("<repo_path>", "white")} is the desired location.
""")
except datastore.RepoDBError as err:
terminal.error(f"""The local repository {path} had a database error.
Expand Down
27 changes: 21 additions & 6 deletions uenv-impl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,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:
Expand Down Expand Up @@ -145,7 +145,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",
Expand Down Expand Up @@ -238,6 +238,11 @@ set without loading the view:
help="Output the environment variable changes as json.",
action="store_true")

#### 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

###############################################################################
Expand All @@ -262,7 +267,6 @@ def get_uenv_version():
stdout=subprocess.PIPE,
check=True)
version = result.stdout.decode('utf-8')
# remove dev strings like `-dev`
return Version(version)
except:
return None
Expand Down Expand Up @@ -293,7 +297,7 @@ 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(',')
# handle the case of UENV_MOUNT_LIST being set but empty
# if UENV_MOUNT_LIST is set and empty, ignore it
if len(raw)>0:
mounts = raw.split(',')
for m in mounts:
Expand Down Expand Up @@ -673,8 +677,12 @@ def parse_image_descriptions(mnt_list, repo, uarch):
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")}
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("uenv image repo <repo_path>", "white")}
where {colorize("<repo_path>", "white")} is the desired location.
""", abort=False)
return []
except datastore.RepoDBError as err:
Expand Down Expand Up @@ -1047,6 +1055,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:
Expand Down

0 comments on commit 4f04d8f

Please sign in to comment.