Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enstools-compression
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2w
enstools-compression
Commits
9df7d9bc
Commit
9df7d9bc
authored
1 year ago
by
Oriol Tintó
Browse files
Options
Downloads
Patches
Plain Diff
Add load-plugins and unload-plugins options in the CLI.
parent
6ec521c6
No related branches found
No related tags found
1 merge request
!15
Development
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
enstools/compression/cli.py
+28
-2
28 additions, 2 deletions
enstools/compression/cli.py
enstools/compression/plugins.py
+30
-0
30 additions, 0 deletions
enstools/compression/plugins.py
tests/test_cli.py
+18
-0
18 additions, 0 deletions
tests/test_cli.py
with
76 additions
and
2 deletions
enstools/compression/cli.py
+
28
−
2
View file @
9df7d9bc
...
...
@@ -336,7 +336,7 @@ Tool to quickly compare two datasets, mainly though to compare a compressed data
"""
def
add_
sub
subparser
(
subparsers
):
def
add_subparser
_evaluator
(
subparsers
):
import
argparse
subparser
=
subparsers
.
add_parser
(
'
evaluate
'
,
help
=
evaluate_help_text
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
...
...
@@ -389,6 +389,27 @@ def call_pruner(args):
pruner
(
file_paths
,
output
)
def
add_subparser_load_plugins
(
subparsers
):
import
argparse
load_subparser
=
subparsers
.
add_parser
(
'
load-plugins
'
,
help
=
"
Add the HDF5PLUGINPATH path to the environment
"
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
load_subparser
.
set_defaults
(
which
=
'
load-plugins
'
)
unload_subparser
=
subparsers
.
add_parser
(
'
unload-plugins
'
,
help
=
"
Remove the HDF5PLUGINPATH from the environment
"
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
unload_subparser
.
set_defaults
(
which
=
'
unload-plugins
'
)
def
call_load_plugins
():
from
enstools.compression.plugins
import
load_plugins
load_plugins
()
def
call_unload_plugins
():
from
enstools.compression.plugins
import
unload_plugins
unload_plugins
()
###############################
def
add_subparsers
(
parser
):
...
...
@@ -405,10 +426,11 @@ def add_subparsers(parser):
# Create the parser for the "significand" command
add_subparser_significand
(
subparsers
)
# Create the parser for the "evaluator" command
add_
sub
subparser
(
subparsers
)
add_subparser
_evaluator
(
subparsers
)
# Create the parser for the "pruner" command
add_subparser_pruner
(
subparsers
)
# To add an additional subparser, just create a function like the ones above and add the call here.
add_subparser_load_plugins
(
subparsers
)
def
expand_paths
(
string
:
str
):
...
...
@@ -463,5 +485,9 @@ def main():
call_evaluator
(
args
)
elif
args
.
which
==
"
pruner
"
:
call_pruner
(
args
)
elif
args
.
which
==
"
load-plugins
"
:
call_load_plugins
()
elif
args
.
which
==
"
unload-plugins
"
:
call_unload_plugins
()
else
:
raise
NotImplementedError
This diff is collapsed.
Click to expand it.
enstools/compression/plugins.py
0 → 100644
+
30
−
0
View file @
9df7d9bc
import
sys
def
load_plugins
()
->
None
:
"""
Function to print the instructions to set the environment variable HDF5_PLUGIN_PATH.
"""
import
hdf5plugin
from
pathlib
import
Path
hdf5plugin_folder
=
Path
(
hdf5plugin
.
__file__
).
parent
plugins_folder
=
hdf5plugin_folder
/
"
plugins
"
load_plugins_comment
=
"""
# You can just execute this command within $() -> $(enstools-compression load-plugins)
# or just execute the following line in your terminal:
"""
print
(
load_plugins_comment
,
file
=
sys
.
stderr
)
print
(
f
"
export HDF5_PLUGIN_PATH=
{
plugins_folder
.
as_posix
()
}
"
)
def
unload_plugins
():
unload_plugins_comment
=
"""
# You can just execute this command within $() -> $(enstools-compression unload-plugins)
# or just execute the following line in your terminal:
"""
print
(
unload_plugins_comment
,
file
=
sys
.
stderr
)
print
(
"
unset HDF5_PLUGIN_PATH
"
)
This diff is collapsed.
Click to expand it.
tests/test_cli.py
+
18
−
0
View file @
9df7d9bc
...
...
@@ -19,6 +19,24 @@ class TestCommandLineInterface(TestClass):
with
pytest
.
raises
(
SystemExit
):
enstools
.
compression
.
cli
.
main
()
def
test_load_plugins
(
self
,
mocker
):
"""
Check that the cli prints the help and exists.
"""
import
enstools.compression.cli
commands
=
[
"
_
"
,
"
load-plugins
"
]
mocker
.
patch
(
"
sys.argv
"
,
commands
)
enstools
.
compression
.
cli
.
main
()
def
test_unload_plugins
(
self
,
mocker
):
"""
Check that the cli prints the help and exists.
"""
import
enstools.compression.cli
commands
=
[
"
_
"
,
"
unload-plugins
"
]
mocker
.
patch
(
"
sys.argv
"
,
commands
)
enstools
.
compression
.
cli
.
main
()
def
test_compress
(
self
,
mocker
):
"""
Test enstools-compressor compress
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment