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
ed7d2d91
Commit
ed7d2d91
authored
3 years ago
by
Yan Sushchynski (EPAM)
Browse files
Options
Downloads
Patches
Plain Diff
GONRG-2320: Switch file handler API to v2
parent
754ce67e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!56
GONRG-2320: Switch file handler API to v2
Pipeline
#43386
passed
3 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/handle_file.py
+3
-3
3 additions, 3 deletions
src/dags/libs/handle_file.py
tests/plugin-unit-tests/test_file_handler.py
+3
-3
3 additions, 3 deletions
tests/plugin-unit-tests/test_file_handler.py
with
6 additions
and
6 deletions
src/dags/libs/handle_file.py
+
3
−
3
View file @
ed7d2d91
...
...
@@ -148,7 +148,7 @@ class FileHandler(HeadersMixin):
:rtype: FileUploadUrlResponse
"""
logger
.
debug
(
"
Getting upload signed url.
"
)
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
1
/files/uploadURL
"
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
2
/files/uploadURL
"
response
=
self
.
_send_get_request
(
headers
,
endpoint
).
json
()
logger
.
debug
(
"
Signed url got.
"
)
upload_url_response
=
FileUploadUrlResponse
(
file_id
=
response
[
"
FileID
"
],
...
...
@@ -168,7 +168,7 @@ class FileHandler(HeadersMixin):
:rtype: FileDownloadUrlResponse
"""
logger
.
debug
(
"
Getting download signed url.
"
)
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
1
/files/
{
record_id
}
/downloadURL
"
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
2
/files/
{
record_id
}
/downloadURL
"
response
=
self
.
_send_get_request
(
headers
,
endpoint
).
json
()
logger
.
debug
(
"
Signed url got.
"
)
download_url_response
=
self
.
_handle_download_url_response
(
response
)
...
...
@@ -269,7 +269,7 @@ class FileHandler(HeadersMixin):
f
"
surrogate_name_
{
file_record
[
'
data
'
][
'
DatasetProperties
'
][
'
FileSourceInfo
'
][
'
PreloadFilePath
'
].
split
(
'
/
'
)[
-
1
]
}
"
logger
.
info
(
f
"
Generated name:
{
file_record
[
'
data
'
][
'
Name
'
]
}
"
)
logger
.
info
(
"
Sending file record metadata to File service
"
)
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
1
/files/metadata
"
endpoint
=
f
"
{
self
.
_file_service_host
}
/v
2
/files/metadata
"
response
=
self
.
_send_post_request
(
self
.
request_headers
,
endpoint
,
json
.
dumps
(
file_record
))
return
response
.
json
()[
"
id
"
]
...
...
This diff is collapsed.
Click to expand it.
tests/plugin-unit-tests/test_file_handler.py
+
3
−
3
View file @
ed7d2d91
...
...
@@ -91,7 +91,7 @@ class TestFileHandler:
"
unsignedUrl
"
:
test_permanent_location
,
"
kind
"
:
"
test_kind
"
}
responses
.
add
(
responses
.
GET
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
1
/files/
{
test_record_id
}
/downloadURL
"
,
responses
.
add
(
responses
.
GET
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
2
/files/
{
test_record_id
}
/downloadURL
"
,
json
=
json_response
,
status
=
http
.
HTTPStatus
.
OK
)
assert
test_permanent_location
==
file_handler
.
get_file_permanent_location
(
test_record_id
)
...
...
@@ -106,7 +106,7 @@ class TestFileHandler:
def
test_get_file_permanent_location_error
(
self
,
file_handler
:
FileHandler
,
http_status
:
str
,
reason
:
str
):
test_record_id
=
"
test_record_id
"
responses
.
add
(
responses
.
GET
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
1
/files/
{
test_record_id
}
/downloadURL
"
,
responses
.
add
(
responses
.
GET
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
2
/files/
{
test_record_id
}
/downloadURL
"
,
status
=
http_status
,
body
=
reason
)
with
pytest
.
raises
((
tenacity
.
RetryError
,
requests
.
exceptions
.
HTTPError
)):
...
...
@@ -124,7 +124,7 @@ class TestFileHandler:
file_record
,
unused_wpc_record
,
unused_wp_record
=
json
.
load
(
cf
)
test_record_id
=
"
test_record_id
"
responses
.
add
(
responses
.
POST
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
1
/files/metadata
"
,
responses
.
add
(
responses
.
POST
,
f
"
{
self
.
BASE_TEST_HOST
}
/v
2
/files/metadata
"
,
json
=
{
"
id
"
:
test_record_id
},
status
=
http
.
HTTPStatus
.
OK
)
assert
test_record_id
==
file_handler
.
save_file_record
(
file_record
)
...
...
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