Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
85508d10
Commit
85508d10
authored
1 year ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
data-envs: add a --filter flag to den-list-data-envs
parent
f04c2e5c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python-libs/poulpe/cli.py
+21
-13
21 additions, 13 deletions
python-libs/poulpe/cli.py
python-libs/poulpe/den.py
+13
-4
13 additions, 4 deletions
python-libs/poulpe/den.py
tests/test-data-env-listing.t
+6
-0
6 additions, 0 deletions
tests/test-data-env-listing.t
with
40 additions
and
17 deletions
python-libs/poulpe/cli.py
+
21
−
13
View file @
85508d10
...
...
@@ -30,6 +30,20 @@
return
cmds
def
filter_option
(
target
):
return
click
.
option
(
"
--filter
"
,
"
filters
"
,
multiple
=
True
,
help
=
f
"""
Criteria to filter
{
target
}
with. Filters are additive.
They are of the form `key=value`, where `key` is the dot-delimited key
inside the result file, and `value` is the expected value.
If `value` starts with `re:`, then it is checked against
the regular expression that follows.
"""
,
)
@click.group
()
def
poulpe_cli
():
"""
The main entry point for Poulpe command
"""
...
...
@@ -102,7 +116,8 @@
@poulpe_cli.command
()
@click.option
(
"
--den-path
"
,
type
=
click
.
Path
(
exists
=
True
),
default
=
"
.
"
)
def
den_list_data_envs
(
den_path
=
"
.
"
):
@filter_option
(
target
=
"
data-environments
"
)
def
den_list_data_envs
(
den_path
=
"
.
"
,
filters
=
None
):
"""
Find and list Data Enviroment available in a Poulpe Den
"""
den_root
=
Path
(
den_path
)
den
=
den_mod
.
PoulpeDen
(
den_root
)
...
...
@@ -106,7 +121,10 @@
"""
Find and list Data Enviroment available in a Poulpe Den
"""
den_root
=
Path
(
den_path
)
den
=
den_mod
.
PoulpeDen
(
den_root
)
den_mod
.
list_data_env
(
den
)
if
filters
is
None
:
filters
=
[]
filters
=
filter
.
parse_filters
(
filters
)
den_mod
.
list_data_env
(
den
,
filters
=
filters
)
@poulpe_cli.command
()
...
...
@@ -245,17 +263,7 @@
default
=
False
,
help
=
"
Display the contents as JSON instead of the filenames
"
,
)
@click.option
(
"
--filter
"
,
"
filters
"
,
multiple
=
True
,
help
=
"""
Criteria to filter results with. Filters are additive.
They are of the form `key=value`, where `key` is the dot-delimited key
inside the result file, and `value` is the expected value.
If `value` starts with `re:`, then it is checked against
the regular expression that follows.
"""
,
)
@filter_option
(
target
=
"
results
"
)
@click.argument
(
"
result_paths
"
,
metavar
=
"
RESULTS
"
,
nargs
=-
1
)
def
result_search
(
result_paths
,
...
...
This diff is collapsed.
Click to expand it.
python-libs/poulpe/den.py
+
13
−
4
View file @
85508d10
...
...
@@ -10,5 +10,6 @@
from
pathlib
import
Path
from
poulpe
import
basics
from
poulpe
import
benchmarks
from
poulpe
import
binenvs
as
bin_env_mod
from
poulpe
import
dataenvs
...
...
@@ -13,6 +14,6 @@
from
poulpe
import
binenvs
as
bin_env_mod
from
poulpe
import
dataenvs
from
poulpe
import
benchmarks
from
poulpe
import
filter
class
PoulpeDen
:
...
...
@@ -51,5 +52,5 @@
def
tooling_dir
(
self
):
return
self
.
root_dir
/
"
tooling
"
def
find_data_envs
(
self
):
def
find_data_envs
(
self
,
filters
=
()
):
"""
walk the data-envs directory in search of data-env
"""
...
...
@@ -55,4 +56,12 @@
"""
walk the data-envs directory in search of data-env
"""
data_envs
=
self
.
_find_all_data_envs
()
result
=
[]
for
d
in
data_envs
:
if
filter
.
apply_filters
(
filters
,
d
.
data_env_vars
):
result
.
append
(
d
)
return
result
def
_find_all_data_envs
(
self
):
den_data_envs
=
[]
# search for data_envs in the data_env directory
...
...
@@ -199,6 +208,6 @@
print
(
f
"
~
{
c
}
{
d
}
"
)
def
list_data_env
(
den
):
for
data_env
in
den
.
find_data_envs
():
def
list_data_env
(
den
,
filters
=
()
):
for
data_env
in
den
.
find_data_envs
(
filters
=
filters
):
print
(
f
"
{
data_env
.
path
}
"
)
This diff is collapsed.
Click to expand it.
tests/test-data-env-listing.t
+
6
−
0
View file @
85508d10
...
...
@@ -50,3 +50,9 @@
$
poulpe
den
-
list
-
data
-
envs
data
-
envs
/
bar
data
-
envs
/
foo
filter
list
-----------
$
poulpe
den
-
list
-
data
-
envs
--
filter
mercurial
.
repo
.
graph
.
visible
-
revision
-
count
=
"
re:^1....$
"
data
-
envs
/
foo
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