Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Airflow Datacat Integration
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
Airflow Datacat Integration
Commits
4d7df92e
Commit
4d7df92e
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
move function from hooks to connection to prevent circular dependencies on import hooks
parent
3b640fde
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/datacat_integration/connection.py
+28
-1
28 additions, 1 deletion
src/datacat_integration/connection.py
src/datacat_integration/hooks.py
+1
-28
1 addition, 28 deletions
src/datacat_integration/hooks.py
with
29 additions
and
29 deletions
src/datacat_integration/connection.py
+
28
−
1
View file @
4d7df92e
from
typing
import
Dict
from
typing
import
Dict
,
Any
import
uuid
import
json
from
urllib.parse
import
urljoin
from
airflow.models.connection
import
Connection
import
requests
def
get_connection_from_entry
(
data
:
Dict
[
str
,
Any
],
datacat_type
:
str
,
oid
:
str
)
->
Connection
:
"""
returns an airflow connection from the data provided in the datacat entry.
"""
conn_type
=
data
[
'
metadata
'
][
'
conn_type
'
]
host
=
data
[
'
metadata
'
][
'
host
'
]
port
=
data
[
'
metadata
'
][
'
port
'
]
schema
=
data
[
'
metadata
'
][
'
schema
'
]
conn_id
=
f
"
{
datacat_type
}
/
{
oid
}
-connection
"
# set all remaining metadata as extra
extra
=
{}
for
key
in
data
[
'
metadata
'
].
keys
():
if
key
in
[
'
conn_type
'
,
'
host
'
,
'
port
'
,
'
schema
'
]:
continue
extra
[
key
]
=
data
[
'
metadata
'
][
key
]
return
Connection
(
conn_id
=
conn_id
,
conn_type
=
conn_type
,
host
=
host
,
port
=
port
,
description
=
"
Automatically generated Connection for the given entry.
"
,
schema
=
schema
,
extra
=
extra
)
class
DataCatalogEntry
:
"""
A datatype representing an entry in the datacatalog.
"""
name
:
str
=
""
...
...
This diff is collapsed.
Click to expand it.
src/datacat_integration/hooks.py
+
1
−
28
View file @
4d7df92e
from
typing
import
Any
from
urllib.parse
import
urljoin
from
airflow.providers.http.hooks.http
import
HttpHook
from
airflow
import
settings
from
airflow.models.connection
import
Connection
from
requests.sessions
import
session
from
requests
import
Session
from
typing
import
Optional
,
Dict
from
datacat_integration.connection
import
DataCatConnection
,
DataCatalogEntry
from
datacat_integration.connection
import
DataCatConnection
,
DataCatalogEntry
,
get_connection_from_entry
from
datacat_integration.auth
import
BearerAuth
def
get_connection_from_entry
(
data
:
Dict
[
str
,
Any
],
datacat_type
:
str
,
oid
:
str
)
->
Connection
:
"""
returns an airflow connection from the data provided in the datacat entry.
"""
conn_type
=
data
[
'
metadata
'
][
'
conn_type
'
]
host
=
data
[
'
metadata
'
][
'
host
'
]
port
=
data
[
'
metadata
'
][
'
port
'
]
schema
=
data
[
'
metadata
'
][
'
schema
'
]
conn_id
=
f
"
{
datacat_type
}
/
{
oid
}
-connection
"
# set all remaining metadata as extra
extra
=
{}
for
key
in
data
[
'
metadata
'
].
keys
():
if
key
in
[
'
conn_type
'
,
'
host
'
,
'
port
'
,
'
schema
'
]:
continue
extra
[
key
]
=
data
[
'
metadata
'
][
key
]
return
Connection
(
conn_id
=
conn_id
,
conn_type
=
conn_type
,
host
=
host
,
port
=
port
,
description
=
"
Automatically generated Connection for the given entry.
"
,
schema
=
schema
,
extra
=
extra
)
class
DataCatalogHook
(
HttpHook
):
connection
:
DataCatConnection
=
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