Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Data Logistics Service
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
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
eFlows4HPC WP2
Data Logistics Service
Commits
f0be852d
Commit
f0be852d
authored
2 years ago
by
Jedrzej Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
upload fixes: no draft link, and full url return
parent
bc7fe7eb
No related branches found
No related tags found
No related merge requests found
Pipeline
#99716
passed
2 years ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dags/uploadflow.py
+6
-11
6 additions, 11 deletions
dags/uploadflow.py
with
6 additions
and
11 deletions
dags/uploadflow.py
+
6
−
11
View file @
f0be852d
...
...
@@ -7,13 +7,12 @@ from airflow.decorators import dag, task
from
airflow.models
import
Variable
from
airflow.models.connection
import
Connection
from
airflow.operators.python
import
PythonOperator
from
airflow.providers.http.hooks.http
import
HttpHook
from
airflow.utils.dates
import
days_ago
from
b2shareoperator
import
(
add_file
,
create_draft_record
,
get_community
,
submit_draft
)
from
decors
import
get_connection
,
remove
,
setup
from
just_reg
import
get_parameter
,
get_record
from
just_reg
import
get_parameter
from
datacat_integration.hooks
import
DataCatalogHook
from
datacat_integration.connection
import
DataCatalogEntry
...
...
@@ -80,16 +79,12 @@ def upload_example():
hook
=
DataCatalogHook
()
print
(
"
Connected to datacat via hook
"
,
hook
.
list_type
(
'
dataset
'
)
)
print
(
"
Connected to datacat via hook
"
)
entry
=
json
.
loads
(
hook
.
get_entry
(
datacat_type
=
'
storage_target
'
,
oid
=
mid
))
#hook = HttpHook(http_conn_id='datacat', method='GET')
#hrespo = hook.run(endpoint=f"storage_target/{mid}").json()['metadata']
print
(
'
Got following metadata
'
,
entry
)
template
=
create_template
(
hrespo
=
entry
[
'
metadata
'
])
community
=
get_community
(
server
=
server
,
community_id
=
template
[
'
community
'
])
community
=
get_community
(
server
=
server
,
community_id
=
template
[
'
community
'
])
if
not
community
:
print
(
"
Not existing community
"
)
return
-
1
...
...
@@ -115,7 +110,7 @@ def upload_example():
submitted
=
submit_draft
(
record
=
r
,
token
=
token
)
print
(
f
"
Record created
{
submitted
}
"
)
return
submitted
[
'
links
'
][
'
self
'
]
return
submitted
[
'
links
'
][
'
publication
'
]
@task
()
def
register
(
object_url
,
**
kwargs
):
...
...
@@ -128,11 +123,11 @@ def upload_example():
print
(
"
Connected to datacat via hook
"
,
hook
.
list_type
(
'
dataset
'
))
entry
=
DataCatalogEntry
(
name
=
f
"
DLS results
{
kwargs
[
'
run_id
'
]
}
"
,
url
=
object_url
,
url
=
object_url
,
metadata
=
{
"
author
"
:
"
DLS on behalf of eFlows
"
,
"
access
"
:
"
hook-based
"
}
)
)
try
:
r
=
hook
.
create_entry
(
datacat_type
=
'
dataset
'
,
entry
=
entry
)
print
(
"
Hook registration returned:
"
,
r
)
...
...
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