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
03cb6f4e
Commit
03cb6f4e
authored
3 years ago
by
Jedrzej Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
working with datacat hook
parent
f4bdf0ae
No related branches found
No related tags found
No related merge requests found
Pipeline
#97098
passed
3 years ago
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dags/just_reg.py
+1
-1
1 addition, 1 deletion
dags/just_reg.py
dags/uploadflow.py
+14
-8
14 additions, 8 deletions
dags/uploadflow.py
with
15 additions
and
9 deletions
dags/just_reg.py
+
1
−
1
View file @
03cb6f4e
...
...
@@ -80,7 +80,7 @@ def datacat_registration_example():
print
(
entry
)
print
(
entry
[
'
metadata
'
])
print
(
'
---
'
)
print
(
get
_template
(
entry
[
'
metadata
'
]))
print
(
create
_template
(
entry
[
'
metadata
'
]))
...
...
This diff is collapsed.
Click to expand it.
dags/uploadflow.py
+
14
−
8
View file @
03cb6f4e
import
os
import
tempfile
from
urllib.parse
import
urljoi
n
import
jso
n
from
airflow.decorators
import
dag
,
task
from
airflow.models
import
Variable
...
...
@@ -78,12 +78,18 @@ def upload_example():
params
=
kwargs
[
'
params
'
]
mid
=
params
[
'
mid
'
]
hook
=
HttpHook
(
http_conn_id
=
'
datacat
'
,
method
=
'
GET
'
)
hrespo
=
hook
.
run
(
endpoint
=
f
"
storage_target/
{
mid
}
"
).
json
()[
'
metadata
'
]
print
(
hrespo
)
template
=
create_template
(
hrespo
=
hrespo
)
community
=
get_community
(
server
=
server
,
community_id
=
template
[
'
community
'
])
hook
=
DataCatalogHook
()
print
(
"
Connected to datacat via hook
"
,
hook
.
list_type
(
'
dataset
'
))
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
'
])
if
not
community
:
print
(
"
Not existing community
"
)
return
-
1
...
...
@@ -129,7 +135,7 @@ def upload_example():
)
try
:
r
=
hook
.
create_entry
(
datacat_type
=
'
dataset
'
,
entry
=
entry
)
print
(
"
Hook registration returned:
"
,
r
,
urljoin
(
hook
.
connection
.
url
,
r
)
)
print
(
"
Hook registration returned:
"
,
r
)
return
r
except
ConnectionError
as
e
:
print
(
'
Registration failed
'
,
e
)
...
...
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