Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Manifest Ingestion DAG
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
OSDU
OSDU Data Platform
Data Flow
Data Ingestion
Manifest Ingestion DAG
Commits
d1bca150
Commit
d1bca150
authored
4 years ago
by
Dmitrii Valuiskii (EPAM)
Committed by
Siarhei Khaletski (EPAM)
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
GONRG-1726: remove ids autogeneration
parent
558d0d1e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Fix for pre-defined Ids and autogenerated Ids
Pipeline
#24795
passed
4 years ago
Stage: linters
Stage: unit_tests
Stage: test_dags
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dags/libs/process_manifest_r3.py
+4
-17
4 additions, 17 deletions
src/dags/libs/process_manifest_r3.py
tests/plugin-unit-tests/test_manifest_processor_r3.py
+0
-34
0 additions, 34 deletions
tests/plugin-unit-tests/test_manifest_processor_r3.py
with
4 additions
and
51 deletions
src/dags/libs/process_manifest_r3.py
+
4
−
17
View file @
d1bca150
...
...
@@ -49,7 +49,6 @@ class ManifestProcessor(HeadersMixin):
"
legal
"
:
{},
"
acl
"
:
{},
"
kind
"
:
""
,
"
id
"
:
""
,
"
data
"
:
{}
}
...
...
@@ -107,20 +106,6 @@ class ManifestProcessor(HeadersMixin):
logger
.
error
(
f
"
Unhandled exception while uploading
{
file_path
}
:
{
e
}
"
)
return
file_record
def
generate_id
(
self
,
manifest_fragment
:
dict
)
->
str
:
"""
Generate id to use it in Storage.
:param manifest_fragment: The manifest to update
:type manifest_fragment: dict
:return: The generated id
:rtype: str
"""
group_type
=
manifest_fragment
.
get
(
"
groupType
"
,
"
doc
"
)
kind
=
manifest_fragment
.
get
(
"
kind
"
)
kind_name
=
self
.
_get_kind_name
(
kind
)
_id
=
f
"
{
self
.
context
.
data_partition_id
}
:
{
group_type
}
_
{
kind_name
}
:
{
str
(
uuid
.
uuid4
())
}
"
return
_id
def
populate_manifest_storage_record
(
self
,
manifest
:
dict
)
->
dict
:
"""
Create a record from manifest to store it in Storage service.
...
...
@@ -130,7 +115,8 @@ class ManifestProcessor(HeadersMixin):
:rtype: dict
"""
record
=
copy
.
deepcopy
(
self
.
RECORD_TEMPLATE
)
record
[
"
id
"
]
=
manifest
[
"
id
"
]
if
manifest
.
get
(
"
id
"
)
else
self
.
generate_id
(
manifest
)
if
manifest
.
get
(
"
id
"
):
record
[
"
id
"
]
=
manifest
[
"
id
"
]
record
[
"
kind
"
]
=
manifest
.
pop
(
"
kind
"
)
record
[
"
legal
"
]
=
manifest
.
pop
(
"
legal
"
)
record
[
"
acl
"
]
=
manifest
.
pop
(
"
acl
"
)
...
...
@@ -146,7 +132,8 @@ class ManifestProcessor(HeadersMixin):
:rtype: dict
"""
record
=
copy
.
deepcopy
(
self
.
RECORD_TEMPLATE
)
record
[
"
id
"
]
=
manifest
[
"
id
"
]
if
manifest
.
get
(
"
id
"
)
else
self
.
generate_id
(
manifest
)
if
manifest
.
get
(
"
id
"
):
record
[
"
id
"
]
=
manifest
[
"
id
"
]
record
[
"
kind
"
]
=
manifest
.
pop
(
"
kind
"
)
record
[
"
legal
"
]
=
manifest
.
pop
(
"
legal
"
)
record
[
"
acl
"
]
=
manifest
.
pop
(
"
acl
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/plugin-unit-tests/test_manifest_processor_r3.py
+
0
−
34
View file @
d1bca150
...
...
@@ -97,7 +97,6 @@ class TestManifestProcessor:
source_file_checker
=
source_file_checker
,
)
monkeypatch
.
setattr
(
manifest_processor
,
"
generate_id
"
,
lambda
manifest
:
"
test_id
"
)
monkeypatch
.
setattr
(
file_handler
,
"
upload_file
"
,
lambda
*
args
,
**
kwargs
:
"
/test/source_file
"
)
monkeypatch
.
setattr
(
file_handler
,
"
save_file_record
"
,
...
...
@@ -233,36 +232,3 @@ class TestManifestProcessor:
for
manifest_part
in
manifest_processor
.
manifest_records
:
kind
=
manifest_part
[
"
entity
"
][
"
kind
"
]
assert
expected_kind_name
==
manifest_processor
.
_get_kind_name
(
kind
)
@pytest.mark.parametrize
(
"
conf_path,expected_kind_name,traversal_manifest_file
"
,
[
pytest
.
param
(
MANIFEST_WELLBORE_VALID_PATH
,
"
Wellbore
"
,
TRAVERSAL_WELLBORE_VALID_PATH
,
id
=
"
Valid Wellbore
"
),
]
)
def
test_generate_id
(
self
,
monkeypatch
,
conf_path
:
str
,
traversal_manifest_file
:
str
,
expected_kind_name
:
str
):
with
open
(
conf_path
)
as
f
:
conf
=
json
.
load
(
f
)
with
open
(
traversal_manifest_file
)
as
f
:
manifest_file
=
json
.
load
(
f
)
manifest_records
=
manifest_file
context
=
process_manifest_r3
.
Context
.
populate
(
conf
)
manifest_processor
=
process_manifest_r3
.
ManifestProcessor
(
storage_url
=
""
,
manifest_records
=
manifest_records
,
token_refresher
=
AirflowTokenRefresher
(),
context
=
context
,
file_handler
=
FileHandler
(
"
test
"
,
AirflowTokenRefresher
(),
context
),
source_file_checker
=
SourceFileChecker
()
)
for
manifest_part
in
manifest_processor
.
manifest_records
:
group_type
=
manifest_part
[
"
entity
"
][
"
groupType
"
]
kind_name
=
manifest_processor
.
_get_kind_name
(
manifest_part
[
"
entity
"
][
"
kind
"
])
generated_id
=
manifest_processor
.
generate_id
(
manifest_part
[
"
entity
"
])
assert
generated_id
.
startswith
(
f
"
{
TENANT
}
:
{
group_type
}
_
{
kind_name
}
:
"
)
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