Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mednet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
medai
software
mednet
Commits
2e8c52e9
Commit
2e8c52e9
authored
10 months ago
by
Daniel CARRON
Committed by
André Anjos
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[cli] Fix info command
parent
1e2c50e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!46
Create common library
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mednet/scripts/info.py
+65
-27
65 additions, 27 deletions
src/mednet/scripts/info.py
with
65 additions
and
27 deletions
src/mednet/scripts/info.py
+
65
−
27
View file @
2e8c52e9
...
...
@@ -5,10 +5,52 @@
import
click
from
clapper.click
import
verbosity_option
from
clapper.logging
import
setup
from
clapper.rc
import
UserDefaults
logger
=
setup
(
__name__
.
split
(
"
.
"
)[
0
],
format
=
"
%(levelname)s: %(message)s
"
)
def
_echo
(
left
:
str
,
right
:
str
,
color
:
str
=
"
white
"
)
->
None
:
s
=
[
click
.
style
(
left
,
bold
=
True
),
click
.
style
(
"
:
"
,
bold
=
True
),
click
.
style
(
right
,
fg
=
color
),
]
click
.
echo
(
""
.
join
(
s
))
def
database_configuration
(
rc
:
UserDefaults
,
raw_databases
:
dict
[
str
,
dict
[
str
,
str
]],
lib_name
:
str
):
"""
Display the database configuration for a particular library.
Parameters
----------
rc
The user defaults read from the user .toml configuration file.
raw_databases
List of all supported (raw) databases.
lib_name
Name of the library to show configurations for.
"""
if
not
rc
.
path
.
exists
():
_echo
(
f
"
{
lib_name
}
configuration
"
,
f
"
{
str
(
rc
.
path
)
}
[MISSING]
"
,
"
white
"
)
else
:
_echo
(
f
"
{
lib_name
}
configuration
"
,
str
(
rc
.
path
),
"
white
"
)
click
.
secho
(
f
"
configured
{
lib_name
}
databases:
"
,
bold
=
True
)
for
k
,
v
in
raw_databases
.
items
():
if
"
datadir
"
not
in
v
:
# this database does not have a "datadir"
continue
if
v
[
"
datadir
"
]
is
not
None
:
_echo
(
f
"
-
{
k
}
(
{
v
[
'
module
'
]
}
)
"
,
f
"
{
v
[
'
datadir
'
]
}
"
,
"
green
"
)
else
:
_echo
(
f
"
-
{
k
}
(
{
v
[
'
module
'
]
}
)
"
,
"
NOT installed
"
,
"
red
"
)
@click.command
(
epilog
=
"""
Examples:
...
...
@@ -28,20 +70,21 @@ def info(
import
typing
from
..utils.rc
import
load_rc
from
.database
import
_get_raw_databases
from
.utils
import
execution_metadata
def
_echo
(
left
:
str
,
right
:
str
,
color
:
str
=
"
white
"
)
->
None
:
s
=
[
click
.
style
(
left
,
bold
=
True
),
click
.
style
(
"
:
"
,
bold
=
True
),
click
.
style
(
right
,
fg
=
color
),
]
click
.
echo
(
""
.
join
(
s
))
from
mednet.libs.classification.scripts.database
import
(
_get_raw_databases
as
_get_raw_databases_classification
,
)
from
mednet.libs.classification.utils.rc
import
(
load_rc
as
load_rc_classification
,
)
from
mednet.libs.common.scripts.utils
import
execution_metadata
from
mednet.libs.segmentation.scripts.database
import
(
_get_raw_databases
as
_get_raw_databases_segmentation
,
)
from
mednet.libs.segmentation.utils.rc
import
(
load_rc
as
load_rc_segmentation
,
)
m
=
execution_metadata
()
c
=
load_rc
()
_echo
(
"
mednet version
"
,
typing
.
cast
(
str
,
m
[
"
package-version
"
]),
"
green
"
)
_echo
(
"
platform
"
,
typing
.
cast
(
str
,
m
[
"
platform
"
]),
"
yellow
"
)
...
...
@@ -51,21 +94,16 @@ def info(
"
cyan
"
,
)
if
not
c
.
path
.
exists
():
_echo
(
"
configuration
"
,
f
"
{
str
(
c
.
path
)
}
[MISSING]
"
,
"
white
"
)
else
:
_echo
(
"
configuration
"
,
str
(
c
.
path
),
"
white
"
)
dbs
=
_get_raw_databases
()
click
.
secho
(
"
configured databases:
"
,
bold
=
True
)
for
k
,
v
in
dbs
.
items
():
if
"
datadir
"
not
in
v
:
# this database does not have a "datadir"
continue
if
v
[
"
datadir
"
]
is
not
None
:
_echo
(
f
"
-
{
k
}
(
{
v
[
'
module
'
]
}
)
"
,
f
"
{
v
[
'
datadir
'
]
}
"
,
"
green
"
)
else
:
_echo
(
f
"
-
{
k
}
(
{
v
[
'
module
'
]
}
)
"
,
"
NOT installed
"
,
"
red
"
)
database_configuration
(
load_rc_classification
(),
_get_raw_databases_classification
(),
"
classification
"
,
)
database_configuration
(
load_rc_segmentation
(),
_get_raw_databases_segmentation
(),
"
segmentation
"
,
)
click
.
secho
(
"
dependencies:
"
,
bold
=
True
)
python
=
typing
.
cast
(
dict
[
str
,
str
],
m
[
"
python
"
])
...
...
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