sumo-wrapper-python 1.0.13__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.

Files changed (48) hide show
  1. sumo_wrapper_python-1.0.15/.github/workflows/linting.yml +28 -0
  2. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/.gitignore +2 -1
  3. sumo_wrapper_python-1.0.15/.pre-commit-config.yaml +16 -0
  4. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/PKG-INFO +4 -1
  5. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/conf.py +0 -1
  6. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/pyproject.toml +30 -4
  7. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_auth_provider.py +14 -16
  8. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_logging.py +9 -4
  9. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_version.py +2 -2
  10. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/sumo_client.py +33 -13
  11. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/PKG-INFO +4 -1
  12. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/SOURCES.txt +2 -2
  13. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/requires.txt +4 -0
  14. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15/tests}/conftest.py +5 -0
  15. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/tests/test_sumo_thin_client.py +42 -42
  16. sumo_wrapper_python-1.0.13/.flake8 +0 -2
  17. sumo_wrapper_python-1.0.13/.github/workflows/linting.yml +0 -40
  18. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/.github/workflows/build_docs.yaml +0 -0
  19. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/.github/workflows/publish_release.yml +0 -0
  20. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/.github/workflows/pytest.yml +0 -0
  21. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/.readthedocs.yaml +0 -0
  22. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/CONTRIBUTING.md +0 -0
  23. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/LICENSE +0 -0
  24. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/README.md +0 -0
  25. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/SECURITY.md +0 -0
  26. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/Makefile +0 -0
  27. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/_static/equinor-logo.png +0 -0
  28. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/_static/equinor-logo2.jpg +0 -0
  29. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/_static/equinor_logo.jpg +0 -0
  30. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/_static/equinor_logo_only.jpg +0 -0
  31. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/_templates/layout.html +0 -0
  32. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/api.rst +0 -0
  33. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/index.rst +0 -0
  34. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/make.bat +0 -0
  35. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/docs/sumo-wrapper-python.rst +0 -0
  36. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/setup.cfg +0 -0
  37. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/__init__.py +0 -0
  38. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/__init__.py +1 -1
  39. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_blob_client.py +0 -0
  40. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_decorators.py +0 -0
  41. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/_retry_strategy.py +1 -1
  42. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/config.py +0 -0
  43. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo/wrapper/login.py +2 -2
  44. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  45. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  46. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  47. {sumo_wrapper_python-1.0.13 → sumo_wrapper_python-1.0.15}/tests/testdata/case.yml +0 -0
  48. {sumo_wrapper_python-1.0.13 → 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
+
@@ -12,4 +12,5 @@ build
12
12
  /src/testing.py
13
13
  /docs/_build
14
14
  /src/sumo/wrapper/version.py
15
- *_version.py
15
+ *_version.py
16
+ .vscode/
@@ -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.13
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
 
@@ -55,4 +55,3 @@ html_logo = "_static/equinor-logo2.jpg"
55
55
  # relative to this directory. They are copied after the builtin static files,
56
56
  # so a file named "default.css" will overwrite the builtin "default.css".
57
57
  html_static_path = ["_static"]
58
-
@@ -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
+
@@ -1,19 +1,19 @@
1
- import msal
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 azure.identity import ManagedIdentityCredential
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
- os.getenv(x)
427
- for x in [
428
- "AZURE_FEDERATED_TOKEN_FILE",
429
- "AZURE_TENANT_ID",
430
- "AZURE_CLIENT_ID",
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, sumoClient):
6
+ def __init__(self, sumo_client):
7
7
  logging.Handler.__init__(self)
8
- self._sumoClient = sumoClient
8
+ self._sumoClient = sumo_client
9
9
  return
10
10
 
11
11
  def emit(self, record):
12
12
  try:
13
- dt = datetime.utcnow().replace(microsecond=0).isoformat() + "Z"
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__.keys():
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)
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.0.13'
16
- __version_tuple__ = version_tuple = (1, 0, 13)
15
+ __version__ = version = '1.0.15'
16
+ __version_tuple__ = version_tuple = (1, 0, 15)
@@ -1,19 +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
8
 
6
- from ._blob_client import BlobClient
7
- from ._logging import LogHandlerSumo
8
9
  from ._auth_provider import get_auth_provider
9
- from .config import APP_REGISTRATION, TENANT_ID, AUTHORITY_HOST_URI
10
-
10
+ from ._blob_client import BlobClient
11
11
  from ._decorators import (
12
12
  raise_for_status,
13
13
  raise_for_status_async,
14
14
  )
15
-
15
+ from ._logging import LogHandlerSumo
16
16
  from ._retry_strategy import RetryStrategy
17
+ from .config import APP_REGISTRATION, AUTHORITY_HOST_URI, TENANT_ID
17
18
 
18
19
  logger = logging.getLogger("sumo.wrapper")
19
20
 
@@ -49,8 +50,8 @@ class SumoClient:
49
50
  raise ValueError(f"Invalid environment: {env}")
50
51
 
51
52
  self._retry_strategy = retry_strategy
52
- self._client = httpx.Client(follow_redirects=True)
53
- self._async_client = httpx.AsyncClient(follow_redirects=True)
53
+ self._client = httpx.Client()
54
+ self._async_client = httpx.AsyncClient()
54
55
 
55
56
  self._timeout = timeout
56
57
 
@@ -60,12 +61,10 @@ class SumoClient:
60
61
  logger.debug("Token provided")
61
62
 
62
63
  payload = None
63
- try:
64
+ with contextlib.suppress(jwt.InvalidTokenError):
64
65
  payload = jwt.decode(
65
66
  token, options={"verify_signature": False}
66
67
  )
67
- except jwt.InvalidTokenError:
68
- pass
69
68
 
70
69
  if payload:
71
70
  logger.debug(f"Token decoded as JWT, payload: {payload}")
@@ -197,12 +196,22 @@ class SumoClient:
197
196
 
198
197
  headers.update(self.auth.get_authorization())
199
198
 
199
+ follow_redirects = False
200
+ if (
201
+ re.match(
202
+ r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", # noqa: E501
203
+ path,
204
+ )
205
+ is not None
206
+ ):
207
+ follow_redirects = True
208
+
200
209
  def _get():
201
210
  return self._client.get(
202
211
  f"{self.base_url}{path}",
203
212
  params=params,
204
213
  headers=headers,
205
- follow_redirects=True,
214
+ follow_redirects=follow_redirects,
206
215
  timeout=self._timeout,
207
216
  )
208
217
 
@@ -369,7 +378,7 @@ class SumoClient:
369
378
 
370
379
  return retryer(_delete)
371
380
 
372
- def getLogger(self, name):
381
+ def get_logger(self, name):
373
382
  """Gets a logger object that sends log objects into the message_log
374
383
  index for the Sumo instance.
375
384
 
@@ -424,11 +433,22 @@ class SumoClient:
424
433
 
425
434
  headers.update(self.auth.get_authorization())
426
435
 
436
+ follow_redirects = False
437
+ if (
438
+ re.match(
439
+ r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", # noqa: E501
440
+ path,
441
+ )
442
+ is not None
443
+ ):
444
+ follow_redirects = True
445
+
427
446
  async def _get():
428
447
  return await self._async_client.get(
429
448
  f"{self.base_url}{path}",
430
449
  params=params,
431
450
  headers=headers,
451
+ follow_redirects=follow_redirects,
432
452
  timeout=self._timeout,
433
453
  )
434
454
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sumo-wrapper-python
3
- Version: 1.0.13
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
@@ -5,6 +5,10 @@ httpx>=0.24.1
5
5
  tenacity!=8.4.0,>=8.2.2
6
6
  azure-identity>=1.13.0
7
7
 
8
+ [dev]
9
+ ruff
10
+ pre-commit
11
+
8
12
  [docs]
9
13
  sphinx==7.1.2
10
14
  sphinx-rtd-theme
@@ -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
- class Connection:
16
- def __init__(self, token):
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(C, blob, url=None, object_id=None):
29
- response = C.api.blob_client.upload_blob(blob=blob, url=url)
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(C, object_id):
41
- response = C.api.get(f"/objects('{object_id}')/blob/authuri")
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(C, object_id):
53
- json = C.api.get(f"/objects('{object_id}')").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(C, parent_id, json):
59
- response = C.api.post(f"/objects('{parent_id}')", json=json)
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(C, object_id):
69
- response = C.api.delete(f"/objects('{object_id}')").json()
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
- C = Connection(token)
92
- B = b"123456789"
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(C=C, json=fmu_case_metadata)
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
- C=C, parent_id=case_id, json=fmu_surface_metadata
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
- C=C, blob=B, url=blob_url, object_id=surface_id
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 = C.api.get(
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 = C.api.get(
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(C, object_id=surface_id)
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 = C.api.get(f"/objects('{surface_id}')/blob").content
159
- assert bin_obj == B
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(C=C, object_id=case_id)
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 = C.api.get(
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 = C.api.get(
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
- C = Connection(token)
186
+ conn = SumoClient(env="dev", token=token)
189
187
  with pytest.raises(Exception):
190
- assert _upload_parent_object(C=C, json={"some field": "some value"})
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
- C = Connection(token)
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(C=C, json=fmu_metadata1)
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(C=C, json=fmu_metadata2)
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(C, object_id=case_id1)
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(C=C, object_id=case_id1)
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(C, object_id=case_id2)
239
+ assert _download_object(conn, object_id=case_id2)
@@ -1,2 +0,0 @@
1
- [flake8]
2
- max-line-length = 79
@@ -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
@@ -1,5 +1,5 @@
1
- from .sumo_client import SumoClient
2
1
  from ._retry_strategy import RetryStrategy
2
+ from .sumo_client import SumoClient
3
3
 
4
4
  try:
5
5
  from ._version import version
@@ -1,5 +1,5 @@
1
- import tenacity as tn
2
1
  import httpx
2
+ import tenacity as tn
3
3
 
4
4
 
5
5
  def _log_retry_info(retry_state):
@@ -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 sumo.wrapper import SumoClient
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")