Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Data Loading
Wellbore DDMS Data Loader
Commits
18a4e5fa
Commit
18a4e5fa
authored
May 04, 2022
by
Ritika Kaushal
Browse files
changes for ibm base url prefix
parent
4bc9dbec
Pipeline
#106970
failed with stages
in 1 minute and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/example_opendes_configuration.json
View file @
18a4e5fa
{
"base_url"
:
"https://osdu-ship.msft-osdu-test.org"
,
"data_partition_id"
:
"opendes"
,
"csp_base_url_prefix"
:
"no"
,
"data_partition_id"
:
"opendes"
,
"legal"
:
{
"legaltags"
:
[
"opendes-public-usa-dataset-7643990"
],
"otherRelevantDataCountries"
:
[
"US"
],
...
...
src/wbdutil/commands/ingest.py
View file @
18a4e5fa
...
...
@@ -30,7 +30,7 @@ def wellbore(
config
=
Configuration
(
LocalFileLoader
(),
config_path
)
las_parser
=
LasParser
(
LocalFileLoader
())
client
=
OsduClient
(
config
.
base_url
,
token
,
config
.
data_partition_id
)
client
=
OsduClient
(
config
.
base_url
,
token
,
config
.
data_partition_id
,
config
.
csp_base_url_prefix
)
service
=
WellBoreService
(
client
,
WellLogService
(
client
))
failed_ingests
=
[]
...
...
src/wbdutil/common/configuration.py
View file @
18a4e5fa
...
...
@@ -71,3 +71,12 @@ class Configuration:
rtype: Dict[str, Any]
"""
return
self
.
_config
.
get
(
"las_file_mapping"
)
@
property
def
csp_base_url_prefix
(
self
)
->
str
:
"""
Gets the csp_base url prefix.
return: the csp base url prefix
rtype: str
"""
return
self
.
_config
.
get
(
"csp_base_url_prefix"
)
src/wbdutil/wrapper/osdu_client.py
View file @
18a4e5fa
...
...
@@ -26,7 +26,7 @@ class DataLoaderWebResponseError(Exception):
class
OsduClient
:
def
__init__
(
self
,
base_url
:
str
,
access_token
:
str
,
data_partition_id
:
str
)
->
None
:
def
__init__
(
self
,
base_url
:
str
,
access_token
:
str
,
data_partition_id
:
str
,
csp_base_url_prefix
:
str
)
->
None
:
"""
Create a new instance of a OsduClient
...
...
@@ -37,7 +37,7 @@ class OsduClient:
self
.
_access_token
=
access_token
self
.
_base_url
=
base_url
self
.
_data_partition_id
=
data_partition_id
self
.
_csp_base_url_prefix
=
csp_base_url_prefix
def
_create_headers
(
self
)
->
Dict
[
str
,
str
]:
"""
Create a new set of auth headers for OSDU
...
...
@@ -58,7 +58,7 @@ class OsduClient:
:return: the id of the new well bore
:rtype: str
"""
return
self
.
_post_data_with_id_response
(
"
/api/os-wellbore-ddms/ddms/v3/wellbores
"
,
record
)
return
self
.
_post_data_with_id_response
(
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/wellbores
'
,
record
)
def
post_welllog
(
self
,
record
:
Union
[
Record
,
WellLogRecord
])
->
List
[
any
]:
"""
...
...
@@ -70,7 +70,7 @@ class OsduClient:
:return: The ID of the created/updated well log
:rtype: List[any]
"""
return
self
.
_post_data_with_id_response
(
"
/api/os-wellbore-ddms/ddms/v3/welllogs
"
,
record
)
return
self
.
_post_data_with_id_response
(
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/welllogs
'
,
record
)
def
get_wellbore_record
(
self
,
wellbore_id
:
str
)
->
Record
:
"""
...
...
@@ -80,7 +80,10 @@ class OsduClient:
:return: the wellbore record
:rtype: Record
"""
get_record_url
=
f
"
{
self
.
_base_url
}
/api/os-wellbore-ddms/ddms/v3/wellbores/
{
wellbore_id
}
"
get_record_url
=
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/wellbores/
{
wellbore_id
}
'
#get_record_url = f"{self._base_url}/api/os-wellbore-ddms/ddms/v3/wellbores/{wellbore_id}"
return
Record
(
self
.
_send_request_json_response
(
"GET"
,
get_record_url
,
None
,
None
))
def
get_welllog_record
(
self
,
welllog_id
:
str
)
->
WellLogRecord
:
...
...
@@ -91,7 +94,8 @@ class OsduClient:
:return: the welllog record
:rtype: WellLogRecord
"""
get_record_url
=
f
"
{
self
.
_base_url
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
"
get_record_url
=
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
'
#get_record_url = f"{self._base_url}/api/os-wellbore-ddms/ddms/v3/welllogs/{welllog_id}"
return
WellLogRecord
(
self
.
_send_request_json_response
(
"GET"
,
get_record_url
,
None
,
None
))
def
add_welllog_data
(
self
,
data
:
DataFrame
,
welllog_id
:
str
)
->
None
:
...
...
@@ -102,7 +106,8 @@ class OsduClient:
:param str welllog_id: The id of the new well log
"""
url
=
f
"
{
self
.
_base_url
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
/data"
url
=
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
/data'
#url = f"{self._base_url}/api/os-wellbore-ddms/ddms/v3/welllogs/{welllog_id}/data"
# Adding content-type to standard headers
headers
=
self
.
_create_headers
()
...
...
@@ -123,7 +128,9 @@ class OsduClient:
if
curves
is
not
None
and
len
(
curves
)
>
0
:
curves_query
=
f
"&curves=
{
','
.
join
(
curves
)
}
"
get_welllog_data_url
=
f
"
{
self
.
_base_url
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
/data?describe=false
{
curves_query
}
"
get_welllog_data_url
=
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/ddms/v3/welllogs/
{
welllog_id
}
/data?describe=false
{
curves_query
}
'
#get_welllog_data_url = f"{self._base_url}/api/os-wellbore-ddms/ddms/v3/welllogs/{welllog_id}/data?describe=false{curves_query}"
try
:
res
=
self
.
_send_request
(
"GET"
,
get_welllog_data_url
,
None
,
None
)
...
...
@@ -140,7 +147,8 @@ class OsduClient:
:return: A dictionary that contains the curve family
:rtype: any
"""
recognize_family_url
=
f
"
{
self
.
_base_url
}
/api/os-wellbore-ddms/log-recognition/family"
recognize_family_url
=
f
'
{
self
.
_get_base_url
(
"wellbore"
)
}
/api/os-wellbore-ddms/log-recognition/family'
#recognize_family_url = f"{self._base_url}/api/os-wellbore-ddms/log-recognition/family"
payload
=
{
"label"
:
mnemonic
,
"log_unit"
:
unit
}
return
self
.
_send_request_json_response
(
"POST"
,
recognize_family_url
,
None
,
payload
)
...
...
@@ -151,7 +159,8 @@ class OsduClient:
:return: A List that contains the matching wellbore ids
:rtype: List[str]
"""
url
=
f
"
{
self
.
_base_url
}
/api/search/v2/query"
#url = f"{self._base_url}/api/search/v2/query"
url
=
f
'
{
self
.
_get_base_url
(
"search"
)
}
/api/search/v2/query'
payload
=
{
"kind"
:
"*:*:master-data--Wellbore:*"
,
...
...
@@ -168,7 +177,8 @@ class OsduClient:
def
_post_data_with_id_response
(
self
,
path
:
str
,
record
:
Record
)
->
List
[
any
]:
payload
=
[
record
.
get_raw_data
()]
url
=
f
"
{
self
.
_base_url
}{
path
}
"
url
=
f
"
{
path
}
"
#url = f"{self._base_url}{path}"
parsed_result
=
self
.
_send_request_json_response
(
"POST"
,
url
,
None
,
payload
)
...
...
@@ -193,3 +203,12 @@ class OsduClient:
raise
DataLoaderWebResponseError
(
res
.
status_code
,
url
,
res
.
text
)
return
res
def
_get_base_url
(
self
,
service_name
:
str
)
->
str
:
if
self
.
_csp_base_url_prefix
==
"yes"
:
if
service_name
==
"wellbore"
:
return
f
"
{
self
.
_base_url
}
/osdu-wellbore"
if
service_name
==
"search"
:
return
f
"
{
self
.
_base_url
}
/osdu-search"
else
:
return
self
.
_base_url
\ No newline at end of file
Write
Preview
Supports
Markdown
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