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
e59469e5
Commit
e59469e5
authored
3 years ago
by
Yan Sushchynski (EPAM)
Committed by
Siarhei Khaletski (EPAM)
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
GONRG-2142: Add lru cache
parent
a38a7d4c
No related branches found
No related tags found
1 merge request
!46
GONRG-2142: Add lru cache
Pipeline
#38141
passed
3 years ago
Stage: linters
Stage: unit_tests
Stage: test_dags
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dags/libs/validation/validate_schema.py
+11
-2
11 additions, 2 deletions
src/dags/libs/validation/validate_schema.py
tests/plugin-unit-tests/test_operators_r3.py
+2
-0
2 additions, 0 deletions
tests/plugin-unit-tests/test_operators_r3.py
with
13 additions
and
2 deletions
src/dags/libs/validation/validate_schema.py
+
11
−
2
View file @
e59469e5
...
...
@@ -17,18 +17,20 @@
import
copy
import
logging
from
functools
import
lru_cache
from
typing
import
Any
,
List
,
Union
,
Tuple
,
Union
import
jsonschema
import
requests
import
tenacity
from
jsonschema
import
exceptions
from
libs.constants
import
DATA_SECTION
,
DATASETS_SECTION
,
MASTER_DATA_SECTION
,
\
REFERENCE_DATA_SECTION
,
WORK_PRODUCT_SECTION
,
WORK_PRODUCT_COMPONENTS_SECTION
from
libs.context
import
Context
from
libs.exceptions
import
GenericManifestSchemaError
,
EntitySchemaValidationError
from
libs.traverse_manifest
import
ManifestEntity
from
libs.mixins
import
HeadersMixin
from
libs.traverse_manifest
import
ManifestEntity
from
osdu_api.libs.auth.authorization
import
TokenRefresher
,
authorize
logger
=
logging
.
getLogger
()
...
...
@@ -70,7 +72,8 @@ class OSDURefResolver(jsonschema.RefResolver):
:rtype: dict
"""
document
=
super
().
resolve_fragment
(
document
,
fragment
)
fragment_parts
=
fragment
.
split
(
"
/
"
)
# /definitions/<OsduID> -> [..., <OsduID>]
# /definitions/<OsduID> -> [..., <OsduID>]
fragment_parts
=
fragment
.
split
(
"
/
"
)
if
len
(
fragment_parts
)
>
1
:
document
.
pop
(
"
$id
"
,
None
)
return
document
...
...
@@ -146,9 +149,15 @@ class SchemaValidator(HeadersMixin):
response
[
"
$id
"
]
=
uri
return
response
@lru_cache
()
def
get_schema
(
self
,
kind
:
str
)
->
Union
[
dict
,
None
]:
"""
Fetch schema from Schema service.
Implies that the cache is a one-off.
@TODO lru_cache should be replaced by generic cache mechanism to work with providers
solutions
:param kind: The kind of the scheema to fetch
:type kind: str
:raises e: Generic exception
...
...
This diff is collapsed.
Click to expand it.
tests/plugin-unit-tests/test_operators_r3.py
+
2
−
0
View file @
e59469e5
...
...
@@ -29,6 +29,7 @@ sys.path.append(f"{os.getenv('AIRFLOW_SRC_DIR')}/dags")
from
libs.exceptions
import
PipelineFailedError
import
pytest
import
requests
from
functools
import
lru_cache
from
file_paths
import
(
MANIFEST_WELLBORE_VALID_PATH
,
...
...
@@ -80,6 +81,7 @@ class TestOperators(object):
def
test_process_manifest_r3_operator
(
self
,
monkeypatch
):
@lru_cache
()
def
_get_common_schema
(
*
args
,
**
kwargs
):
with
open
(
MANIFEST_GENERIC_SCHEMA_PATH
)
as
f
:
manifest_schema
=
json
.
load
(
f
)
...
...
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