Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BioFlow-Insight
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shareFAIR
BioFlow-Insight
Commits
8be0c110
Commit
8be0c110
authored
3 months ago
by
George Marchment
Browse files
Options
Downloads
Patches
Plain Diff
Update smalll bug + removing ternary operator from code
parent
418fb2a7
No related branches found
No related tags found
No related merge requests found
Pipeline
#14427
failed with stage
in 2 minutes and 30 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/code_.py
+20
-0
20 additions, 0 deletions
src/code_.py
src/function.py
+3
-0
3 additions, 0 deletions
src/function.py
src/subworkflow.py
+0
-1
0 additions, 1 deletion
src/subworkflow.py
src/workflow.py
+11
-4
11 additions, 4 deletions
src/workflow.py
with
34 additions
and
5 deletions
src/code_.py
+
20
−
0
View file @
8be0c110
...
@@ -21,6 +21,7 @@ class Code:
...
@@ -21,6 +21,7 @@ class Code:
self
.
code_wo_comments
=
re
.
sub
(
constant
.
BACKSLAPSH_JUMP
,
'
'
,
self
.
code_wo_comments
)
self
.
code_wo_comments
=
re
.
sub
(
constant
.
BACKSLAPSH_JUMP
,
'
'
,
self
.
code_wo_comments
)
self
.
code_wo_comments
=
self
.
code_wo_comments
.
replace
(
"
||
"
,
"
$OR$
"
)
self
.
code_wo_comments
=
self
.
code_wo_comments
.
replace
(
"
||
"
,
"
$OR$
"
)
self
.
code_wo_comments
=
self
.
turn_single_condition_into_multiline
(
self
.
code_wo_comments
)
self
.
code_wo_comments
=
self
.
turn_single_condition_into_multiline
(
self
.
code_wo_comments
)
self
.
code_wo_comments
=
self
.
rewrite_ternary_operation_to_normal_condition
(
self
.
code_wo_comments
)
def
check_its_nextflow
(
self
):
def
check_its_nextflow
(
self
):
...
@@ -40,6 +41,25 @@ class Code:
...
@@ -40,6 +41,25 @@ class Code:
old
,
new
=
r
old
,
new
=
r
code
=
code
.
replace
(
old
,
new
)
code
=
code
.
replace
(
old
,
new
)
return
code
return
code
#This methods rewrite ternary operation into "normal" conditions
#variable = (condition) ? Expression2 : Expression3;
def
rewrite_ternary_operation_to_normal_condition
(
self
,
code
):
pattern
=
r
"
(\w+) *\= *([^?\n]+) *\? *([^:\n]+) *\: *([^\n]+)\n
"
to_replace
=
[]
for
match
in
re
.
finditer
(
pattern
,
code
):
variable
=
match
.
group
(
1
)
condition
=
match
.
group
(
2
).
strip
()
exp1
,
exp2
=
match
.
group
(
3
).
strip
(),
match
.
group
(
4
).
strip
()
old
=
match
.
group
(
0
)
new
=
f
"
if (
{
condition
}
) {{
\n
{
variable
}
=
{
exp1
}
\n
}}
\n\n
"
new
+=
f
"
if (!(
{
condition
}
)) {{
\n
{
variable
}
=
{
exp2
}
\n
}}
\n\n
"
#else {{\n{variable} = {exp2}\n}}\n"
to_replace
.
append
((
old
,
new
))
for
r
in
to_replace
:
old
,
new
=
r
code
=
code
.
replace
(
old
,
new
)
return
code
def
get_line
(
self
,
bit_of_code
):
def
get_line
(
self
,
bit_of_code
):
code
=
remove_comments
(
self
.
code
)
code
=
remove_comments
(
self
.
code
)
...
...
This diff is collapsed.
Click to expand it.
src/function.py
+
3
−
0
View file @
8be0c110
...
@@ -16,6 +16,9 @@ class Function(Nextflow_Building_Blocks):
...
@@ -16,6 +16,9 @@ class Function(Nextflow_Building_Blocks):
def
get_alias
(
self
):
def
get_alias
(
self
):
return
self
.
alias
return
self
.
alias
def
get_alias_and_id
(
self
):
return
f
"
{
self
.
alias
}
_GG_
{
id
(
self
)
}
"
def
get_type
(
self
):
def
get_type
(
self
):
return
"
Function
"
return
"
Function
"
...
...
This diff is collapsed.
Click to expand it.
src/subworkflow.py
+
0
−
1
View file @
8be0c110
...
@@ -100,7 +100,6 @@ class Subworkflow(Main):
...
@@ -100,7 +100,6 @@ class Subworkflow(Main):
def
simplify_code
(
self
):
def
simplify_code
(
self
):
code
=
super
().
simplify_code
()
code
=
super
().
simplify_code
()
for
o
in
self
.
emit
:
for
o
in
self
.
emit
:
print
(
o
.
get_code
(
get_OG
=
True
),
o
.
simplify_code
(),
o
.
OG_code
)
code
=
code
.
replace
(
o
.
get_code
(
get_OG
=
True
),
o
.
simplify_code
(),
1
)
code
=
code
.
replace
(
o
.
get_code
(
get_OG
=
True
),
o
.
simplify_code
(),
1
)
return
code
return
code
...
...
This diff is collapsed.
Click to expand it.
src/workflow.py
+
11
−
4
View file @
8be0c110
...
@@ -749,7 +749,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
...
@@ -749,7 +749,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
#Get the clusters and the code
#Get the clusters and the code
relevant_processes
=
self
.
check_relevant_processes_in_workflow
(
relevant_processes
)
relevant_processes
=
self
.
check_relevant_processes_in_workflow
(
relevant_processes
)
print
(
relevant_processes
)
self
.
generate_user_view
(
relevant_processes
=
relevant_processes
,
processes_2_remove
=
[])
self
.
generate_user_view
(
relevant_processes
=
relevant_processes
,
processes_2_remove
=
[])
clusters
=
self
.
graph
.
get_clusters_from_user_view
()
clusters
=
self
.
graph
.
get_clusters_from_user_view
()
broken_subworkflows
=
get_workflows_broken
(
get_subworkflow_2_executors
(),
get_clusters_with_calls
(
clusters
))
broken_subworkflows
=
get_workflows_broken
(
get_subworkflow_2_executors
(),
get_clusters_with_calls
(
clusters
))
...
@@ -767,7 +766,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
...
@@ -767,7 +766,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
broken_subworkflows
=
get_workflows_broken
(
get_subworkflow_2_executors
(),
get_clusters_with_calls
(
clusters
))
broken_subworkflows
=
get_workflows_broken
(
get_subworkflow_2_executors
(),
get_clusters_with_calls
(
clusters
))
#print(code)
...
@@ -967,8 +966,16 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
...
@@ -967,8 +966,16 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
#Replace names inside subworkflow
#Replace names inside subworkflow
subworkflow_code
=
f
"
workflow
{
name
}
{{
\n
{
take
}
\n
main:
\n
{
body
}
\n
{
emit
}
\n
}}
"
subworkflow_code
=
f
"
workflow
{
name
}
{{
\n
{
take
}
\n
main:
\n
{
body
}
\n
{
emit
}
\n
}}
"
for
i
in
range
(
len
(
new_param_names
)):
for
i
in
range
(
len
(
new_param_names
)):
pattern
=
fr
"
[\=\,\(] *(
{
re
.
escape
(
takes_param
[
i
].
get_code
())
}
)[\s\,\)\.]
"
if
(
takes_param
[
i
].
get_code
()
!=
new_param_names
[
i
]):
subworkflow_code
=
replace_group1
(
subworkflow_code
,
pattern
,
new_param_names
[
i
])
#pattern = fr"[\=\,\(] *({re.escape(takes_param[i].get_code())})[\s\,\)\.]"
pattern
=
fr
"
(
{
re
.
escape
(
takes_param
[
i
].
get_code
())
}
)[\s\,\)\.]
"
temp
=
subworkflow_code
subworkflow_code
=
replace_group1
(
subworkflow_code
,
pattern
,
new_param_names
[
i
])
if
(
temp
==
subworkflow_code
):
print
(
takes_param
[
i
].
get_code
(),
new_param_names
[
i
])
print
(
pattern
)
print
(
f
'"
{
subworkflow_code
}
"'
)
raise
Exception
(
"
Something went wrong -> cause the paramter wasn
'
t updated
"
)
#subworkflow_code = subworkflow_code.replace(takes_param[i].get_code(), new_param_names[i])
#subworkflow_code = subworkflow_code.replace(takes_param[i].get_code(), new_param_names[i])
#TODO -> added verification of conditions
#TODO -> added verification of conditions
...
...
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