Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GraphDeployer
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
scripts
GraphDeployer
Commits
65de903b
Commit
65de903b
authored
Dec 15, 2022
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Deploy only changed graphs
parent
e743de50
Branches
Branches containing commit
No related tags found
1 merge request
!9
Fix: Deploy only changed graphs
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/GraphDeployer/Program.cs
+44
-9
44 additions, 9 deletions
src/GraphDeployer/Program.cs
with
44 additions
and
9 deletions
src/GraphDeployer/Program.cs
+
44
−
9
View file @
65de903b
...
@@ -90,14 +90,39 @@ public class Program
...
@@ -90,14 +90,39 @@ public class Program
// Graph Insertion
// Graph Insertion
var
queries
=
new
List
<
string
>();
var
queries
=
new
List
<
string
>();
var
turtleFiles
=
Directory
.
GetFiles
(
WorkingFolder
,
"*.ttl"
,
SearchOption
.
AllDirectories
);
var
turtleFiles
=
Directory
.
GetFiles
(
WorkingFolder
,
"*.ttl"
,
SearchOption
.
AllDirectories
);
foreach
(
var
file
in
turtleFiles
)
var
graphAccumulation
=
new
Dictionary
<
Uri
,
(
Graph
,
List
<
string
>)>();
Array
.
ForEach
(
turtleFiles
,
(
file
)
=>
{
{
var
fileInfo
=
new
FileInfo
(
file
);
var
graph
=
new
Graph
();
var
graph
=
new
Graph
();
graph
.
LoadFromFile
(
file
);
graph
.
LoadFromFile
(
file
);
var
graphName
=
graph
.
BaseUri
.
ToString
();
if
(
graphAccumulation
.
ContainsKey
(
graph
.
BaseUri
))
{
graphAccumulation
[
graph
.
BaseUri
].
Item1
.
Merge
(
graph
);
graphAccumulation
[
graph
.
BaseUri
].
Item2
.
Add
(
file
);
}
else
{
graphAccumulation
.
Add
(
graph
.
BaseUri
,
(
graph
,
new
List
<
string
>()
{
file
}));
}
});
if
(
_rdfStoreConnector
.
HasGraph
(
graphName
))
foreach
(
var
kv
in
graphAccumulation
)
{
var
graph
=
kv
.
Value
.
Item1
;
var
graphName
=
kv
.
Key
.
ToString
();
var
currentGraph
=
_rdfStoreConnector
.
GetGraph
(
graphName
);
var
graphWasChanged
=
graph
.
Triples
.
Count
!=
currentGraph
.
Triples
.
Count
||
graph
.
Triples
.
Any
((
triple
)
=>
!
currentGraph
.
Triples
.
Any
((
currentTriple
)
=>
(
triple
.
Subject
.
Equals
(
currentTriple
.
Subject
)
||
(
triple
.
Subject
.
NodeType
==
NodeType
.
Blank
&&
currentTriple
.
Subject
.
NodeType
==
NodeType
.
Blank
)
&&
triple
.
Predicate
.
Equals
(
currentTriple
.
Predicate
)
&&
triple
.
Object
.
Equals
(
currentTriple
.
Object
)
||
(
triple
.
Object
.
NodeType
==
NodeType
.
Blank
&&
currentTriple
.
Object
.
NodeType
==
NodeType
.
Blank
))));
if
(
graphWasChanged
)
{
if
(!
currentGraph
.
IsEmpty
)
{
{
_rdfStoreConnector
.
ClearGraph
(
graphName
);
_rdfStoreConnector
.
ClearGraph
(
graphName
);
_logger
.
LogInformation
(
"Cleared Graph {graphName}"
,
graphName
);
_logger
.
LogInformation
(
"Cleared Graph {graphName}"
,
graphName
);
...
@@ -107,8 +132,18 @@ public class Program
...
@@ -107,8 +132,18 @@ public class Program
_logger
.
LogInformation
(
"No Graph {graphName}"
,
graphName
);
_logger
.
LogInformation
(
"No Graph {graphName}"
,
graphName
);
}
}
foreach
(
var
file
in
kv
.
Value
.
Item2
)
{
var
fileInfo
=
new
FileInfo
(
file
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
}
}
}
else
{
_logger
.
LogInformation
(
"Skipping {graphName}"
,
graphName
);
}
}
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
...
...
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