sumo-wrapper-python 1.0.14__tar.gz → 1.0.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sumo-wrapper-python might be problematic. Click here for more details.
- sumo_wrapper_python-1.0.15/.github/workflows/linting.yml +28 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.gitignore +2 -1
- sumo_wrapper_python-1.0.15/.pre-commit-config.yaml +16 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/PKG-INFO +4 -1
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/conf.py +0 -1
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/pyproject.toml +30 -4
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_auth_provider.py +14 -16
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_logging.py +9 -4
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_version.py +2 -2
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/sumo_client.py +9 -11
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/PKG-INFO +4 -1
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/SOURCES.txt +2 -2
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/requires.txt +4 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15/tests}/conftest.py +5 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/tests/test_sumo_thin_client.py +42 -42
- sumo_wrapper_python-1.0.14/.flake8 +0 -2
- sumo_wrapper_python-1.0.14/.github/workflows/linting.yml +0 -40
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.github/workflows/build_docs.yaml +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.github/workflows/publish_release.yml +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.github/workflows/pytest.yml +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.readthedocs.yaml +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/CONTRIBUTING.md +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/LICENSE +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/README.md +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/SECURITY.md +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/Makefile +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_static/equinor-logo.png +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_static/equinor-logo2.jpg +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_static/equinor_logo.jpg +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_static/equinor_logo_only.jpg +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_templates/layout.html +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/api.rst +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/index.rst +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/make.bat +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/sumo-wrapper-python.rst +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/setup.cfg +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/__init__.py +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/__init__.py +1 -1
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_blob_client.py +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_decorators.py +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_retry_strategy.py +1 -1
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/config.py +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/login.py +2 -2
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/tests/testdata/case.yml +0 -0
- {sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/tests/testdata/surface.yml +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Check formatting and linting
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push: { branches: [main] }
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ruff-check:
|
|
9
|
+
name: Run ruff lint and format checks
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: '3.11'
|
|
18
|
+
cache: 'pip'
|
|
19
|
+
|
|
20
|
+
- name: Installing dependencies
|
|
21
|
+
run: pip install ruff
|
|
22
|
+
|
|
23
|
+
- name: Run ruff lint
|
|
24
|
+
run: ruff check .
|
|
25
|
+
|
|
26
|
+
- name: Run ruff format
|
|
27
|
+
run: ruff format . --check
|
|
28
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: local
|
|
3
|
+
hooks:
|
|
4
|
+
- id: lint
|
|
5
|
+
name: Ruff Lint
|
|
6
|
+
description: Linting using ruff
|
|
7
|
+
entry: bash -c 'ruff check .'
|
|
8
|
+
language: system
|
|
9
|
+
stages: ["pre-commit", "pre-push"]
|
|
10
|
+
|
|
11
|
+
- id: format
|
|
12
|
+
name: Ruff Format
|
|
13
|
+
description: Formatting using ruff
|
|
14
|
+
entry: bash -c 'ruff format . --check'
|
|
15
|
+
language: system
|
|
16
|
+
stages: ["pre-commit", "pre-push"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sumo-wrapper-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.15
|
|
4
4
|
Summary: Python wrapper for the Sumo API
|
|
5
5
|
Author: Equinor
|
|
6
6
|
License: Apache License
|
|
@@ -226,6 +226,9 @@ Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
|
226
226
|
Requires-Dist: autoapi; extra == "docs"
|
|
227
227
|
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
228
228
|
Requires-Dist: sphinxcontrib-apidoc; extra == "docs"
|
|
229
|
+
Provides-Extra: dev
|
|
230
|
+
Requires-Dist: ruff; extra == "dev"
|
|
231
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
229
232
|
|
|
230
233
|
# sumo-wrapper-python
|
|
231
234
|
|
|
@@ -5,10 +5,6 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[tool.setuptools_scm]
|
|
6
6
|
version_file = "src/sumo/wrapper/_version.py"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
[tool.black]
|
|
10
|
-
line-length = 79
|
|
11
|
-
|
|
12
8
|
[project]
|
|
13
9
|
name = "sumo-wrapper-python"
|
|
14
10
|
description = "Python wrapper for the Sumo API"
|
|
@@ -39,6 +35,7 @@ docs = [
|
|
|
39
35
|
"sphinx-autodoc-typehints",
|
|
40
36
|
"sphinxcontrib-apidoc",
|
|
41
37
|
]
|
|
38
|
+
dev = ["ruff", "pre-commit"]
|
|
42
39
|
|
|
43
40
|
[project.urls]
|
|
44
41
|
Repository = "https://github.com/equinor/sumo-wrapper-python"
|
|
@@ -48,3 +45,32 @@ sumo_login = "sumo.wrapper.login:main"
|
|
|
48
45
|
|
|
49
46
|
[tool.setuptools.packages.find]
|
|
50
47
|
where = ["src"]
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
exclude = [
|
|
51
|
+
".env",
|
|
52
|
+
".git",
|
|
53
|
+
".github",
|
|
54
|
+
".venv",
|
|
55
|
+
"venv",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
line-length = 79
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
ignore = [
|
|
62
|
+
"E501",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
extend-select = [
|
|
66
|
+
"C4", # Flake8-comprehensions
|
|
67
|
+
"I", # isort
|
|
68
|
+
"SIM", # Flake8-simplify
|
|
69
|
+
"TC", # Flake8-type-checking
|
|
70
|
+
"TID", # Flake8-tidy-imports
|
|
71
|
+
"N", # pep8-naming
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.per-file-ignores]
|
|
75
|
+
"__init__.py" = ["F401"]
|
|
76
|
+
|
{sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_auth_provider.py
RENAMED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import errno
|
|
2
|
+
import json
|
|
2
3
|
import os
|
|
3
|
-
from datetime import datetime, timedelta
|
|
4
4
|
import stat
|
|
5
5
|
import sys
|
|
6
|
-
import json
|
|
7
|
-
import jwt
|
|
8
6
|
import time
|
|
9
|
-
from
|
|
10
|
-
import tenacity as tn
|
|
11
|
-
from ._retry_strategy import _log_retry_info, _return_last_value
|
|
7
|
+
from datetime import datetime, timedelta
|
|
12
8
|
|
|
9
|
+
import jwt
|
|
10
|
+
import msal
|
|
11
|
+
import tenacity as tn
|
|
12
|
+
from azure.identity import ManagedIdentityCredential
|
|
13
13
|
from msal_extensions.persistence import FilePersistence
|
|
14
14
|
from msal_extensions.token_cache import PersistedTokenCache
|
|
15
|
-
import errno
|
|
16
15
|
|
|
16
|
+
from ._retry_strategy import _log_retry_info, _return_last_value
|
|
17
17
|
|
|
18
18
|
if not sys.platform.startswith("linux"):
|
|
19
19
|
from msal_extensions import build_encrypted_persistence
|
|
@@ -422,14 +422,12 @@ def get_auth_provider(
|
|
|
422
422
|
return AuthProviderDeviceCode(client_id, authority, resource_id)
|
|
423
423
|
# ELSE
|
|
424
424
|
if all(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
"AZURE_AUTHORITY_HOST",
|
|
432
|
-
]
|
|
425
|
+
os.getenv(x)
|
|
426
|
+
for x in [
|
|
427
|
+
"AZURE_FEDERATED_TOKEN_FILE",
|
|
428
|
+
"AZURE_TENANT_ID",
|
|
429
|
+
"AZURE_CLIENT_ID",
|
|
430
|
+
"AZURE_AUTHORITY_HOST",
|
|
433
431
|
]
|
|
434
432
|
):
|
|
435
433
|
return AuthProviderManaged(resource_id)
|
|
@@ -3,14 +3,19 @@ from datetime import datetime
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class LogHandlerSumo(logging.Handler):
|
|
6
|
-
def __init__(self,
|
|
6
|
+
def __init__(self, sumo_client):
|
|
7
7
|
logging.Handler.__init__(self)
|
|
8
|
-
self._sumoClient =
|
|
8
|
+
self._sumoClient = sumo_client
|
|
9
9
|
return
|
|
10
10
|
|
|
11
11
|
def emit(self, record):
|
|
12
12
|
try:
|
|
13
|
-
dt =
|
|
13
|
+
dt = (
|
|
14
|
+
datetime.now(datetime.timezone.utc)
|
|
15
|
+
.replace(microsecond=0)
|
|
16
|
+
.isoformat()
|
|
17
|
+
+ "Z"
|
|
18
|
+
)
|
|
14
19
|
json = {
|
|
15
20
|
"severity": record.levelname,
|
|
16
21
|
"message": record.getMessage(),
|
|
@@ -20,7 +25,7 @@ class LogHandlerSumo(logging.Handler):
|
|
|
20
25
|
"funcname": record.funcName,
|
|
21
26
|
"linenumber": record.lineno,
|
|
22
27
|
}
|
|
23
|
-
if "objectUuid" in record.__dict__
|
|
28
|
+
if "objectUuid" in record.__dict__:
|
|
24
29
|
json["objectUuid"] = record.__dict__.get("objectUuid")
|
|
25
30
|
|
|
26
31
|
self._sumoClient.post("/message-log/new", json=json)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
import asyncio
|
|
2
|
+
import contextlib
|
|
3
|
+
import logging
|
|
4
|
+
import re
|
|
5
|
+
|
|
3
6
|
import httpx
|
|
4
7
|
import jwt
|
|
5
|
-
import re
|
|
6
8
|
|
|
7
|
-
from ._blob_client import BlobClient
|
|
8
|
-
from ._logging import LogHandlerSumo
|
|
9
9
|
from ._auth_provider import get_auth_provider
|
|
10
|
-
from .
|
|
11
|
-
|
|
10
|
+
from ._blob_client import BlobClient
|
|
12
11
|
from ._decorators import (
|
|
13
12
|
raise_for_status,
|
|
14
13
|
raise_for_status_async,
|
|
15
14
|
)
|
|
16
|
-
|
|
15
|
+
from ._logging import LogHandlerSumo
|
|
17
16
|
from ._retry_strategy import RetryStrategy
|
|
17
|
+
from .config import APP_REGISTRATION, AUTHORITY_HOST_URI, TENANT_ID
|
|
18
18
|
|
|
19
19
|
logger = logging.getLogger("sumo.wrapper")
|
|
20
20
|
|
|
@@ -61,12 +61,10 @@ class SumoClient:
|
|
|
61
61
|
logger.debug("Token provided")
|
|
62
62
|
|
|
63
63
|
payload = None
|
|
64
|
-
|
|
64
|
+
with contextlib.suppress(jwt.InvalidTokenError):
|
|
65
65
|
payload = jwt.decode(
|
|
66
66
|
token, options={"verify_signature": False}
|
|
67
67
|
)
|
|
68
|
-
except jwt.InvalidTokenError:
|
|
69
|
-
pass
|
|
70
68
|
|
|
71
69
|
if payload:
|
|
72
70
|
logger.debug(f"Token decoded as JWT, payload: {payload}")
|
|
@@ -380,7 +378,7 @@ class SumoClient:
|
|
|
380
378
|
|
|
381
379
|
return retryer(_delete)
|
|
382
380
|
|
|
383
|
-
def
|
|
381
|
+
def get_logger(self, name):
|
|
384
382
|
"""Gets a logger object that sends log objects into the message_log
|
|
385
383
|
index for the Sumo instance.
|
|
386
384
|
|
{sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sumo-wrapper-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.15
|
|
4
4
|
Summary: Python wrapper for the Sumo API
|
|
5
5
|
Author: Equinor
|
|
6
6
|
License: Apache License
|
|
@@ -226,6 +226,9 @@ Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
|
226
226
|
Requires-Dist: autoapi; extra == "docs"
|
|
227
227
|
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
228
228
|
Requires-Dist: sphinxcontrib-apidoc; extra == "docs"
|
|
229
|
+
Provides-Extra: dev
|
|
230
|
+
Requires-Dist: ruff; extra == "dev"
|
|
231
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
229
232
|
|
|
230
233
|
# sumo-wrapper-python
|
|
231
234
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
.flake8
|
|
2
1
|
.gitignore
|
|
2
|
+
.pre-commit-config.yaml
|
|
3
3
|
.readthedocs.yaml
|
|
4
4
|
CONTRIBUTING.md
|
|
5
5
|
LICENSE
|
|
6
6
|
README.md
|
|
7
7
|
SECURITY.md
|
|
8
|
-
conftest.py
|
|
9
8
|
pyproject.toml
|
|
10
9
|
.github/workflows/build_docs.yaml
|
|
11
10
|
.github/workflows/linting.yml
|
|
@@ -39,6 +38,7 @@ src/sumo_wrapper_python.egg-info/dependency_links.txt
|
|
|
39
38
|
src/sumo_wrapper_python.egg-info/entry_points.txt
|
|
40
39
|
src/sumo_wrapper_python.egg-info/requires.txt
|
|
41
40
|
src/sumo_wrapper_python.egg-info/top_level.txt
|
|
41
|
+
tests/conftest.py
|
|
42
42
|
tests/test_sumo_thin_client.py
|
|
43
43
|
tests/testdata/case.yml
|
|
44
44
|
tests/testdata/surface.yml
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
+
from sumo.wrapper import SumoClient
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
def pytest_addoption(parser):
|
|
5
7
|
parser.addoption("--token", action="store", default="")
|
|
@@ -10,5 +12,8 @@ def pytest_generate_tests(metafunc):
|
|
|
10
12
|
token = os.environ.get("ACCESS_TOKEN")
|
|
11
13
|
token = token if token and len(token) > 0 else None
|
|
12
14
|
|
|
15
|
+
if token is None:
|
|
16
|
+
_ = SumoClient(env="dev", interactive=True)
|
|
17
|
+
|
|
13
18
|
if "token" in metafunc.fixturenames:
|
|
14
19
|
metafunc.parametrize("token", [token])
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
"""Example code for communicating with Sumo"""
|
|
2
2
|
|
|
3
|
-
import pytest
|
|
4
|
-
import yaml
|
|
5
|
-
from time import sleep
|
|
6
|
-
import sys
|
|
7
3
|
import os
|
|
4
|
+
import sys
|
|
8
5
|
import uuid
|
|
6
|
+
from time import sleep
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
import yaml
|
|
9
10
|
|
|
10
11
|
sys.path.append(os.path.abspath(os.path.join("src")))
|
|
11
12
|
|
|
12
13
|
from sumo.wrapper import SumoClient # noqa: E402
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
self.api = SumoClient(env="dev", token=token)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _upload_parent_object(C, json):
|
|
21
|
-
response = C.api.post("/objects", json=json)
|
|
16
|
+
def _upload_parent_object(conn, json):
|
|
17
|
+
response = conn.post("/objects", json=json)
|
|
22
18
|
|
|
23
19
|
if not 200 <= response.status_code < 202:
|
|
24
20
|
raise Exception(f"code: {response.status_code}, text: {response.text}")
|
|
25
21
|
return response
|
|
26
22
|
|
|
27
23
|
|
|
28
|
-
def _upload_blob(
|
|
29
|
-
response =
|
|
24
|
+
def _upload_blob(conn, blob, url=None, object_id=None):
|
|
25
|
+
response = conn.blob_client.upload_blob(blob=blob, url=url)
|
|
30
26
|
|
|
31
27
|
print("Blob save " + str(response.status_code), flush=True)
|
|
32
28
|
if not 200 <= response.status_code < 202:
|
|
@@ -37,8 +33,8 @@ def _upload_blob(C, blob, url=None, object_id=None):
|
|
|
37
33
|
return response
|
|
38
34
|
|
|
39
35
|
|
|
40
|
-
def _get_blob_uri(
|
|
41
|
-
response =
|
|
36
|
+
def _get_blob_uri(conn, object_id):
|
|
37
|
+
response = conn.get(f"/objects('{object_id}')/blob/authuri")
|
|
42
38
|
|
|
43
39
|
print("Blob save " + str(response.status_code), flush=True)
|
|
44
40
|
if not 200 <= response.status_code < 202:
|
|
@@ -49,14 +45,14 @@ def _get_blob_uri(C, object_id):
|
|
|
49
45
|
return response
|
|
50
46
|
|
|
51
47
|
|
|
52
|
-
def _download_object(
|
|
53
|
-
json =
|
|
48
|
+
def _download_object(conn, object_id):
|
|
49
|
+
json = conn.get(f"/objects('{object_id}')").json()
|
|
54
50
|
|
|
55
51
|
return json
|
|
56
52
|
|
|
57
53
|
|
|
58
|
-
def _upload_child_level_json(
|
|
59
|
-
response =
|
|
54
|
+
def _upload_child_level_json(conn, parent_id, json):
|
|
55
|
+
response = conn.post(f"/objects('{parent_id}')", json=json)
|
|
60
56
|
|
|
61
57
|
if not 200 <= response.status_code < 202:
|
|
62
58
|
raise Exception(
|
|
@@ -65,8 +61,8 @@ def _upload_child_level_json(C, parent_id, json):
|
|
|
65
61
|
return response
|
|
66
62
|
|
|
67
63
|
|
|
68
|
-
def _delete_object(
|
|
69
|
-
response =
|
|
64
|
+
def _delete_object(conn, object_id):
|
|
65
|
+
response = conn.delete(f"/objects('{object_id}')").json()
|
|
70
66
|
|
|
71
67
|
return response
|
|
72
68
|
|
|
@@ -88,8 +84,8 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
88
84
|
those objects to make sure they are available to the user. We then delete
|
|
89
85
|
them and repeat the search to check if they were properly removed from sumo.
|
|
90
86
|
"""
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
sumo_client = SumoClient(env="dev", token=token)
|
|
88
|
+
blob = b"123456789"
|
|
93
89
|
|
|
94
90
|
# Upload Ensemble
|
|
95
91
|
with open("tests/testdata/case.yml", "r") as stream:
|
|
@@ -98,7 +94,9 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
98
94
|
case_uuid = str(uuid.uuid4())
|
|
99
95
|
fmu_case_metadata["fmu"]["case"]["uuid"] = case_uuid
|
|
100
96
|
|
|
101
|
-
response_case = _upload_parent_object(
|
|
97
|
+
response_case = _upload_parent_object(
|
|
98
|
+
conn=sumo_client, json=fmu_case_metadata
|
|
99
|
+
)
|
|
102
100
|
|
|
103
101
|
assert 200 <= response_case.status_code <= 202
|
|
104
102
|
assert isinstance(response_case.json(), dict)
|
|
@@ -115,7 +113,7 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
115
113
|
fmu_surface_metadata["fmu"]["case"]["uuid"] = case_uuid
|
|
116
114
|
|
|
117
115
|
response_surface = _upload_child_level_json(
|
|
118
|
-
|
|
116
|
+
conn=sumo_client, parent_id=case_id, json=fmu_surface_metadata
|
|
119
117
|
)
|
|
120
118
|
|
|
121
119
|
assert 200 <= response_surface.status_code <= 202
|
|
@@ -126,7 +124,7 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
126
124
|
|
|
127
125
|
# Upload BLOB
|
|
128
126
|
response_blob = _upload_blob(
|
|
129
|
-
|
|
127
|
+
conn=sumo_client, blob=blob, url=blob_url, object_id=surface_id
|
|
130
128
|
)
|
|
131
129
|
assert 200 <= response_blob.status_code <= 202
|
|
132
130
|
|
|
@@ -135,7 +133,7 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
135
133
|
# Search for ensemble
|
|
136
134
|
query = f"fmu.case.uuid:{case_uuid}"
|
|
137
135
|
|
|
138
|
-
search_results =
|
|
136
|
+
search_results = sumo_client.get(
|
|
139
137
|
"/searchroot", params={"$query": query, "$select": ["_source"]}
|
|
140
138
|
).json()
|
|
141
139
|
|
|
@@ -144,28 +142,28 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
144
142
|
assert hits[0].get("_id") == case_id
|
|
145
143
|
|
|
146
144
|
# Search for child object
|
|
147
|
-
search_results =
|
|
145
|
+
search_results = sumo_client.get(
|
|
148
146
|
"/search", {"$query": query, "$select": ["_source"]}
|
|
149
147
|
).json()
|
|
150
148
|
|
|
151
149
|
total = search_results.get("hits").get("total").get("value")
|
|
152
150
|
assert total == 2
|
|
153
151
|
|
|
154
|
-
get_result = _download_object(
|
|
152
|
+
get_result = _download_object(sumo_client, object_id=surface_id)
|
|
155
153
|
assert get_result["_id"] == surface_id
|
|
156
154
|
|
|
157
155
|
# Search for blob
|
|
158
|
-
bin_obj =
|
|
159
|
-
assert bin_obj ==
|
|
156
|
+
bin_obj = sumo_client.get(f"/objects('{surface_id}')/blob").content
|
|
157
|
+
assert bin_obj == blob
|
|
160
158
|
|
|
161
159
|
# Delete Ensemble
|
|
162
|
-
result = _delete_object(
|
|
160
|
+
result = _delete_object(conn=sumo_client, object_id=case_id)
|
|
163
161
|
assert result == "Accepted"
|
|
164
162
|
|
|
165
163
|
sleep(40)
|
|
166
164
|
|
|
167
165
|
# Search for ensemble
|
|
168
|
-
search_results =
|
|
166
|
+
search_results = sumo_client.get(
|
|
169
167
|
"/searchroot", {"$query": query, "$select": ["_source"]}
|
|
170
168
|
).json()
|
|
171
169
|
|
|
@@ -174,7 +172,7 @@ def test_upload_search_delete_ensemble_child(token):
|
|
|
174
172
|
assert len(hits) == 0
|
|
175
173
|
|
|
176
174
|
# Search for child object
|
|
177
|
-
search_results =
|
|
175
|
+
search_results = sumo_client.get(
|
|
178
176
|
"/search", {"$query": query, "$select": ["_source"]}
|
|
179
177
|
).json()
|
|
180
178
|
total = search_results.get("hits").get("total").get("value")
|
|
@@ -185,16 +183,18 @@ def test_fail_on_wrong_metadata(token):
|
|
|
185
183
|
"""
|
|
186
184
|
Upload a parent object with erroneous metadata, confirm failure
|
|
187
185
|
"""
|
|
188
|
-
|
|
186
|
+
conn = SumoClient(env="dev", token=token)
|
|
189
187
|
with pytest.raises(Exception):
|
|
190
|
-
assert _upload_parent_object(
|
|
188
|
+
assert _upload_parent_object(
|
|
189
|
+
conn=conn, json={"some field": "some value"}
|
|
190
|
+
)
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
def test_upload_duplicate_ensemble(token):
|
|
194
194
|
"""
|
|
195
195
|
Adding a duplicate ensemble, both tries must return same id.
|
|
196
196
|
"""
|
|
197
|
-
|
|
197
|
+
conn = SumoClient(env="dev", token=token)
|
|
198
198
|
|
|
199
199
|
with open("tests/testdata/case.yml", "r") as stream:
|
|
200
200
|
fmu_metadata1 = yaml.safe_load(stream)
|
|
@@ -207,23 +207,23 @@ def test_upload_duplicate_ensemble(token):
|
|
|
207
207
|
fmu_metadata2["fmu"]["case"]["uuid"] = case_uuid
|
|
208
208
|
|
|
209
209
|
# upload case metadata, get object_id
|
|
210
|
-
response1 = _upload_parent_object(
|
|
210
|
+
response1 = _upload_parent_object(conn=conn, json=fmu_metadata1)
|
|
211
211
|
assert 200 <= response1.status_code <= 202
|
|
212
212
|
|
|
213
213
|
# upload duplicated case metadata, get object_id
|
|
214
|
-
response2 = _upload_parent_object(
|
|
214
|
+
response2 = _upload_parent_object(conn=conn, json=fmu_metadata2)
|
|
215
215
|
assert 200 <= response2.status_code <= 202
|
|
216
216
|
|
|
217
217
|
case_id1 = response1.json().get("objectid")
|
|
218
218
|
case_id2 = response2.json().get("objectid")
|
|
219
219
|
assert case_id1 == case_id2
|
|
220
220
|
|
|
221
|
-
get_result = _download_object(
|
|
221
|
+
get_result = _download_object(conn, object_id=case_id1)
|
|
222
222
|
assert get_result["_id"] == case_id1
|
|
223
223
|
|
|
224
224
|
# Delete Ensemble
|
|
225
225
|
sleep(5)
|
|
226
|
-
result = _delete_object(
|
|
226
|
+
result = _delete_object(conn=conn, object_id=case_id1)
|
|
227
227
|
assert result == "Accepted"
|
|
228
228
|
|
|
229
229
|
# Ugly: sumo-core has a cache for case objects, which has a
|
|
@@ -236,4 +236,4 @@ def test_upload_duplicate_ensemble(token):
|
|
|
236
236
|
|
|
237
237
|
# Search for ensemble
|
|
238
238
|
with pytest.raises(Exception):
|
|
239
|
-
assert _download_object(
|
|
239
|
+
assert _download_object(conn, object_id=case_id2)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: linting
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
push: { branches: [main] }
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
black:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
strategy:
|
|
11
|
-
matrix:
|
|
12
|
-
python-version: ["3.9"]
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
- name: Set up Python ${{ matrix.python-version }}
|
|
16
|
-
uses: actions/setup-python@v5
|
|
17
|
-
with:
|
|
18
|
-
python-version: ${{ matrix.python-version }}
|
|
19
|
-
- uses: psf/black@stable
|
|
20
|
-
with:
|
|
21
|
-
options: "--check --verbose --line-length 79"
|
|
22
|
-
src: "./src/sumo/wrapper"
|
|
23
|
-
flake8:
|
|
24
|
-
runs-on: ubuntu-latest
|
|
25
|
-
strategy:
|
|
26
|
-
matrix:
|
|
27
|
-
python-version: ["3.9"]
|
|
28
|
-
steps:
|
|
29
|
-
- uses: actions/checkout@v4
|
|
30
|
-
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
-
uses: actions/setup-python@v5
|
|
32
|
-
with:
|
|
33
|
-
python-version: ${{ matrix.python-version }}
|
|
34
|
-
- name: Install dependencies
|
|
35
|
-
run: |
|
|
36
|
-
python -m pip install --upgrade pip
|
|
37
|
-
pip install flake8
|
|
38
|
-
- name: Analysing the code with flake8
|
|
39
|
-
run: |
|
|
40
|
-
flake8 src/sumo/wrapper --config .flake8
|
|
File without changes
|
{sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/.github/workflows/publish_release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.14 → sumo_wrapper_python-1.0.15}/docs/_static/equinor_logo_only.jpg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import platform
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
from argparse import ArgumentParser
|
|
5
|
-
from
|
|
4
|
+
from pathlib import Path
|
|
6
5
|
|
|
6
|
+
from sumo.wrapper import SumoClient
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger("sumo.wrapper")
|
|
9
9
|
logger.setLevel(level="CRITICAL")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|