Commit 5d6e5931 authored by Alexandre Vincent's avatar Alexandre Vincent
Browse files

Merge branch 'master' into avincent/horizontal_pod_autoscaling

parents 6a1a1ee8 14920c09
Pipeline #70315 failed with stages
in 18 minutes and 39 seconds
......@@ -41,4 +41,4 @@ secrets/
**/.DS_Store
.vscode
\ No newline at end of file
.vscode
......@@ -32,8 +32,8 @@ variables:
OSDU_GCP_SERVICE: wellbore
OSDU_GCP_VENDOR: gcp
OSDU_GCP_HELM_PACKAGE_CHARTS: "devops/gcp/deploy devops/gcp/configmap"
OSDU_GCP_HELM_CONFIG_SERVICE_VARS: "--set data.os_wellbore_ddms_data_project_id=$OSDU_GCP_PROJECT --set data.service_host_search=$OSDU_GCP_SERVICE_HOST_SEARCH --set data.sa_key=$OSDU_GCP_INTEGRATION_TESTER"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS: "--set data.image=$CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA"
OSDU_GCP_HELM_CONFIG_SERVICE_VARS: "--set data.os_wellbore_ddms_data_project_id=$OSDU_GCP_PROJECT"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS: "--set data.image=$CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA --set data.serviceAccountName=workload-identity-wellbore"
OSDU_GCP_HELM_CONFIG_SERVICE: wellbore-config
OSDU_GCP_HELM_DEPLOYMENT_SERVICE: wellbore-deploy
OSDU_GCP_INT_TEST_TYPE: python
......@@ -65,6 +65,50 @@ include:
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/aws-python.yml"
verify_existing_requirements:
extends:
- .python
- .skipForTriggeringMergeRequests
stage: build
before_script:
- pip3 install --upgrade pip-tools
script:
- pip-compile requirements.in
- pip-compile requirements_dev.in
# checking difference between existing requirements and the newly generated one
# and using the number of lines as exit status code
- exit $(git status -s | grep -e "^ M " | wc -l)
artifacts:
when: always
paths:
- "requirements*.txt"
expire_in: 2 days
generate_updated_requirements:
extends:
- .python
- .skipForTriggeringMergeRequests
stage: build
before_script:
- pip3 install --upgrade pip-tools
script:
- pip-compile requirements.in --upgrade --output-file requirements.upg
- pip-compile requirements_dev.in --upgrade --output-file requirements_dev.upg
artifacts:
when: always
paths:
- "*.upg"
expire_in: 2 days
allow_failure: true
containerize:
extends: .skipForTriggeringMergeRequests
stage: containerize
......@@ -194,8 +238,3 @@ osdu-gcp-test-python:
osdu-gcp-test:
extends:
- .osdu-gcp-variables
# Allow failure on deployments
ibm-deploy:
allow_failure: true
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
\ No newline at end of file
......@@ -30,7 +30,7 @@ The following software have components provided under the terms of this license:
- openapi-spec-validator (from https://github.com/p1c2u/openapi-spec-validator)
- opencensus (from https://github.com/census-instrumentation/opencensus-python)
- opencensus-context (from https://github.com/census-instrumentation/opencensus-python/tree/master/context/opencensus-context)
- opencensus-ext-azure (from )
- opencensus-ext-azure (from https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-azure)
- opencensus-ext-logging (from )
- opencensus-ext-ocagent (from https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-ocagent)
- opencensus-ext-stackdriver (from https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-stackdriver)
......
......@@ -349,8 +349,7 @@ This example runs basic tests using the local filesystem for blob storage and st
First, create the temp storage folders and run the service.
```bash
mkdir -p tmpstorage
mkdir -p tmpblob
mkdir -p tmpstorage tmpblob
python main.py -e USE_INTERNAL_STORAGE_SERVICE_WITH_PATH $(pwd)/tmpstorage -e USE_LOCALFS_BLOB_STORAGE_WITH_PATH $(pwd)/tmpblob -e CLOUD_PROVIDER local
```
......@@ -378,6 +377,11 @@ If you want to work with other requirements file, you can specify them
pip-sync requirements.txt requirements_dev.txt
```
**Note:** On a Windows workstation, platform-specific modules such as `pywin32` are also needed. In this case don't use `pip-sync` but `pip install` instead.
```bash
pip install -r requirements.txt -r requirements_dev.txt
```
If you want to update `requirements.txt` to retrieve the most recent version, respecting bounds set in `requirements.in`, you can use:
```bash
......@@ -390,6 +394,8 @@ If you want to update the version of only one dependency, for instance fastapi:
pip-compile --upgrade-package fastapi
```
**Note:** On a Windows workstation, **don't** commit the `pywin32` back to the `requirements.txt` file, that will cause CICD to fail.
For more information: https://github.com/jazzband/pip-tools/
### Debugging:
......
......@@ -314,9 +314,24 @@ def cloud_provider_additional_environment(config: ConfigurationContainer):
config.add_from_env(attribute_name='default_data_tenant_credentials',
env_var_key='OS_WELLBORE_DDMS_DATA_PROJECT_CREDENTIALS',
description='path to the key file of the SA to access the data tenant',
is_mandatory=True,
is_mandatory=False,
override=True,
validator=validator_path_must_exist,
default=None)
config.add_from_env(attribute_name='service_host_storage',
env_var_key='SERVICE_HOST_STORAGE',
description='Back-end for storage service',
is_mandatory=False,
override=True,
default='http://storage/api/storage')
config.add_from_env(attribute_name='service_host_search',
env_var_key='SERVICE_HOST_SEARCH',
description='Back-end for search service',
is_mandatory=False,
override=True,
validator=validator_path_must_exist)
default='http://search/api/search')
if provider == 'ibm':
config.add_from_env(attribute_name='default_data_tenant_project_id',
......
......@@ -14,7 +14,7 @@
import asyncio
import json
from typing import List, Optional
from typing import Dict, List, Optional
import numpy as np
import pandas as pd
......@@ -392,15 +392,11 @@ class StatsColumn(BaseModel):
max: float = Field(..., description="Maximum of the values in the object")
class GetStatisticResponse(BaseModel):
columns: List[StatsColumn]
@router.get('/logs/{logid}/statistics',
summary='Data statistics',
description="This API will return count, mean, std, min, max and percentiles of each column. {}"
.format(REQUIRED_ROLES_READ),
response_model=GetStatisticResponse,
response_model=Dict[str, StatsColumn],
)
async def get_log_data_statistics(logid: str,
bulk_id_path: str = Depends(bulk_id_path_parameter),
......
......@@ -26,25 +26,11 @@ from app.utils import Context
from app.utils import get_ctx
from app.utils import load_schema_example
from app.model.model_utils import to_record, from_record
from app.converter.well_converter import WellConverter
from app.routers.ddms_v3.ddms_v3_utils import DMSV3RouterUtils
router = APIRouter()
async def get_well_as_osdu(wellid: str, ctx: Context) -> Well:
storage_client = await get_storage_record_service(ctx)
well_record = await storage_client.get_record(
id=wellid, data_partition_id=ctx.partition_id
)
res_as_dict = well_record.dict(
exclude_unset=True, exclude_none=True, by_alias=True
)
well = Well.parse_obj(WellConverter.convert_delfi_to_osdu(res_as_dict,
context={"namespace": ctx.partition_id}))
return well
async def get_osdu_well(wellid: str, ctx: Context) -> Well:
storage_client = await get_storage_record_service(ctx)
well_record = await storage_client.get_record(
......@@ -67,18 +53,15 @@ async def get_osdu_well(wellid: str, ctx: Context) -> Well:
async def get_well_osdu(
wellid: str, ctx: Context = Depends(get_ctx)
) -> Well:
deli_conversion, delfi_id = DMSV3RouterUtils.is_osdu_entity_fake_id(wellid)
if deli_conversion:
return await get_well_as_osdu(delfi_id, ctx)
fake_id, _ = DMSV3RouterUtils.is_osdu_entity_fake_id(wellid)
if fake_id:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Id is not OSDU Well")
is_osdu_versioned, osdu_id, version = DMSV3RouterUtils.is_osdu_versionned_well_id(wellid)
if is_osdu_versioned:
return await get_osdu_well(osdu_id, ctx)
if DMSV3RouterUtils.is_osdu_well_id(wellid):
return await get_osdu_well(wellid, ctx)
if DMSV3RouterUtils.is_delfi_id(wellid):
return await get_well_as_osdu(wellid, ctx)
raise HTTPException(status_code=status.HTTP_417_EXPECTATION_FAILED, detail="Id is not a wellbore")
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Id is not OSDU Well")
......
......@@ -27,25 +27,11 @@ from app.utils import Context
from app.utils import get_ctx
from app.utils import load_schema_example
from app.model.model_utils import to_record, from_record
from app.converter.wellbore_converter import WellboreConverter
from app.routers.ddms_v3.ddms_v3_utils import DMSV3RouterUtils
router = APIRouter()
async def get_wellbore_as_osdu(wellboreid: str, ctx: Context) -> Wellbore:
storage_client = await get_storage_record_service(ctx)
wellbore_record = await storage_client.get_record(
id=wellboreid, data_partition_id=ctx.partition_id
)
res_as_dict = wellbore_record.dict(
exclude_unset=True, exclude_none=True, by_alias=True
)
wellbore = Wellbore.parse_obj(WellboreConverter.convert_delfi_to_osdu(res_as_dict,
context={"namespace": ctx.partition_id}))
return wellbore
async def get_osdu_wellbore(wellboreid: str, ctx: Context) -> Wellbore:
storage_client = await get_storage_record_service(ctx)
wellbore_record = await storage_client.get_record(
......@@ -59,9 +45,7 @@ async def get_osdu_wellbore(wellboreid: str, ctx: Context) -> Wellbore:
response_model=Wellbore,
response_model_exclude_unset=True,
summary="Get the Wellbore using osdu schema",
description="""Get the Wellbore object using its **id**.
<p>If the **id** is a Delfi Wellbore Id, tries to convert it on the fly to return the Wellbore as an osdu Wellbore.</p>
{}""".format(REQUIRED_ROLES_READ),
description="""Get the Wellbore object using its **id**.{}""".format(REQUIRED_ROLES_READ),
operation_id="get_wellbore_osdu",
responses={
status.HTTP_404_NOT_FOUND: {"description": "Wellbore not found"}
......@@ -70,18 +54,15 @@ async def get_osdu_wellbore(wellboreid: str, ctx: Context) -> Wellbore:
async def get_wellbore_osdu(
wellboreid: str, ctx: Context = Depends(get_ctx)
) -> Wellbore:
delfi_convertion, delfi_id = DMSV3RouterUtils.is_osdu_entity_fake_id(wellboreid)
if delfi_convertion:
return await get_wellbore_as_osdu(delfi_id, ctx)
fake_id, _ = DMSV3RouterUtils.is_osdu_entity_fake_id(wellboreid)
if fake_id:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Id is not OSDU Wellbore")
is_osdu_versionned, osdu_id, version = DMSV3RouterUtils.is_osdu_versionned_wellbore_id(wellboreid)
if is_osdu_versionned:
return await get_osdu_wellbore(osdu_id, ctx)
if DMSV3RouterUtils.is_osdu_wellbore_id(wellboreid):
return await get_osdu_wellbore(wellboreid, ctx)
if DMSV3RouterUtils.is_delfi_id(wellboreid):
return await get_wellbore_as_osdu(wellboreid, ctx)
raise HTTPException(status_code=status.HTTP_417_EXPECTATION_FAILED, detail="Id is not a wellbore")
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Id is not OSDU Wellbore")
......
......@@ -244,11 +244,11 @@ async def post_traj_data(
channels = {c.name: c for c in record.data.channels}
record.data.channels = []
for name in df.columns:
channel = channels.get(name, TrajectoryChannel(name=name))
channel.bulkURI = record.data.bulkURI + ":" + name
record.data.channels.append(channel)
if channel.name not in channels:
record.data.channels.append(channel)
# Update record
storage_client = await get_storage_record_service(ctx)
......
kind: Secret
apiVersion: v1
metadata:
name: "{{ .Values.conf.secret_name }}"
namespace: "{{ .Release.Namespace }}"
type: Opaque
data:
"key.json": "{{ .Values.data.sa_key }}"
......@@ -8,6 +8,4 @@ metadata:
data:
CLOUD_PROVIDER: "gcp"
OS_WELLBORE_DDMS_DATA_PROJECT_ID: "{{ .Values.data.os_wellbore_ddms_data_project_id }}"
SERVICE_HOST_SEARCH: "{{ .Values.data.service_host_search }}"
SERVICE_HOST_STORAGE: "{{ .Values.data.service_host_storage }}"
OS_WELLBORE_DDMS_DATA_PROJECT_CREDENTIALS : "{{ .Values.data.os_wellbore_ddms_data_project_credentials }}"
......@@ -4,12 +4,7 @@
data:
os_wellbore_ddms_data_project_id: ""
os_wellbore_ddms_data_project_credentials: "/tmp/key/key.json"
service_host_search: "http://search/api/search"
service_host_storage: "http://storage/api/storage"
sa_key: ""
conf:
configmap: "wellbore-config"
app_name: "wellbore"
secret_name: "wellbore-secret"
......@@ -18,15 +18,9 @@ spec:
rollme: {{ randAlphaNum 5 | quote }}
sidecar.istio.io/rewriteAppHTTPProbers: "true"
spec:
volumes:
- name: service-account-key
secret:
secretName: "{{ .Values.conf.secret_name }}"
serviceAccountName: "{{ .Values.data.serviceAccountName }}"
containers:
- name: "{{ .Values.conf.app_name }}"
volumeMounts:
- mountPath: /tmp/key
name: service-account-key
image: "{{ .Values.data.image }}"
imagePullPolicy: Always
envFrom:
......
......@@ -6,10 +6,11 @@ data:
requests_cpu: "0.25"
requests_memory: "256M"
limits_cpu: "1"
limits_memory: "1G"
limits_memory: "2G"
image: "community.opengroup.org:5555/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/osdu-gcp:latest"
serviceAccountName: ""
conf:
configmap: "wellbore-config"
app_name: "wellbore"
secret_name: "wellbore-secret"
#
# This file is autogenerated by pip-compile with python 3.9
# This file is autogenerated by pip-compile with python 3.7
# To update, run:
#
# pip-compile requirements.in
......@@ -107,8 +107,6 @@ cloudpickle==1.6.0
# via
# dask
# distributed
colorama==0.4.4
# via click
cryptography==3.4.7
# via
# -r requirements.in
......@@ -192,6 +190,8 @@ idna==3.2
# requests
# rfc3986
# yarl
importlib-metadata==4.8.1
# via click
isodate==0.6.0
# via msrest
jmespath==0.10.0
......@@ -323,8 +323,6 @@ pytz==2021.1
# via
# google-api-core
# pandas
# pywin32==301
# via portalocker
pyyaml==5.4.1
# via
# dask
......@@ -389,9 +387,16 @@ tornado==6.1
typing-extensions==3.10.0.0
# via
# aiohttp
# aioitertools
# anyio
# asgiref
# importlib-metadata
# osdu-data-ecosystem-search
# osdu-data-ecosystem-storage
# pydantic
# structlog
# uvicorn
# yarl
urllib3==1.26.6
# via
# botocore
......@@ -406,6 +411,8 @@ yarl==1.6.3
# via aiohttp
zict==2.0.0
# via distributed
zipp==3.6.0
# via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
# setuptools
......@@ -58,7 +58,7 @@ idna==3.2
# anyio
# requests
# rfc3986
importlib-metadata==4.6.4
importlib-metadata==4.8.1
# via
# -c requirements.txt
# click
......@@ -197,7 +197,7 @@ urllib3==1.26.6
# requests
wheel==0.36.2
# via pip-tools
zipp==3.5.0
zipp==3.6.0
# via
# -c requirements.txt
# importlib-metadata
......