Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
7ae53c20
Commit
7ae53c20
authored
1 year ago
by
Charlotte Hausman
Browse files
Options
Downloads
Patches
Plain Diff
tweaking wresters
parent
b7c71e46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1605
Merge 2.8.2.3 work to main
,
!1521
tweaking wresters
Pipeline
#12821
passed
1 year ago
Stage: pull-db
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py
+36
-8
36 additions, 8 deletions
apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py
apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
+4
-1
4 additions, 1 deletion
apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
with
40 additions
and
9 deletions
apps/cli/utilities/aat_wrest/aat_wrest/metadata_wrester.py
+
36
−
8
View file @
7ae53c20
...
...
@@ -366,7 +366,22 @@ class WrestWorkflowMetadata:
make_json
=
{}
try
:
cursor
=
self
.
conn
.
cursor
()
cursor
.
execute
(
query
,
{
"
spl
"
:
self
.
spl
[
0
]})
spl
=
self
.
spl
[
0
]
if
self
.
spl
[
0
].
isdigit
():
spl_query
=
"""
SELECT science_product_locator
FROM science_products_product_groups
WHERE product_group_id = %(pg_id)s;
"""
cursor
.
execute
(
spl_query
,
{
"
pg_id
"
:
self
.
spl
[
0
]})
data
=
cursor
.
fetchall
()
if
data
:
spl
=
data
[
0
][
0
]
else
:
self
.
logger
.
error
(
f
"
ERROR: Failed to determine SPL from product group id, got
{
data
}
"
)
return
make_json
cursor
.
execute
(
query
,
{
"
spl
"
:
spl
})
data
=
cursor
.
fetchall
()
if
data
:
make_json
=
json
.
dumps
(
...
...
@@ -379,7 +394,7 @@ class WrestWorkflowMetadata:
else
:
self
.
logger
.
error
(
f
"
ERROR: aat-wrest query returned no results!
"
f
"
The database appears to be missing information for spl id
{
s
elf
.
spl
[
0
]
}
!
"
f
"
The database appears to be missing information for spl id
{
s
pl
}
!
"
)
finally
:
self
.
conn
.
close
()
...
...
@@ -399,25 +414,25 @@ class WrestWorkflowMetadata:
product_group_id
=
self
.
spl
[
0
]
else
:
# We were given an SPL, need to get the associated product group ID
prod_id_query
=
f
"""
prod_id_query
=
"""
SELECT product_group_id
FROM science_products_product_groups
WHERE science_product_locator =
'
{
self
.
spl
[
0
]
}
'
;
WHERE science_product_locator =
%(spl)s
;
"""
cursor
.
execute
(
prod_id_query
)
cursor
.
execute
(
prod_id_query
,
{
"
spl
"
:
self
.
spl
[
0
]}
)
data
=
cursor
.
fetchall
()
if
data
:
product_group_id
=
data
[
0
][
0
]
else
:
self
.
logger
.
error
(
f
"
ERROR: Failed to fetch product group id from SPL, got
{
data
}
"
)
files_query
=
f
"""
files_query
=
"""
WITH product_locators AS (
SELECT sp.science_product_locator,
ap.ancillary_product_locator
FROM science_products_product_groups sp
JOIN ancillary_products ap ON sp.product_group_id = ap.product_group_id
WHERE sp.product_group_id =
'
{
product_group
_id
}
'
WHERE sp.product_group_id =
%(pg
_id
)s
), filegroups AS (
SELECT ap2.filegroup_id
FROM ancillary_products ap2
...
...
@@ -432,7 +447,7 @@ class WrestWorkflowMetadata:
JOIN filegroups fg ON f.filegroup = fg.filegroup_id
"""
if
product_group_id
!=
""
:
cursor
.
execute
(
files_query
)
cursor
.
execute
(
files_query
,
{
"
pg_id
"
:
product_group_id
}
)
data
=
cursor
.
fetchall
()
if
data
:
# This should have all the ancillary and science product names
...
...
@@ -442,6 +457,19 @@ class WrestWorkflowMetadata:
self
.
logger
.
error
(
f
"
ERROR: Failed to fetch products from product ID
{
product_group_id
}
"
)
else
:
self
.
logger
.
error
(
f
"
ERROR: Failed to get product group ID
"
)
input_group_query
=
"""
SELECT DISTINCT s.science_product_locator
FROM product_groups pg2
JOIN science_products_product_groups sppg on pg2.product_group_id = sppg.product_group_id
JOIN science_products_product_groups s on pg2.parent_product_group_id = s.product_group_id
WHERE sppg.product_group_id = %(pg_id)s;
"""
cursor
.
execute
(
input_group_query
,
{
"
pg_id
"
:
product_group_id
})
input_data
=
cursor
.
fetchall
()
if
input_data
:
input_info
=
json
.
dumps
({
"
input_group_locator
"
:
input_data
[
0
][
0
]})
make_json
=
{
**
make_json
,
**
input_info
}
finally
:
self
.
conn
.
close
()
return
make_json
This diff is collapsed.
Click to expand it.
apps/cli/utilities/aat_wrest/aat_wrest/wrest.py
+
4
−
1
View file @
7ae53c20
...
...
@@ -160,7 +160,10 @@ def determine_wrester(connection: MDDBConnector, args: argparse.Namespace):
elif
args
.
curator
:
data
=
WrestWorkflowMetadata
(
connection
,
spl
=
args
.
curator
).
wrest_curator
()
elif
args
.
curator_products
:
data
=
WrestWorkflowMetadata
(
connection
,
spl
=
args
.
curator_products
).
wrest_curator_products
()
general_data
=
WrestWorkflowMetadata
(
connection
,
spl
=
args
.
curator_products
).
wrest_curator
()
connection2
=
MDDBConnector
()
product_data
=
WrestWorkflowMetadata
(
connection2
,
spl
=
args
.
curator_products
).
wrest_curator_products
()
data
=
{
**
general_data
,
**
product_data
}
else
:
data
=
None
...
...
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