Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
concepts-processing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
meldb
concepts-processing
Commits
230240d1
Commit
230240d1
authored
1 month ago
by
Jakub Dylag
Browse files
Options
Downloads
Patches
Plain Diff
(feat) flag to stop phen diff from check config.yml if it doesn't exist
parent
1aeab1dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
acmc/main.py
+7
-1
7 additions, 1 deletion
acmc/main.py
acmc/phen.py
+31
-26
31 additions, 26 deletions
acmc/phen.py
with
38 additions
and
27 deletions
acmc/main.py
+
7
−
1
View file @
230240d1
...
...
@@ -78,7 +78,7 @@ def _phen_copy(args: argparse.Namespace):
def
_phen_diff
(
args
:
argparse
.
Namespace
):
"""
Handle the `phen diff` command.
"""
phen
.
diff
(
args
.
phen_dir
,
args
.
version
,
args
.
old_phen_dir
,
args
.
old_version
)
phen
.
diff
(
args
.
phen_dir
,
args
.
version
,
args
.
old_phen_dir
,
args
.
old_version
,
args
.
not_check_config
)
def
main
():
...
...
@@ -323,6 +323,12 @@ def main():
required
=
True
,
help
=
"
Old phenotype version to compare with the changed version
"
,
)
phen_diff_parser
.
add_argument
(
"
--not-check-config
"
,
action
=
'
store_true
'
,
default
=
False
,
help
=
"
(Optional) Prevent loading and comparing config file, in the case where one does not exist
"
,
)
phen_diff_parser
.
set_defaults
(
func
=
_phen_diff
)
# Parse arguments
...
...
This diff is collapsed.
Click to expand it.
acmc/phen.py
+
31
−
26
View file @
230240d1
...
...
@@ -1375,37 +1375,42 @@ def diff_phen(
old_phen_path
:
Path
,
old_version
:
str
,
report_path
:
Path
,
not_check_config
:
bool
,
):
"""
Compare the differences between two versions of a phenotype
"""
# validate phenotypes
_logger
.
debug
(
f
"
Validating for diff old path:
{
str
(
old_phen_path
.
resolve
())
}
"
)
validate
(
str
(
old_phen_path
.
resolve
()))
_logger
.
debug
(
f
"
Validating for diff new path:
{
str
(
new_phen_path
.
resolve
())
}
"
)
validate
(
str
(
new_phen_path
.
resolve
()))
# get old and new config
old_config_path
=
old_phen_path
/
CONFIG_FILE
with
old_config_path
.
open
(
"
r
"
)
as
file
:
old_config
=
yaml
.
safe_load
(
file
)
new_config_path
=
new_phen_path
/
CONFIG_FILE
with
new_config_path
.
open
(
"
r
"
)
as
file
:
new_config
=
yaml
.
safe_load
(
file
)
# write report heading
report
=
f
"
# Phenotype Comparison Report
\n
"
report
+=
f
"
## Original phenotype
\n
"
report
+=
f
"
-
{
old_config
[
'
phenotype
'
][
'
omop
'
][
'
vocabulary_id
'
]
}
\n
"
report
+=
f
"
-
{
old_version
}
\n
"
report
+=
f
"
-
{
str
(
old_phen_path
.
resolve
())
}
\n
"
report
+=
f
"
## Changed phenotype:
\n
"
report
+=
f
"
-
{
new_config
[
'
phenotype
'
][
'
omop
'
][
'
vocabulary_id
'
]
}
\n
"
report
+=
f
"
-
{
new_version
}
\n
"
report
+=
f
"
-
{
str
(
new_phen_path
.
resolve
())
}
\n
"
# Step 1: check differences configuration files
# Convert list of dicts into a dict: {name: file}
report
+=
diff_config
(
old_config
,
new_config
)
if
not
not_check_config
:
# validate phenotypes
_logger
.
debug
(
f
"
Validating for diff old path:
{
str
(
old_phen_path
.
resolve
())
}
"
)
validate
(
str
(
old_phen_path
.
resolve
()))
_logger
.
debug
(
f
"
Validating for diff new path:
{
str
(
new_phen_path
.
resolve
())
}
"
)
validate
(
str
(
new_phen_path
.
resolve
()))
# get old and new config
old_config_path
=
old_phen_path
/
CONFIG_FILE
with
old_config_path
.
open
(
"
r
"
)
as
file
:
old_config
=
yaml
.
safe_load
(
file
)
new_config_path
=
new_phen_path
/
CONFIG_FILE
with
new_config_path
.
open
(
"
r
"
)
as
file
:
new_config
=
yaml
.
safe_load
(
file
)
# write report
report
+=
f
"
## Original phenotype
\n
"
report
+=
f
"
-
{
old_config
[
'
phenotype
'
][
'
omop
'
][
'
vocabulary_id
'
]
}
\n
"
report
+=
f
"
-
{
old_version
}
\n
"
report
+=
f
"
-
{
str
(
old_phen_path
.
resolve
())
}
\n
"
report
+=
f
"
## Changed phenotype:
\n
"
report
+=
f
"
-
{
new_config
[
'
phenotype
'
][
'
omop
'
][
'
vocabulary_id
'
]
}
\n
"
report
+=
f
"
-
{
new_version
}
\n
"
report
+=
f
"
-
{
str
(
new_phen_path
.
resolve
())
}
\n
"
# Convert list of dicts into a dict: {name: file}
report
+=
diff_config
(
old_config
,
new_config
)
# Step 2: check differences between map files
# List files from output directories
...
...
@@ -1422,7 +1427,7 @@ def diff_phen(
_logger
.
info
(
f
"
Phenotypes diff
'
d successfully
"
)
def
diff
(
phen_dir
:
str
,
version
:
str
,
old_phen_dir
:
str
,
old_version
:
str
):
def
diff
(
phen_dir
:
str
,
version
:
str
,
old_phen_dir
:
str
,
old_version
:
str
,
not_check_config
:
bool
):
# make tmp directory .acmc
timestamp
=
time
.
strftime
(
"
%Y%m%d_%H%M%S
"
)
temp_dir
=
Path
(
f
"
.acmc/diff_
{
timestamp
}
"
)
...
...
@@ -1483,7 +1488,7 @@ def diff(phen_dir: str, version: str, old_phen_dir: str, old_version: str):
report_filename
=
f
"
{
version
}
_
{
old_version
}
_diff.md
"
report_path
=
changed_phen_path
/
report_filename
# diff old with new
diff_phen
(
changed_path
,
version
,
old_path
,
old_version
,
report_path
)
diff_phen
(
changed_path
,
version
,
old_path
,
old_version
,
report_path
,
not_check_config
)
finally
:
# clean up tmp directory
...
...
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