Commit 94b1a6d3 authored by fabian serin's avatar fabian serin
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services into fserin/fix_conversion
parents 7813a9d7 1bd64ffc
Pipeline #37364 passed with stages
in 11 minutes and 1 second
# Copyright 2021 Schlumberger
# Copyright 2021 EPAM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -19,7 +20,7 @@ variables:
AZURE_DOCKER_SUBDIR: build/Dockerfile
AZURE_TEST_SUBDIR: tests/integration
AZURE_TEST_TYPE: python
AWS_SERVICE: wellbore-ddms
AWS_ENVIRONMENT: dev
AWS_BUILD_SUBDIR: provider/os-wellbore-ddms-aws/build-aws
......@@ -29,7 +30,10 @@ variables:
OSDU_GCP_PROJECT_NAME: nice-etching-277309
OSDU_GCP_CLUSTER: wb
OSDU_GCP_ZONE: us-central1-c
SERVICE_NAME: wellbore #Must be same as in configmap.yaml (namespace = name)
OSDU_GCP_SERVICE: wellbore
OSDU_GCP_HELM_DEPLOYMENT_DIR: devops/gcp/osdu-helm
OSDU_GCP_SERVICE_PATH: /api/os-wellbore-ddms
OSDU_GCP_HEALTH_PATH: /api/os-wellbore-ddms/healthz
include:
......@@ -45,24 +49,24 @@ include:
- project: "osdu/platform/ci-cd-pipelines"
file: "scanners/gitlab-ultimate.yml"
- project: 'osdu/platform/ci-cd-pipelines'
file: 'cloud-providers/osdu-gcp-stateful-k8s.yml'
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/osdu-gcp-stateful-k8s.yml"
- project: 'osdu/platform/ci-cd-pipelines'
file: 'cloud-providers/ibm-wellbore.yml'
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/ibm-wellbore.yml"
- local: "/devops/azure/azure-wellbore.yml"
- project: 'osdu/platform/ci-cd-pipelines'
file: 'cloud-providers/aws.yml'
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/aws.yml"
containerize:
extends: .skipForTriggeringMergeRequests
stage: containerize
image: docker:19.03
tags: ['osdu-medium']
tags: ["osdu-medium"]
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
script:
- echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
- apk update
......@@ -89,13 +93,13 @@ osdu-gcp-containerize:
stage: containerize
image: docker:19.03
cache: {}
tags: [ 'osdu-medium' ]
tags: ["osdu-medium"]
only:
variables:
- $OSDU_GCP == 'true'
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
IMAGE_TAG_COMMUNITY: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:gcp-community
IMAGE_TAG: $CI_REGISTRY_IMAGE/osdu-gcp-$OSDU_GCP_SERVICE:$CI_COMMIT_SHA
IMAGE_TAG_COMMUNITY: $CI_REGISTRY_IMAGE/osdu-gcp-$OSDU_GCP_SERVICE:gcp-community
script:
- echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
- apk update
......@@ -122,13 +126,13 @@ osdu-gcp-containerize-for-release:
stage: containerize
image: docker:19.03
cache: {}
tags: [ 'osdu-medium' ]
tags: ["osdu-medium"]
only:
variables:
- $OSDU_GCP == 'true' && $RELEASE =~ /(v)(\d+\.)(\d+\.)\w+/i
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:gcp-$RELEASE
IMAGE_TAG_RELEASE: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:gcp-release
IMAGE_TAG: $CI_REGISTRY_IMAGE/osdu-gcp-$OSDU_GCP_SERVICE:gcp-$RELEASE
IMAGE_TAG_RELEASE: $CI_REGISTRY_IMAGE/osdu-gcp-$OSDU_GCP_SERVICE:gcp-release
script:
- echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
- apk update
......@@ -154,7 +158,7 @@ osdu-gcp-containerize-for-release:
osdu-gcp-test-python:
stage: integration
image: gcr.io/google.com/cloudsdktool/cloud-sdk
allow_failure: true
needs: ['osdu-gcp-deploy']
only:
variables:
- $OSDU_GCP == 'true' && $OSDU_GCP_INT_TEST_TYPE == 'python'
......@@ -167,26 +171,15 @@ osdu-gcp-test-python:
- pip install -r requirements.txt
- pip install -r requirements_dev.txt
- cd tests/integration
- gcloud auth activate-service-account --key-file $OSDU_GCP_DEPLOY_FILE
- gcloud config set project $OSDU_GCP_PROJECT_NAME
- gcloud container clusters get-credentials $OSDU_GCP_CLUSTER --zone $OSDU_GCP_ZONE --project $OSDU_GCP_PROJECT_NAME
- OSDU_GCP_WELLBORE_DDMS_URL=http://`kubectl get ingress -n $SERVICE_NAME -o jsonpath='{..ingress[*].'ip'}'``kubectl get configmap $SERVICE_NAME -n $SERVICE_NAME -o jsonpath='{.data.'API_URL'}'`
- OSDU_GCP_TENANT=`kubectl get configmap $SERVICE_NAME -n $SERVICE_NAME -o jsonpath='{.data.'TENANT'}'`
- OSDU_GCP_LEGAL_TAG=`kubectl get configmap $SERVICE_NAME -n $SERVICE_NAME -o jsonpath='{.data.'LEGAL_TAG'}'`
- echo $OSDU_GCP_INTEGRATION_TESTER | base64 -d > file.json
- gcloud auth activate-service-account --key-file file.json
- gcloud config set project $OSDU_GCP_PROJECT_NAME
- python gen_postman_env.py --token $(gcloud auth print-identity-token) --base_url $OSDU_GCP_WELLBORE_DDMS_URL --cloud_provider $OSDU_GCP_VENDOR --data_partition $OSDU_GCP_TENANT --acl_domain $DOMAIN --legal_tag $OSDU_GCP_LEGAL_TAG
- >
python gen_postman_env.py
--token $(gcloud auth print-identity-token)
--base_url ${OSDU_GCP_URL}${OSDU_GCP_SERVICE_PATH}
--cloud_provider $OSDU_GCP_VENDOR
--data_partition $OSDU_GCP_TENANT
--acl_domain $DOMAIN
--legal_tag $OSDU_GCP_LEGAL_TAG
- pytest ./functional --environment="./generated/postman_environment.json" --filter-tag=basic
osdu-gcp-test:
extends: []
image: gcr.io/google.com/cloudsdktool/cloud-sdk
script:
- echo "Tests here"
allow_failure: false
stage: integration
needs: ["osdu-gcp-deploy"]
only:
variables:
- $OSDU_GCP == 'true' && $OSDU_GCP_INT_TEST_TYPE != 'python'
......@@ -15,6 +15,7 @@
from typing import Union
from fastapi.exceptions import RequestValidationError
from fastapi.encoders import jsonable_encoder
from fastapi.openapi.constants import REF_PREFIX
from fastapi.openapi.utils import validation_error_response_definition
from pydantic import ValidationError
......@@ -33,7 +34,7 @@ async def http422_error_handler(
"""
get_logger().exception(f"http422_error_handler - {request.url}")
return JSONResponse({"errors": exc.errors()}, status_code=HTTP_422_UNPROCESSABLE_ENTITY)
return JSONResponse(content=jsonable_encoder({"errors": exc.errors()}), status_code=HTTP_422_UNPROCESSABLE_ENTITY)
validation_error_response_definition["properties"] = {
......
......@@ -839,7 +839,6 @@ class Artefact(BaseModel):
] = Field(None, description='The SRN which identifies this OSDU Artefact resource.')
class AbstractWellboreDrillingReason100(BaseModel):
"""
Purpose for drilling a wellbore, which often is an indication of the level of risk.
......@@ -946,6 +945,7 @@ class VerticalMeasurement(AbstractFacilityVerticalMeasurement100):
description='The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.',
)
class AbstractWPCGroupType100(BaseModel):
"""
Generic reference object containing the universal group-type properties of a Work Product Component for inclusion in data type specific Work Product Component objects
......@@ -968,7 +968,7 @@ class AbstractWPCGroupType100(BaseModel):
class LineageAssertion(BaseModel):
ID: Optional[
constr(regex=r'^[\w\-\.]+:[\w\-\.]+\-\-[\w\-\.]+:[\w\-\.\:\%]+:[0-9]*$')
constr(regex=r'^[\w\-\.]+:[\w\-\.]+:[\w\-\.\:\%]+:[0-9]*$')
] = Field(
None,
description='The object reference identifying the DIRECT, INDIRECT, REFERENCE dependency.',
......@@ -1206,6 +1206,7 @@ class Well(BaseModel):
)
data: Optional[WellData] = None
class WellBoreData(AbstractCommonResources100, AbstractMaster100, AbstractFacility100):
WellID: Optional[
constr(regex=r'^[\w\-\.]+:master-data\-\-Well:[\w\-\.\:\%]+:[0-9]*$')
......@@ -1502,3 +1503,198 @@ class WellLog(BaseModel):
title='Frame of Reference Meta Data',
)
data: Optional[WellLogData] = None
class WellboreTrajectoryData(
AbstractCommonResources100,
AbstractWPCGroupType100,
AbstractWorkProductComponent100,
):
ServiceCompanyID: Optional[
constr(regex=r'^[\w\-\.]+:master-data\-\-Organisation:[\w\-\.\:\%]+:[0-9]*$')
] = Field(None, description='Name of the Survey Company.', title='Service Company')
WellboreID: constr(
regex=r'^[\w\-\.]+:master-data\-\-Wellbore:[\w\-\.\:\%]+:[0-9]*$'
) = Field(
...,
description='A unique name, code or number designated to the Wellbore.',
title='Wellbore',
)
TopDepthMeasuredDepth: float = Field(
...,
description='Measured depth in wellbore where the directional survey starts. This should equal the minimum station measured depth for this directional survey, regardless of whether the surveyed station represents an actual surveyed MD or not.',
title='Survey Top Measured Depth',
)
AzimuthReferenceType: Optional[
constr(
regex=r'^[\w\-\.]+:reference-data\-\-AzimuthReferenceType:[\w\-\.\:\%]+:[0-9]*$'
)
] = Field(
None,
description='The North reference of the trajectory used to define the azimuth angular measurement values. For example, True North, Grid North, Magnetic North.',
title='Azimuth Reference Type',
)
CalculationMethodType: Optional[
constr(
regex=r'^[\w\-\.]+:reference-data\-\-CalculationMethodType:[\w\-\.\:\%]+:[0-9]*$'
)
] = Field(
None,
description='Calculation Method Type used to compute the TVD, X OFFSET, Y OFFSET and DOG LEG SEVERITY values for this Directional Survey. For example, Radius of Curvature, Minimum Curvature, Balanced Tangential, etc.',
title='Calculation Method Type',
)
ProjectedCRSID: Optional[
constr(
regex=r'^[\w\-\.]+:reference-data\-\-CoordinateReferenceSystem:[\w\-\.\:\%]+:[0-9]*$'
)
] = Field(
None,
description='Coordinate Reference System defining the Projection of the station EASTING and NORTHING values. If type is "Grid North" and EASTING and NORTHING attributes are stored, clearly identifying their projection is required.',
example='namespace:reference-data--CoordinateReferenceSystem:ProjectedCRS.EPSG.32615:',
title='Projected Coordinate Reference System ID',
)
ActiveIndicator: Optional[bool] = Field(
None,
description='A flag indicating if the survey is currently active or valid within his lifecycle stage, not necessarily the definitive survey.',
title='Active Survey Indicator',
)
SurveyType: Optional[str] = Field(
None,
description='The type of this directional survey. For example a "Directional Survey" where MD, Inclination and Azimuth are all measured or a "Position Log" where Inclination and Azimuth are both null and only MD, TVD and X/Y Offsets are available) - or "Full Survey" where everything is fully filled-up, depth-inclination-azimuth.',
title='Directional Survey Type',
)
AcquisitionDate: Optional[datetime] = Field(
None,
description='The date that the survey data was acquired on the field.',
title='Effective Date',
)
GeographicCRSID: Optional[
constr(
regex=r'^[\w\-\.]+:reference-data\-\-CoordinateReferenceSystem:[\w\-\.\:\%]+:[0-9]*$'
)
] = Field(
None,
description='Coordinate Reference System defining the Geodetic Datum of the station LATITUDE and LONGITUDE values. If LATITUDE and LONGITUDE attributes are stored, clearly identifying their Datum is required.',
example='namespace:reference-data--CoordinateReferenceSystem:GeodeticCRS.EPSG.4326:',
title='Geographic Coordinate Reference System',
)
AcquisitionRemark: Optional[str] = Field(
None,
description='Remarks related to acquisition context which is not the same as Description which is a summary of the work-product-component.',
title='Survey Remark',
)
SurveyReferenceIdentifier: Optional[str] = Field(
None,
description='Unique or Distinctive Survey Reference Number, Job Number, File Number, Identifier, Label, Name, etc. as indicated on a directional survey report, file, etc. Use this attribute to allow correlation of the data in this Directional Survey back to the original source document, file, etc.',
title='Survey Reference Identifier',
)
SurveyToolTypeID: Optional[str] = Field(
None,
description='The type of tool or equipment used to acquire this Directional Survey. For example, gyroscopic, magnetic, MWD, TOTCO, acid bottle, etc. Follow OWSG reference data and support the ISCWSA survey tool definitions.',
title='Type of the Survey Tool',
)
SurveyVersion: Optional[str] = Field(
None,
description='The version of the wellbore survey deliverable received from the service provider - as given by this provider',
title='Survey Version',
)
ExtrapolatedMeasuredDepth: Optional[float] = Field(
None,
description='The measured depth to which the survey segment was extrapolated.',
title='Extrapolated Measured Depth',
)
BaseDepthMeasuredDepth: float = Field(
...,
description='Measured depth within the wellbore of the LAST surveyed station with recorded data. If a stored survey has been extrapolated to a deeper depth than the last surveyed station then that is the extrapolated measured depth and not the survey base depth.',
title='Survey Base Measured Depth',
)
TieMeasuredDepth: Optional[float] = Field(
None,
description='Tie-point depth measured along the wellbore from the measurement reference datum to the survey station - where tie point is the place on the originating survey where the current survey intersect it.',
title='Tie Measured Depth',
)
VerticalMeasurement: AbstractFacilityVerticalMeasurement100 = Field(
...,
description='References an entry in the Vertical Measurement array for the Wellbore identified by WellboreID, which defines the vertical reference datum for all survey station measured depths.',
)
ExtensionProperties: Optional[Dict[str, Any]] = None
class WellboreTrajectory(BaseModel):
"""
Work Product Component describing an individual instance of a wellbore trajectory data object. Also called a deviation survey, wellbore trajectory is data that is used to calculate the position and spatial uncertainty of a planned or actual wellbore in 2-dimensional and 3-dimensional space.
"""
id: Optional[
constr(
regex=r'^[\w\-\.]+:work-product-component\-\-WellboreTrajectory:[\w\-\.\:\%]+$'
)
] = Field(
None,
description='Previously called ResourceID or SRN which identifies this OSDU resource object without version.',
example='namespace:work-product-component--WellboreTrajectory:606f224a-ef1f-5690-9843-d26cd7e33e10',
title='Entity ID',
)
kind: constr(regex=r'^[\w\-\.]+:[\w\-\.]+:[\w\-\.]+:[0-9]+.[0-9]+.[0-9]+$') = Field(
...,
description='The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.',
example='osdu:wks:work-product-component--WellboreTrajectory:1.0.0',
title='Entity Kind',
)
version: Optional[int] = Field(
None,
description='The version number of this OSDU resource; set by the framework.',
example=1562066009929332,
title='Version Number',
)
acl: AbstractAccessControlList100 = Field(
...,
description='The access control tags associated with this entity.',
title='Access Control List',
)
legal: AbstractLegalTags100 = Field(
...,
description="The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.",
title='Legal Tags',
)
tags: Optional[Dict[str, Tags]] = Field(
None,
description='A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.',
example={'NameOfKey': 'String value'},
title='Tag Dictionary',
)
createTime: Optional[datetime] = Field(
None,
description='Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.',
example='2020-12-16T11:46:20.163Z',
title='Resource Object Creation DateTime',
)
createUser: Optional[str] = Field(
None,
description='The user reference, which created the first version of this resource object. Set by the System.',
example='some-user@some-company-cloud.com',
title='Resource Object Creation User Reference',
)
modifyTime: Optional[datetime] = Field(
None,
description='Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.',
example='2020-12-16T11:52:24.477Z',
title='Resource Object Version Creation DateTime',
)
modifyUser: Optional[str] = Field(
None,
description='The user reference, which created this version of this resource object. Set by the System.',
example='some-user@some-company-cloud.com',
title='Resource Object Version Creation User Reference',
)
ancestry: Optional[AbstractLegalParentList100] = Field(
None,
description='The links to data, which constitute the inputs.',
title='Ancestry',
)
meta: Optional[List[Any]] = Field(
None,
description='The Frame of Reference meta data section linking the named properties to self-contained definitions.',
title='Frame of Reference Meta Data',
)
data: Optional[WellboreTrajectoryData] = None
# Default values for gcp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
namespace: wellbore
namespace: osdu
configMap:
data:
......@@ -19,10 +19,9 @@ secret:
replicaCount: 1
image:
repository: "gcr.io/nice-etching-277309/wellbore-ddms/wellbore-ddms-gcp"
repository: "community.opengroup.org:5555/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/osdu-gcp-wellbore-ddms"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "7e6b01b5"
tag: "gcp-release"
service:
#type: ClusterIP
......@@ -32,18 +31,18 @@ service:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: gcp
kubernetes.io/ingress.class: gcp
# kubernetes.io/tls-acme: "true"
# hosts:
# - host: chart-example.local
# paths: []
# tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
......
......@@ -2234,7 +2234,7 @@
"properties": {
"ID": {
"description": "The object reference identifying the DIRECT, INDIRECT, REFERENCE dependency.",
"pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+\\-\\-[\\w\\-\\.]+:[\\w\\-\\.\\:\\%]+:[0-9]*$",
"pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.\\:\\%]+:[0-9]*$",
"title": "Id",
"type": "string"
},
......
......@@ -20,7 +20,7 @@ import pytest
from fastapi import HTTPException, Header, status
from fastapi.testclient import TestClient
from odes_search.models import CursorQueryResponse
from odes_storage.models import RecordVersions, CreateUpdateRecordsResponse
from odes_storage.models import RecordVersions, CreateUpdateRecordsResponse, Record
from app.auth.auth import require_opendes_authorized_user
from app.clients import *
......@@ -83,6 +83,10 @@ tests_parameters = [
)),
]
tests_errors_422 = [
('/ddms/v2/wellbores', Record(id='123456', kind='xx', acl={'viewers': [], 'owners': []}, legal={},
data={"wellborePurpose": "develpment"})),
]
tests_parameters_for_recursive = [
('/ddms/v2/logsets', logset(id='123456', data={})),
......@@ -147,6 +151,20 @@ def test_get_record_success(client, base_url, record_obj):
# assert it validates the input object schema
record_obj.validate(response.json())
@pytest.mark.parametrize('base_url, record_obj', tests_errors_422)
def test_get_record_422(client, base_url, record_obj):
record_id = record_obj.id
moc = mock.AsyncMock(return_value=record_obj)
with mock.patch.object(StorageRecordServiceClientMock, 'get_record', moc):
# when
response = client.get(f'{base_url}/{record_id}', headers={'data-partition-id': 'testing_partition'})
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
# then assert storage is called with the proper id and data_partition
moc.assert_called_with(id=record_id, data_partition_id='testing_partition')
@pytest.mark.parametrize('base_url, record_obj', tests_parameters)
def test_get_record_without_default_values(client, base_url, record_obj):
record_id = record_obj.id
......
This diff is collapsed.
......@@ -17,13 +17,14 @@ import json
import os
from typing import Type
from pydantic import BaseModel
from app.model.osdu_model import Wellbore, Well, WellLog
from app.model.osdu_model import Wellbore, Well, WellLog, WellboreTrajectory
test_parameters = [
(Wellbore, "Wellbore_unit.json"),
(Well, "Well_unit.json"),
(WellLog, "WellLog_unit.json"),
(WellboreTrajectory, "WellboreTrajectory_unit.json"),
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment