mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-04 23:09:44 +01:00
* init * rename to plot data insertion basig on dicts update * revision support * roll back revision * plot makedirs for backward compatibility * log path * pretty plot link to visualization page * make target default title * efiop review * efiop review * plot multiple initial * add some missing metric file tests * proper id generation * proper id generation * add confusion matrix template * refactor tests * plot from dvct file * plot from dvct * brush up commands * fix confusion matrix multiple plot * plot: change confusion matrix data schema * should be working as intended * support for src file in dvct files * minor fixes * plot: support json templates * plot: rename confusion template * plot: polish command behaviour * fix test for json * plot: test command * some minor fixes for tests * plot: unit test loading * plot: unit test loading * plot: handle TODOS * cleanup * use mocker * plot: support tsv * plot: command refactoring * plot: fix windows issues with tests * plot: test: some more windows fixes * plot: _load_from_revisions complexity fix * plot: reduce complexity * plot: complexity reduction * plot: deepsource suggestions * plot: move template path evaluation * fixup * fixup * exception on no datafile and no template * json metric load with OrderedDict * plot: improve handling non-existing files on revisions * plot: improve handling non-existing files on revisions * change default plot path * some exceptions and fixes * add yaml metrics support * fixup * some more suggestions * default filename fix * efiop review requests * log exception on failur * move revisions deduction to commands * json templates * extract template filling to separate method * some parsing improvements * add columns functionality * extract default data transformation to separate method * plot: initial support for jsonpath * plot: rename columns to filters, tests are dict based * plot: fixups * plot: refactoring * repo: plot: convert to package * plot: data loading refactor, support searching for data * plot: raise if wrong fields provided * plot: command description * plot: default: pass y axis info for default plot * plot: get rid of fieldnames, expect ordered data * plot: handle default plot in separate method * plot: fix default * plot: command option names fixes * refactoring * fixes * plot: provide option for stdout redirection * plot: rename show-json to no-html * plot: add no-csv-header option * plot: improve error message for wrongly structured metric * plot: match template name exactly, whit suffix appended only * plot: dmpetrov and ivan review * plot: refactor --stdout help message * plot: move template to repo/plot * plot: add -x and -y options * plot: add -x and -y options * plot: command: order change * plot: scatter * plot: rename confusion matrix template, new name generation format * plot: add title anchor * plot: review from jorgeorpinel * plot: rename filter and result options to select and file * plot: add --title, --x-title, --y-title * plot: xlab ylab * Update dvc/repo/plot/template.py Co-authored-by: Ruslan Kuprieiev <[email protected]> * Update dvc/repo/plot/template.py Co-authored-by: Ruslan Kuprieiev <[email protected]> * efiop review * plot: bash completion * plot: static code analysis fixes Co-authored-by: Ruslan Kuprieiev <[email protected]>
150 lines
6.0 KiB
Bash
150 lines
6.0 KiB
Bash
#!/usr/bin/env bash
|
|
# References:
|
|
# - https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html
|
|
# - https://opensource.com/article/18/3/creating-bash-completion-script
|
|
# - https://stackoverflow.com/questions/12933362
|
|
|
|
_dvc_commands='add cache checkout commit config destroy diff fetch get-url get gc \
|
|
import-url import init install lock list metrics move pipeline plot pull push \
|
|
remote remove repro root run status unlock unprotect update version'
|
|
|
|
_dvc_options='-h --help -V --version'
|
|
_dvc_global_options='-h --help -q --quiet -v --verbose'
|
|
|
|
_dvc_add='-R --recursive -f --file --no-commit'
|
|
_dvc_add_COMPGEN=_dvc_compgen_files
|
|
_dvc_cache='dir'
|
|
_dvc_cache_dir=' --global --system --local -u --unset'
|
|
_dvc_checkout='-d --with-deps -R --recursive -f --force --relink --summary'
|
|
_dvc_checkout_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_commit='-f --force -d --with-deps -R --recursive'
|
|
_dvc_commit_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_config='-u --unset --local --system --global'
|
|
_dvc_destroy='-f --force'
|
|
_dvc_diff='-t --show-json --show-hash'
|
|
_dvc_fetch='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive'
|
|
_dvc_fetch_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_gc='-a --all-branches --all-commits -T --all-tags -w --workspace -c --cloud -r --remote -f --force -p --projects -j --jobs'
|
|
_dvc_get='-o --out --rev --show-url'
|
|
_dvc_get_url=''
|
|
_dvc_import='-o --out --rev'
|
|
_dvc_import_url='-f --file'
|
|
_dvc_init='--no-scm -f --force'
|
|
_dvc_install=''
|
|
_dvc_list='-R --recursive --outs-only --rev'
|
|
_dvc_list_COMPGEN=_dvc_compgen_files
|
|
_dvc_lock=''
|
|
_dvc_lock_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_metrics='add diff modify remove show'
|
|
_dvc_metrics_add='-t --type -x --xpath'
|
|
_dvc_metrics_add_COMPGEN=_dvc_compgen_files
|
|
_dvc_metrics_diff='--targets -t --type -x --xpath -R --show-json'
|
|
_dvc_metrics_modify='-t --type -x --xpath'
|
|
_dvc_metrics_modify_COMPGEN=_dvc_compgen_files
|
|
_dvc_metrics_remove=''
|
|
_dvc_metrics_remove_COMPGEN=_dvc_compgen_files
|
|
_dvc_metrics_show='-t --type -x --xpath -a --all-branches -T --all-tags -R --recursive'
|
|
_dvc_metrics_show_COMPGEN=_dvc_compgen_files
|
|
_dvc_move=''
|
|
_dvc_move_COMPGEN=_dvc_compgen_files
|
|
_dvc_pipeline='list show'
|
|
_dvc_pipeline_list=''
|
|
_dvc_pipeline_show='-c --commands -o --outs --ascii --dot --tree -l --locked'
|
|
_dvc_pipeline_show_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_plot='show diff'
|
|
_dvc_plot_show='-t --template -f --file -s --select -x -y --stdout --no-csv-header --no-html --title --xlab --ylab'
|
|
_dvc_plot_diff='-t --template -d --datafile -f --file -s --select -x -y --stdout --no-csv-header --no-html --title --xlab --ylab'
|
|
_dvc_pull='-j --jobs -r --remote -a --all-branches -T --all-tags -f --force -d --with-deps -R --recursive'
|
|
_dvc_pull_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_push='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive'
|
|
_dvc_push_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_remote='add default list modify remove'
|
|
_dvc_remote_add='--global --system --local -d --default -f --force'
|
|
_dvc_remote_default='--global --system --local -u --unset'
|
|
_dvc_remote_list='--global --system --local'
|
|
_dvc_remote_modify='--global --system --local -u --unset'
|
|
_dvc_remote_remove='--global --system --local'
|
|
_dvc_remove='-o --outs -p --purge -f --force'
|
|
_dvc_remove_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_repro='-f --force -s --single-item -c --cwd -m --metrics --dry -i --interactive -p --pipeline -P --all-pipelines --ignore-build-cache --no-commit -R --recursive --downstream'
|
|
_dvc_repro_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_root=''
|
|
_dvc_run='--no-exec -f --file -d --deps -o --outs -O --outs-no-cache --outs-persist --outs-persist-no-cache -m --metrics -M --metrics-no-cache --overwrite-dvcfile --ignore-build-cache --no-commit -w --wdir'
|
|
_dvc_run_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_status='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -c --cloud'
|
|
_dvc_status_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_unlock_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_unprotect_COMPGEN=_dvc_compgen_files
|
|
_dvc_update='--rev'
|
|
_dvc_update_COMPGEN=_dvc_compgen_DVCFiles
|
|
_dvc_version=''
|
|
|
|
# $1=COMP_WORDS[1]
|
|
_dvc_compgen_DVCFiles() {
|
|
compgen -f -X '!*?.dvc' -- $1
|
|
compgen -d -S '/' -- $1 # recurse into subdirs
|
|
# Note that the recurse into dirs is only for looking for DVC-files.
|
|
# Since dirs themselves are not required, we need `-o nospace` at the bottom
|
|
# unfortunately :(
|
|
}
|
|
|
|
# $1=COMP_WORDS[1]
|
|
_dvc_compgen_files() {
|
|
compgen -f -- $1
|
|
compgen -d -S '/' -- $1 # recurse into subdirs
|
|
}
|
|
|
|
# $1=COMP_WORDS[1]
|
|
_dvc_replace_hyphen() {
|
|
echo $1 | sed 's/-/_/g'
|
|
}
|
|
|
|
# $1=COMP_WORDS[1]
|
|
_dvc_compgen_command() {
|
|
local flags_list="_dvc_$(_dvc_replace_hyphen $1)"
|
|
local args_gen="${flags_list}_COMPGEN"
|
|
COMPREPLY=( $(compgen -W "$_dvc_global_options ${!flags_list}" -- "$word"; [ -n "${!args_gen}" ] && ${!args_gen} "$word") )
|
|
}
|
|
|
|
# $1=COMP_WORDS[1]
|
|
# $2=COMP_WORDS[2]
|
|
_dvc_compgen_subcommand() {
|
|
local flags_list="_dvc_$(_dvc_replace_hyphen $1)_$(_dvc_replace_hyphen $2)"
|
|
local args_gen="${flags_list}_COMPGEN"
|
|
[ -n "${!args_gen}" ] && local opts_more="$(${!args_gen} "$word")"
|
|
local opts="${!flags_list}"
|
|
if [ -z "$opts$opts_more" ]; then
|
|
_dvc_compgen_command $1
|
|
else
|
|
COMPREPLY=( $(compgen -W "$_dvc_global_options $opts" -- "$word"; [ -n "$opts_more" ] && echo "$opts_more") )
|
|
fi
|
|
}
|
|
|
|
# Notes:
|
|
# `COMPREPLY` contains what will be rendered after completion is triggered
|
|
# `word` refers to the current typed word
|
|
# `${!var}` is to evaluate the content of `var` and expand its content as a variable
|
|
# hello="world"
|
|
# x="hello"
|
|
# ${!x} -> ${hello} -> "world"
|
|
_dvc() {
|
|
local word="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
COMPREPLY=()
|
|
|
|
if [ "${COMP_CWORD}" -eq 1 ]; then
|
|
case "$word" in
|
|
-*) COMPREPLY=($(compgen -W "$_dvc_options" -- "$word")) ;;
|
|
*) COMPREPLY=($(compgen -W "$_dvc_commands" -- "$word")) ;;
|
|
esac
|
|
elif [ "${COMP_CWORD}" -eq 2 ]; then
|
|
_dvc_compgen_command ${COMP_WORDS[1]}
|
|
elif [ "${COMP_CWORD}" -ge 3 ]; then
|
|
_dvc_compgen_subcommand ${COMP_WORDS[1]} ${COMP_WORDS[2]}
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
complete -o nospace -F _dvc dvc
|