Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsm-orchestration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UFZ TSM
tsm-orchestration
Commits
0a600f68
Commit
0a600f68
authored
10 months ago
by
Joost Hemmen
Browse files
Options
Downloads
Patches
Plain Diff
fix par pat, allow par pat to be null, ...
parent
ba9e610f
No related branches found
No related tags found
1 merge request
!161
added filename_pattern to s3map DB
Pipeline
#391011
passed
10 months ago
Stage: integration
Stage: end-to-end
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dispatcher/s3_to_db.sh
+2
-2
2 additions, 2 deletions
dispatcher/s3_to_db.sh
migrations/s3map_add_parser_and_filenamepattern.py
+10
-11
10 additions, 11 deletions
migrations/s3map_add_parser_and_filenamepattern.py
with
12 additions
and
13 deletions
dispatcher/s3_to_db.sh
+
2
−
2
View file @
0a600f68
...
...
@@ -17,8 +17,8 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
"thing_uuid" uuid NOT NULL,
"thing_name" varchar(256) NOT NULL,
"db_url" varchar(256) NOT NULL,
"filename_pattern" varchar(256)
NOT NULL
,
"parser" varchar(256)
NOT NULL
"filename_pattern" varchar(256),
"parser" varchar(256)
);
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA
$S3MAP_POSTGRES_USER
TO
$S3MAP_POSTGRES_USER
;
...
...
This diff is collapsed.
Click to expand it.
migrations/s3map_add_parser_and_filenamepattern.py
+
10
−
11
View file @
0a600f68
...
...
@@ -25,11 +25,6 @@ ALTER_TABLE_SQL = (
)
FETCH_THING_IDS
=
"
SELECT distinct thing_uuid FROM s3map.mapping
"
FETCH_THING_IDS2
=
"
SELECT distinct thing_uuid FROM mapping
"
ADD_CONSTRAINS_SQL
=
(
"
ALTER TABLE s3map.mapping
"
"
ALTER COLUMN filename_pattern SET NOT NULL,
"
"
ALTER COLUMN parser SET NOT NULL
"
)
GET_PATTERN_PARSER_BY_THING_ID
=
()
...
...
@@ -54,10 +49,10 @@ Example:
def
get_parser_and_pattern
(
cur
,
thing_id
):
return
cur
.
execute
(
"
SELECT th.sftp_filename_pattern
, pt.name FROM frontenddb.
tsm_thing th
"
"
JOIN
frontenddb.
tsm_thing_parser t2p ON th.id = t2p.thing_id
"
"
JOIN
frontenddb.
tsm_parser p ON t2p.parser_id = p.id
"
"
JOIN
frontenddb.
tsm_parsertype pt on p.type_id = pt.id
"
"
SELECT
pt.name,
th.sftp_filename_pattern
FROM
tsm_thing th
"
"
JOIN tsm_thing_parser t2p ON th.id = t2p.thing_id
"
"
JOIN tsm_parser p ON t2p.parser_id = p.id
"
"
JOIN tsm_parsertype pt on p.type_id = pt.id
"
"
WHERE th.thing_id = %s
"
,
(
thing_id
,),
).
fetchone
()
...
...
@@ -79,6 +74,7 @@ if __name__ == "__main__":
sys
.
exit
(
1
)
with
psycopg
.
connect
(
sys
.
argv
[
1
])
as
s3
,
psycopg
.
connect
(
sys
.
argv
[
2
])
as
fe
:
early_exit
=
False
with
s3
.
cursor
()
as
c
:
for
col
in
[
"
filename_pattern
"
,
"
parser
"
]:
if
has_column
(
c
,
"
mapping
"
,
col
):
...
...
@@ -94,7 +90,10 @@ if __name__ == "__main__":
thing_ids
=
wc
.
execute
(
FETCH_THING_IDS
).
fetchall
()
for
thing_id
in
thing_ids
:
thing_id
=
thing_id
[
0
]
par
,
pat
=
get_parser_and_pattern
(
rc
,
thing_id
)
pp
=
get_parser_and_pattern
(
rc
,
thing_id
)
if
pp
is
None
:
par
=
pat
=
None
else
:
par
,
pat
=
pp
update_parser_and_pattern
(
wc
,
thing_id
,
par
,
pat
)
wc
.
execute
(
ADD_CONSTRAINS_SQL
)
s3
.
commit
()
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