Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AmendsenProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaik Janipasha
AmendsenProject
Commits
d046eabf
Unverified
Commit
d046eabf
authored
Nov 08, 2019
by
Tao Feng
Committed by
GitHub
Nov 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Application model to be more generic (#166)
parent
1bd6cd5c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
9 deletions
+20
-9
application.py
databuilder/models/application.py
+5
-2
sample_application.csv
example/sample_data/sample_application.csv
+2
-2
sample_data_loader.py
example/scripts/sample_data_loader.py
+10
-3
setup.py
setup.py
+1
-1
test_application.py
tests/unit/models/test_application.py
+2
-1
No files found.
databuilder/models/application.py
View file @
d046eabf
...
...
@@ -28,14 +28,17 @@ class Application(Neo4jCsvSerializable):
task_id
,
# type: str
dag_id
,
# type: str,
application_url_template
,
# type: str
exec_date
,
# type: str
db_name
=
'hive'
,
# type: str
schema_name
=
''
,
# type: str
table_name
=
''
,
# type: str
exec_date
=
''
,
# type: str
):
# type: (...) -> None
self
.
task
=
task_id
# todo: need to modify this hack
self
.
application_url
=
application_url_template
.
format
(
dag_id
=
dag_id
)
self
.
database
,
self
.
schema
,
self
.
table
=
task_id
.
split
(
'.'
)
self
.
database
,
self
.
schema
,
self
.
table
=
db_name
,
schema_name
,
table_name
self
.
dag
=
dag_id
...
...
example/sample_data/sample_application.csv
View file @
d046eabf
task_id,dag_id,exec_date,application_url_template
hive.test_schema.test_table1,event_test,"2018-05-31T00:00:00","https://airflow_host.net/admin/airflow/tree?dag_id={dag_id}"
task_id,dag_id,exec_date,application_url_template
,db_name,schema_name,table_name
hive.test_schema.test_table1,event_test,"2018-05-31T00:00:00","https://airflow_host.net/admin/airflow/tree?dag_id={dag_id}"
,hive,test_schema,test_table1
example/scripts/sample_data_loader.py
View file @
d046eabf
...
...
@@ -229,17 +229,24 @@ def load_application_data_from_csv(file_name):
'(task_id VARCHAR(64) NOT NULL , '
'dag_id VARCHAR(64) NOT NULL , '
'exec_date VARCHAR(64) NOT NULL, '
'application_url_template VARCHAR(128) NOT NULL)'
)
'application_url_template VARCHAR(128) NOT NULL, '
'db_name VARCHAR(64) NOT NULL, '
'schema_name VARCHAR(64) NOT NULL, '
'table_name VARCHAR(64) NOT NULL)'
)
file_loc
=
'example/sample_data/'
+
file_name
with
open
(
file_loc
,
'r'
)
as
fin
:
dr
=
csv
.
DictReader
(
fin
)
to_db
=
[(
i
[
'task_id'
],
i
[
'dag_id'
],
i
[
'exec_date'
],
i
[
'application_url_template'
])
for
i
in
dr
]
i
[
'application_url_template'
],
i
[
'db_name'
],
i
[
'schema_name'
],
i
[
'table_name'
],)
for
i
in
dr
]
cur
.
executemany
(
"INSERT INTO test_application_metadata (task_id, dag_id, "
"exec_date, application_url_template) VALUES (?, ?, ?, ?);"
,
to_db
)
"exec_date, application_url_template, db_name, schema_name, table_name) "
"VALUES (?, ?, ?, ?, ?, ?, ?);"
,
to_db
)
conn
.
commit
()
...
...
setup.py
View file @
d046eabf
...
...
@@ -2,7 +2,7 @@ import os
from
setuptools
import
setup
,
find_packages
__version__
=
'1.4.1
1
'
__version__
=
'1.4.1
2
'
requirements_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'requirements.txt'
)
...
...
tests/unit/models/test_application.py
View file @
d046eabf
...
...
@@ -16,7 +16,8 @@ class TestApplication(unittest.TestCase):
self
.
application
=
Application
(
task_id
=
'hive.default.test_table'
,
dag_id
=
'event_test'
,
exec_date
=
'2018-05-31T00:00:00'
,
schema_name
=
'default'
,
table_name
=
'test_table'
,
application_url_template
=
'airflow_host.net/admin/airflow/tree?dag_id={dag_id}'
)
self
.
expected_node_result
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment