-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from kamangir/conda-refactors-2025-01-10-Q7AoMc
conda refactors
- Loading branch information
Showing
9 changed files
with
139 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /usr/bin/env bash | ||
|
||
function abcli_conda_exists() { | ||
local options=$1 | ||
local environment_name=$(abcli_option "$options" name abcli) | ||
|
||
if conda info --envs | grep -q "^$environment_name "; then | ||
echo 1 | ||
else | ||
echo 0 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /usr/bin/env bash | ||
|
||
function abcli_conda_list() { | ||
abcli_eval ,$1 \ | ||
conda info \ | ||
--envs "${@:2}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/env bash | ||
|
||
function abcli_conda_rm() { | ||
local options=$1 | ||
local environment_name=$(abcli_option "$options" name abcli) | ||
|
||
local exists=$(abcli_conda_exists $environment_name) | ||
if [[ "$exists" == 0 ]]; then | ||
abcli_log_warning "@conda: $environment_name does not exist." | ||
return 0 | ||
fi | ||
|
||
conda activate base | ||
[[ $? -ne 0 ]] && return 1 | ||
|
||
abcli_eval ,$options \ | ||
conda remove -y \ | ||
--name $environment_name \ | ||
--all | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from typing import List | ||
|
||
from blue_options.terminal import show_usage, xtra | ||
|
||
|
||
def help_create( | ||
tokens: List[str], | ||
mono: bool, | ||
) -> str: | ||
options = "".join( | ||
[ | ||
xtra("clone=<auto|base>,~install_plugin,", mono=mono), | ||
"name=<environment-name>", | ||
xtra(",repo=<repo-name>,~recreate", mono=mono), | ||
] | ||
) | ||
|
||
return show_usage( | ||
[ | ||
"@conda", | ||
"create", | ||
f"[{options}]", | ||
], | ||
"create conda environment.", | ||
mono=mono, | ||
) | ||
|
||
|
||
def help_exists( | ||
tokens: List[str], | ||
mono: bool, | ||
) -> str: | ||
options = "name=<environment-name>" | ||
|
||
return show_usage( | ||
[ | ||
"@conda", | ||
"exists", | ||
f"[{options}]", | ||
], | ||
"does conda environment exist?", | ||
mono=mono, | ||
) | ||
|
||
|
||
def help_list( | ||
tokens: List[str], | ||
mono: bool, | ||
) -> str: | ||
options = xtra("dryrun", mono=mono) | ||
|
||
return show_usage( | ||
[ | ||
"@conda", | ||
"list", | ||
f"[{options}]", | ||
], | ||
"show list of conda environments.", | ||
mono=mono, | ||
) | ||
|
||
|
||
def help_rm( | ||
tokens: List[str], | ||
mono: bool, | ||
) -> str: | ||
options = "".join( | ||
[ | ||
xtra("dryrun,", mono=mono), | ||
"name=<environment-name>", | ||
] | ||
) | ||
|
||
return show_usage( | ||
[ | ||
"@conda", | ||
"rm", | ||
f"[{options}]", | ||
], | ||
"rm conda environment.", | ||
mono=mono, | ||
) | ||
|
||
|
||
help_functions = { | ||
"create": help_create, | ||
"exists": help_exists, | ||
"list": help_list, | ||
"rm": help_rm, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters