Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Pipeline Dependency Analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chiara Liotta
Pipeline Dependency Analysis
Commits
21196d6b
Commit
21196d6b
authored
6 months ago
by
Chiara Liotta
Browse files
Options
Downloads
Patches
Plain Diff
make every edge have a component_id
parent
f1dd6bce
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
graph_creation/cwl_processing.py
+3
-3
3 additions, 3 deletions
graph_creation/cwl_processing.py
neo4j_queries/edge_queries.py
+4
-28
4 additions, 28 deletions
neo4j_queries/edge_queries.py
with
7 additions
and
31 deletions
graph_creation/cwl_processing.py
+
3
−
3
View file @
21196d6b
...
...
@@ -2,7 +2,7 @@ from neo4j import Driver
from
graph_creation.cst_processing
import
traverse_when_statement_extract_dependencies
from
graph_creation.utils
import
process_in_param
,
process_parameter_source
from
neo4j_queries.node_queries
import
ensure_component_node
,
ensure_in_parameter_node
,
ensure_out_parameter_node
from
neo4j_queries.edge_queries
import
create_control_relationship
,
create_data_relationship
,
create_out_param_relationship
from
neo4j_queries.edge_queries
import
create_control_relationship
,
create_data_relationship
_with_id
,
create_out_param_relationship
from
neo4j_queries.utils
import
get_is_workflow
from
parsers.javascript_parsing
import
parse_javascript_expression_string
,
parse_javascript_string
...
...
@@ -138,7 +138,7 @@ def process_cwl_steps(driver: Driver, cwl_entity: dict, tool_paths: list[str], s
param_node_internal_id
=
param_node
[
0
]
if
is_tool
:
# Create a data edge from the step component node to the in-parameter node
create_data_relationship
(
driver
,
s_node_internal_id
,
param_node_internal_id
)
create_data_relationship
_with_id
(
driver
,
s_node_internal_id
,
param_node_internal_id
,
step_path
)
# Inputs can have one or multiple data sources (data nodes)
if
'
source
'
in
input
:
...
...
@@ -181,7 +181,7 @@ def process_cwl_steps(driver: Driver, cwl_entity: dict, tool_paths: list[str], s
param_node_internal_id
=
param_node
[
0
]
if
is_tool
:
# Create a data edge from out-parameter node to the step component node
create_data_relationship
(
driver
,
param_node_internal_id
,
s_node_internal_id
)
create_data_relationship
_with_id
(
driver
,
param_node_internal_id
,
s_node_internal_id
,
step_path
)
def
process_cwl_expression
(
driver
:
Driver
,
entity
:
dict
)
->
None
:
expression
=
entity
[
'
expression
'
]
...
...
This diff is collapsed.
Click to expand it.
neo4j_queries/edge_queries.py
+
4
−
28
View file @
21196d6b
...
...
@@ -21,7 +21,7 @@ def create_in_param_relationship(driver: Driver, prefixed_component_id: str, par
query
=
"""
MATCH (c:Component {component_id: $component_id}), (p:InParameter)
WHERE elementId(p) = $parameter_internal_id
MERGE (c)-[:DATA]->(p)
MERGE (c)-[:DATA
{component_id: $component_id}
]->(p)
RETURN c.component_id AS component_id, p.parameter_id AS parameter_id
"""
with
driver
.
session
()
as
session
:
...
...
@@ -48,38 +48,13 @@ def create_out_param_relationship(driver: Driver, prefixed_component_id: str, pa
query
=
"""
MATCH (c:Component {component_id: $component_id}), (p: OutParameter)
WHERE elementId(p) = $parameter_internal_id
MERGE (c)<-[:DATA]-(p)
MERGE (c)<-[:DATA
{component_id: $component_id}
]-(p)
RETURN c.component_id AS component_id, p.parameter_id AS parameter_id
"""
with
driver
.
session
()
as
session
:
result
=
session
.
run
(
query
,
component_id
=
component_id
,
parameter_internal_id
=
parameter_internal_id
)
def
create_data_relationship
(
driver
:
Driver
,
from_internal_node_id
:
int
,
to_internal_node_id
:
int
)
->
tuple
[
int
,
int
]:
"""
Creates a data dependency relationship in Neo4j between the two nodes with Neo4j internal IDs given as parameters.
This relationship is an outgoing data edge from the node with internal ID from_internal_node_id
to the node with internal ID to_internal_node_id.
Parameters:
driver (Driver): the Neo4j driver
from_internal_node_id (int): the internal Neo4j ID of the first node
to_internal_node_id (int): the internal Neo4j ID of the second node
Returns:
tuple[int,int]: from_internal_node_id, to_internal_node_id
"""
query
=
"""
MATCH (a), (b)
WHERE elementId(a) = $from_internal_node_id AND elementId(b) = $to_internal_node_id
MERGE (a)-[:DATA]->(b)
RETURN elementId(a) AS id_1, elementId(b) AS id_2
"""
with
driver
.
session
()
as
session
:
result
=
session
.
run
(
query
,
from_internal_node_id
=
from_internal_node_id
,
to_internal_node_id
=
to_internal_node_id
)
record
=
result
.
single
()
return
record
[
"
id_1
"
],
record
[
"
id_2
"
]
def
create_data_relationship_with_id
(
driver
:
Driver
,
from_internal_node_id
:
int
,
to_internal_node_id
:
int
,
id
:
str
)
->
tuple
[
int
,
int
]:
"""
...
...
@@ -95,6 +70,7 @@ def create_data_relationship_with_id(driver: Driver, from_internal_node_id: int,
Returns:
tuple[int,int]: from_internal_node_id, to_internal_node_id
"""
clean_id
=
clean_component_id
(
id
)
query
=
"""
MATCH (a), (b)
WHERE elementId(a) = $from_internal_node_id AND elementId(b) = $to_internal_node_id
...
...
@@ -103,7 +79,7 @@ def create_data_relationship_with_id(driver: Driver, from_internal_node_id: int,
"""
with
driver
.
session
()
as
session
:
result
=
session
.
run
(
query
,
from_internal_node_id
=
from_internal_node_id
,
to_internal_node_id
=
to_internal_node_id
,
component_id
=
id
)
to_internal_node_id
=
to_internal_node_id
,
component_id
=
clean_
id
)
record
=
result
.
single
()
return
record
[
"
id_1
"
],
record
[
"
id_2
"
]
...
...
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