From a7ef87a209fd61060e8506f994c7ec100b548aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= <31612826+anders-kiaer@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:30:15 +0000 Subject: [PATCH] Change to `async` SUMO calls --- backend/poetry.lock | 140 +++--------------- .../primary/routers/timeseries/router.py | 28 ++-- .../services/sumo_access/summary_access.py | 18 ++- 3 files changed, 42 insertions(+), 144 deletions(-) diff --git a/backend/poetry.lock b/backend/poetry.lock index acfb4e39f..ee1678cda 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "annotated-types" version = "0.5.0" description = "Reusable constraint types to use with typing.Annotated" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -16,7 +15,6 @@ files = [ name = "anyio" version = "3.7.1" description = "High level compatibility layer for multiple asynchronous event loop implementations" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -38,7 +36,6 @@ trio = ["trio (<0.22)"] name = "astroid" version = "2.15.4" description = "An abstract syntax tree for Python with inference support." -category = "dev" optional = false python-versions = ">=3.7.2" files = [ @@ -58,7 +55,6 @@ wrapt = [ name = "async-timeout" version = "4.0.2" description = "Timeout context manager for asyncio programs" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -70,7 +66,6 @@ files = [ name = "azure-core" version = "1.26.2" description = "Microsoft Azure Core Library for Python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -90,7 +85,6 @@ aio = ["aiohttp (>=3.0)"] name = "bandit" version = "1.7.5" description = "Security oriented static analyser for python code." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -114,7 +108,6 @@ yaml = ["PyYAML"] name = "black" version = "22.12.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -149,7 +142,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "blosc2" version = "2.0.0" description = "Python wrapper for the C-Blosc2 library." -category = "main" optional = false python-versions = ">=3.8, <4" files = [ @@ -183,7 +175,6 @@ msgpack = "*" name = "bottleneck" version = "1.3.7" description = "Fast NumPy array functions written in C" -category = "main" optional = false python-versions = "*" files = [ @@ -242,7 +233,6 @@ doc = ["gitpython", "numpydoc", "sphinx"] name = "certifi" version = "2022.12.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -254,7 +244,6 @@ files = [ name = "cffi" version = "1.15.1" description = "Foreign Function Interface for Python calling C code." -category = "main" optional = false python-versions = "*" files = [ @@ -331,7 +320,6 @@ pycparser = "*" name = "charset-normalizer" version = "3.0.1" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = "*" files = [ @@ -429,7 +417,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -444,7 +431,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -456,7 +442,6 @@ files = [ name = "contourpy" version = "1.0.7" description = "Python library for calculating contours of 2D quadrilateral grids" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -531,7 +516,6 @@ test-no-images = ["pytest"] name = "cryptography" version = "39.0.0" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -575,7 +559,6 @@ test = ["hypothesis (>=1.11.4,!=3.79.2)", "iso8601", "pretend", "pytest (>=6.2.0 name = "cycler" version = "0.11.0" description = "Composable style cycles" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -587,7 +570,6 @@ files = [ name = "cython" version = "0.29.34" description = "The Cython compiler for writing C extensions for the Python language." -category = "main" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -637,7 +619,6 @@ files = [ name = "deprecation" version = "2.1.0" description = "A library to handle automated deprecations" -category = "main" optional = false python-versions = "*" files = [ @@ -652,7 +633,6 @@ packaging = "*" name = "dill" version = "0.3.6" description = "serialize all of python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -667,7 +647,6 @@ graph = ["objgraph (>=1.7.2)"] name = "ecl-data-io" version = "2.1.0" description = "A (lazy) parser and writer for the ecl output format." -category = "main" optional = false python-versions = "*" files = [ @@ -682,7 +661,6 @@ numpy = "*" name = "exceptiongroup" version = "1.1.1" description = "Backport of PEP 654 (exception groups)" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -697,7 +675,6 @@ test = ["pytest (>=6)"] name = "fastapi" version = "0.103.1" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -716,14 +693,13 @@ all = ["email-validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)" [[package]] name = "fmu-sumo" -version = "0.3.10" +version = "0.3.11" description = "Python package for interacting with Sumo in an FMU setting" -category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "fmu-sumo-0.3.10.tar.gz", hash = "sha256:e71e2dd0cdca6fc9c802add0742a73369d22279e0a5f7b26c470c6760c5fca07"}, - {file = "fmu_sumo-0.3.10-py3-none-any.whl", hash = "sha256:f4f52e0434d5bd7a800d9ac553ca251012a8d03770a55a0d3508eaf432cf9880"}, + {file = "fmu-sumo-0.3.11.tar.gz", hash = "sha256:bd6b9dd2914825af1f9a9233d39b709271c3a60ac61f3a1df4794222a982734d"}, + {file = "fmu_sumo-0.3.11-py3-none-any.whl", hash = "sha256:6f848b5c93372e73d1aa8490ef6cc7ae197ae9511db12a3d680cddab73812a12"}, ] [package.dependencies] @@ -744,7 +720,6 @@ tests = ["pytest (>=6.1.1)", "pytest-timeout"] name = "fonttools" version = "4.39.3" description = "Tools to manipulate font files" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -770,7 +745,6 @@ woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"] name = "gitdb" version = "4.0.10" description = "Git Object Database" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -785,7 +759,6 @@ smmap = ">=3.0.1,<6" name = "gitpython" version = "3.1.31" description = "GitPython is a Python library used to interact with Git repositories" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -800,7 +773,6 @@ gitdb = ">=4.0.1,<5" name = "h11" version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -812,7 +784,6 @@ files = [ name = "h5py" version = "3.8.0" description = "Read and write HDF5 files from Python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -850,7 +821,6 @@ numpy = ">=1.14.5" name = "hdf5plugin" version = "4.1.1" description = "HDF5 Plugins for Windows, MacOS, and Linux" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -872,7 +842,6 @@ dev = ["sphinx", "sphinx-rtd-theme"] name = "httpcore" version = "0.17.0" description = "A minimal low-level HTTP client." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -884,22 +853,21 @@ files = [ anyio = ">=3.0,<5.0" certifi = "*" h11 = ">=0.13,<0.15" -sniffio = ">=1.0.0,<2.0.0" +sniffio = "==1.*" [package.extras] http2 = ["h2 (>=3,<5)"] -socks = ["socksio (>=1.0.0,<2.0.0)"] +socks = ["socksio (==1.*)"] [[package]] name = "httpx" -version = "0.24.0" +version = "0.24.1" description = "The next generation HTTP client." -category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "httpx-0.24.0-py3-none-any.whl", hash = "sha256:447556b50c1921c351ea54b4fe79d91b724ed2b027462ab9a329465d147d5a4e"}, - {file = "httpx-0.24.0.tar.gz", hash = "sha256:507d676fc3e26110d41df7d35ebd8b3b8585052450f4097401c9be59d928c63e"}, + {file = "httpx-0.24.1-py3-none-any.whl", hash = "sha256:06781eb9ac53cde990577af654bd990a4949de37a28bdb4a230d434f3a30b9bd"}, + {file = "httpx-0.24.1.tar.gz", hash = "sha256:5853a43053df830c20f8110c5e69fe44d035d850b2dfe795e196f00fdb774bdd"}, ] [package.dependencies] @@ -910,15 +878,14 @@ sniffio = "*" [package.extras] brotli = ["brotli", "brotlicffi"] -cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<14)"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] -socks = ["socksio (>=1.0.0,<2.0.0)"] +socks = ["socksio (==1.*)"] [[package]] name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -930,7 +897,6 @@ files = [ name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -942,7 +908,6 @@ files = [ name = "isort" version = "5.12.0" description = "A Python utility / library to sort Python imports." -category = "dev" optional = false python-versions = ">=3.8.0" files = [ @@ -960,7 +925,6 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] name = "itsdangerous" version = "2.1.2" description = "Safely pass data to untrusted environments and back." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -972,7 +936,6 @@ files = [ name = "kiwisolver" version = "1.4.4" description = "A fast implementation of the Cassowary constraint solver" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1050,7 +1013,6 @@ files = [ name = "lazy-object-proxy" version = "1.9.0" description = "A fast and thorough lazy object proxy." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1096,7 +1058,6 @@ files = [ name = "llvmlite" version = "0.40.0" description = "lightweight wrapper around basic LLVM functionality" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1130,7 +1091,6 @@ files = [ name = "markdown-it-py" version = "2.2.0" description = "Python port of markdown-it. Markdown parsing, done right!" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1155,7 +1115,6 @@ testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] name = "matplotlib" version = "3.7.1" description = "Python plotting package" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1217,7 +1176,6 @@ python-dateutil = ">=2.7" name = "mccabe" version = "0.7.0" description = "McCabe checker, plugin for flake8" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1229,7 +1187,6 @@ files = [ name = "mdurl" version = "0.1.2" description = "Markdown URL utilities" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1241,7 +1198,6 @@ files = [ name = "msal" version = "1.20.0" description = "The Microsoft Authentication Library (MSAL) for Python library enables your app to access the Microsoft Cloud by supporting authentication of users with Microsoft Azure Active Directory accounts (AAD) and Microsoft Accounts (MSA) using industry standard OAuth2 and OpenID Connect." -category = "main" optional = false python-versions = "*" files = [ @@ -1261,7 +1217,6 @@ broker = ["pymsalruntime (>=0.11.2,<0.14)"] name = "msal-extensions" version = "1.0.0" description = "Microsoft Authentication Library extensions (MSAL EX) provides a persistence API that can save your data on disk, encrypted on Windows, macOS and Linux. Concurrent data access will be coordinated by a file lock mechanism." -category = "main" optional = false python-versions = "*" files = [ @@ -1280,7 +1235,6 @@ portalocker = [ name = "msgpack" version = "1.0.4" description = "MessagePack serializer" -category = "main" optional = false python-versions = "*" files = [ @@ -1342,7 +1296,6 @@ files = [ name = "mypy" version = "1.5.1" description = "Optional static typing for Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1389,7 +1342,6 @@ reports = ["lxml"] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -1401,7 +1353,6 @@ files = [ name = "numba" version = "0.57.0" description = "compiling Python code using LLVM" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1432,14 +1383,13 @@ files = [ ] [package.dependencies] -llvmlite = ">=0.40.0dev0,<0.41" +llvmlite = "==0.40.*" numpy = ">=1.21,<1.25" [[package]] name = "numexpr" version = "2.8.4" description = "Fast numerical expression evaluator for NumPy" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1482,7 +1432,6 @@ numpy = ">=1.13.3" name = "numpy" version = "1.24.3" description = "Fundamental package for array computing in Python" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1520,7 +1469,6 @@ files = [ name = "openvds" version = "3.2.4" description = "Open-source implementation of the Volume Data Store (VDS) standard for fast random access to multi-dimensional volumetric data." -category = "main" optional = false python-versions = "*" files = [ @@ -1544,7 +1492,6 @@ numpy = "*" name = "orjson" version = "3.8.11" description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" -category = "main" optional = false python-versions = ">= 3.7" files = [ @@ -1605,7 +1552,6 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1617,7 +1563,6 @@ files = [ name = "pandas" version = "2.0.1" description = "Powerful data structures for data analysis, time series, and statistics" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1653,7 +1598,7 @@ bottleneck = {version = ">=1.3.2", optional = true, markers = "extra == \"perfor numba = {version = ">=0.53.1", optional = true, markers = "extra == \"performance\""} numexpr = {version = ">=2.7.1", optional = true, markers = "extra == \"performance\""} numpy = [ - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, ] python-dateutil = ">=2.8.2" @@ -1687,7 +1632,6 @@ xml = ["lxml (>=4.6.3)"] name = "pathspec" version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1699,7 +1643,6 @@ files = [ name = "pbr" version = "5.11.1" description = "Python Build Reasonableness" -category = "dev" optional = false python-versions = ">=2.6" files = [ @@ -1711,7 +1654,6 @@ files = [ name = "pillow" version = "9.5.0" description = "Python Imaging Library (Fork)" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1791,7 +1733,6 @@ tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "pa name = "platformdirs" version = "2.6.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1807,7 +1748,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest- name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1823,7 +1763,6 @@ testing = ["pytest", "pytest-benchmark"] name = "portalocker" version = "2.7.0" description = "Wraps the portalocker recipe for easy usage" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -1843,7 +1782,6 @@ tests = ["pytest (>=5.4.1)", "pytest-cov (>=2.8.1)", "pytest-mypy (>=0.8.0)", "p name = "psutil" version = "5.9.5" description = "Cross-platform lib for process and system monitoring in Python." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -1870,7 +1808,6 @@ test = ["enum34", "ipaddress", "mock", "pywin32", "wmi"] name = "py-cpuinfo" version = "9.0.0" description = "Get CPU info with pure Python" -category = "main" optional = false python-versions = "*" files = [ @@ -1882,7 +1819,6 @@ files = [ name = "pyarrow" version = "10.0.1" description = "Python library for Apache Arrow" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1920,7 +1856,6 @@ numpy = ">=1.16.6" name = "pycparser" version = "2.21" description = "C parser in Python" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -1932,7 +1867,6 @@ files = [ name = "pydantic" version = "2.3.0" description = "Data validation using Python type hints" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1952,7 +1886,6 @@ email = ["email-validator (>=2.0.0)"] name = "pydantic-core" version = "2.6.3" description = "" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2071,7 +2004,6 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" name = "pygments" version = "2.15.1" description = "Pygments is a syntax highlighting package written in Python." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -2086,7 +2018,6 @@ plugins = ["importlib-metadata"] name = "pyjwt" version = "2.6.0" description = "JSON Web Token implementation in Python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2107,7 +2038,6 @@ tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"] name = "pylint" version = "2.17.3" description = "python code static checker" -category = "dev" optional = false python-versions = ">=3.7.2" files = [ @@ -2136,7 +2066,6 @@ testutils = ["gitpython (>3)"] name = "pyparsing" version = "3.0.9" description = "pyparsing module - Classes and methods to define and execute parsing grammars" -category = "main" optional = false python-versions = ">=3.6.8" files = [ @@ -2151,7 +2080,6 @@ diagrams = ["jinja2", "railroad-diagrams"] name = "pytest" version = "7.3.1" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -2174,7 +2102,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "python-dateutil" version = "2.8.2" description = "Extensions to the standard Python datetime module" -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -2189,7 +2116,6 @@ six = ">=1.5" name = "python-dotenv" version = "0.21.1" description = "Read key-value pairs from a .env file and set them as environment variables" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2204,7 +2130,6 @@ cli = ["click (>=5.0)"] name = "pytz" version = "2022.7.1" description = "World timezone definitions, modern and historical" -category = "main" optional = false python-versions = "*" files = [ @@ -2216,7 +2141,6 @@ files = [ name = "pywin32" version = "306" description = "Python for Window Extensions" -category = "main" optional = false python-versions = "*" files = [ @@ -2240,7 +2164,6 @@ files = [ name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -2290,7 +2213,6 @@ files = [ name = "redis" version = "4.4.2" description = "Python client for Redis database and key-value store" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2309,7 +2231,6 @@ ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)" name = "requests" version = "2.29.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2331,7 +2252,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "rich" version = "13.3.5" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "dev" optional = false python-versions = ">=3.7.0" files = [ @@ -2350,7 +2270,6 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] name = "roffio" version = "0.0.2" description = "A (lazy) parser and writer for the Roxar Open File Format (ROFF)." -category = "main" optional = false python-versions = "*" files = [ @@ -2365,7 +2284,6 @@ numpy = "*" name = "scipy" version = "1.9.3" description = "Fundamental algorithms for scientific computing in Python" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -2404,7 +2322,6 @@ test = ["asv", "gmpy2", "mpmath", "pytest", "pytest-cov", "pytest-xdist", "sciki name = "segyio" version = "1.9.11" description = "Simple & fast IO for SEG-Y files" -category = "main" optional = false python-versions = "*" files = [ @@ -2453,7 +2370,6 @@ numpy = ">=1.10" name = "setuptools" version = "67.7.2" description = "Easily download, build, install, upgrade, and uninstall Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2470,7 +2386,6 @@ testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs ( name = "shapely" version = "2.0.1" description = "Manipulation and analysis of geometric objects" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2518,14 +2433,13 @@ files = [ numpy = ">=1.14" [package.extras] -docs = ["matplotlib", "numpydoc (>=1.1.0,<1.2.0)", "sphinx", "sphinx-book-theme", "sphinx-remove-toctrees"] +docs = ["matplotlib", "numpydoc (==1.1.*)", "sphinx", "sphinx-book-theme", "sphinx-remove-toctrees"] test = ["pytest", "pytest-cov"] [[package]] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -2537,7 +2451,6 @@ files = [ name = "smmap" version = "5.0.0" description = "A pure Python implementation of a sliding window memory map manager" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -2549,7 +2462,6 @@ files = [ name = "sniffio" version = "1.3.0" description = "Sniff out which async library your code is running under" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2561,7 +2473,6 @@ files = [ name = "starlette" version = "0.27.0" description = "The little ASGI library that shines." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2579,7 +2490,6 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyam name = "starsessions" version = "2.1.2" description = "Advanced sessions for Starlette and FastAPI frameworks" -category = "main" optional = false python-versions = ">=3.8.0,<4.0.0" files = [ @@ -2598,7 +2508,6 @@ redis = ["redis (>=4.2.0rc1)"] name = "stevedore" version = "5.0.0" description = "Manage dynamic plugins for Python applications" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -2611,22 +2520,21 @@ pbr = ">=2.0.0,<2.1.0 || >2.1.0" [[package]] name = "sumo-wrapper-python" -version = "0.3.4" +version = "0.3.5" description = "Python wrapper for the Sumo API" -category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "sumo-wrapper-python-0.3.4.tar.gz", hash = "sha256:3d9eaf7c508b0a66b59d19d246fc7c143bca3a905f40eeb57615d6d3d86a1605"}, - {file = "sumo_wrapper_python-0.3.4-py3-none-any.whl", hash = "sha256:c9e5b634512884bce501aa14b1cd3376bdb7383c5d3594745198df07fe462f31"}, + {file = "sumo-wrapper-python-0.3.5.tar.gz", hash = "sha256:057bf096c382760605ac3e4259b93c00fc771e9e0be8c926d782ce5e03c9c2f5"}, + {file = "sumo_wrapper_python-0.3.5-py3-none-any.whl", hash = "sha256:53bbd6eebf05e10dc7d0215d2c3a8facb232f69277effbf0b42409915d134c7b"}, ] [package.dependencies] +httpx = ">=0.24.1" msal = ">=1.18.0" msal-extensions = ">=1.0.0" pyjwt = ">=2.4.0" PyYAML = ">=5.4" -requests = ">=2.24.0" setuptools = ">=49.2.1" [package.extras] @@ -2637,7 +2545,6 @@ test = ["black", "flake8", "pylint", "pytest (>=6.1.1)"] name = "tables" version = "3.8.0" description = "Hierarchical datasets for Python" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -2675,7 +2582,6 @@ doc = ["ipython", "numpydoc", "sphinx (>=1.1)", "sphinx-rtd-theme"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -2687,7 +2593,6 @@ files = [ name = "tomlkit" version = "0.11.8" description = "Style preserving TOML library" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -2699,7 +2604,6 @@ files = [ name = "types-requests" version = "2.31.0.1" description = "Typing stubs for requests" -category = "dev" optional = false python-versions = "*" files = [ @@ -2714,7 +2618,6 @@ types-urllib3 = "*" name = "types-urllib3" version = "1.26.25.13" description = "Typing stubs for urllib3" -category = "dev" optional = false python-versions = "*" files = [ @@ -2726,7 +2629,6 @@ files = [ name = "typing-extensions" version = "4.7.1" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2738,7 +2640,6 @@ files = [ name = "tzdata" version = "2023.3" description = "Provider of IANA time zone data" -category = "main" optional = false python-versions = ">=2" files = [ @@ -2750,7 +2651,6 @@ files = [ name = "urllib3" version = "1.26.15" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ @@ -2767,7 +2667,6 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] name = "uvicorn" version = "0.20.0" description = "The lightning-fast ASGI server." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2786,7 +2685,6 @@ standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", name = "vtk" version = "9.2.6" description = "VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization" -category = "main" optional = false python-versions = "*" files = [ @@ -2824,7 +2722,6 @@ web = ["wslink (>=1.0.4)"] name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -2909,7 +2806,6 @@ files = [ name = "xtgeo" version = "3.0.0" description = "XTGeo is a Python library for 3D grids, surfaces, wells, etc" -category = "main" optional = false python-versions = "*" files = [ diff --git a/backend/src/backend/primary/routers/timeseries/router.py b/backend/src/backend/primary/routers/timeseries/router.py index 81c7a684b..a7b3c47c8 100644 --- a/backend/src/backend/primary/routers/timeseries/router.py +++ b/backend/src/backend/primary/routers/timeseries/router.py @@ -20,14 +20,14 @@ @router.get("/vector_list/") -def get_vector_list( +async def get_vector_list( authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], ensemble_name: Annotated[str, Query(description="Ensemble name")], ) -> list[schemas.VectorDescription]: """Get list of all vectors in a given Sumo ensemble, excluding any historical vectors""" - access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) vector_info_arr = access.get_available_vectors() ret_arr: list[schemas.VectorDescription] = [ @@ -39,7 +39,7 @@ def get_vector_list( @router.get("/realizations_vector_data/") -def get_realizations_vector_data( +async def get_realizations_vector_data( # fmt:off authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], @@ -52,7 +52,7 @@ def get_realizations_vector_data( ) -> list[schemas.VectorRealizationData]: """Get vector data per realization""" - access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) sumo_freq = Frequency.from_string_value(resampling_frequency.value if resampling_frequency else "dummy") sumo_vec_arr = access.get_vector( @@ -77,7 +77,7 @@ def get_realizations_vector_data( @router.get("/timestamps_list/") -def get_timestamps_list( +async def get_timestamps_list( authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], ensemble_name: Annotated[str, Query(description="Ensemble name")], @@ -91,14 +91,14 @@ def get_timestamps_list( For other resampling frequencies, the date range will be expanded to cover the entire time range of all the requested realizations before computing the resampled dates. """ - access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) sumo_freq = Frequency.from_string_value(resampling_frequency.value if resampling_frequency else "dummy") return access.get_timestamps(resampling_frequency=sumo_freq) @router.get("/historical_vector_data/") # type: ignore [empty-body] -def get_historical_vector_data( +async def get_historical_vector_data( authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], ensemble_name: Annotated[str, Query(description="Ensemble name")], @@ -106,7 +106,7 @@ def get_historical_vector_data( resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency")] = None, # relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None, ) -> schemas.VectorHistoricalData: - access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) sumo_freq = Frequency.from_string_value(resampling_frequency.value if resampling_frequency else "dummy") sumo_hist_vec = access.get_matching_historical_vector( @@ -125,7 +125,7 @@ def get_historical_vector_data( @router.get("/statistical_vector_data/") -def get_statistical_vector_data( +async def get_statistical_vector_data( # fmt:off authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], @@ -139,7 +139,7 @@ def get_statistical_vector_data( ) -> schemas.VectorStatisticData: """Get statistical vector data for an ensemble""" - access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) service_freq = Frequency.from_string_value(resampling_frequency.value) service_stat_funcs_to_compute = converters.to_service_statistic_functions(statistic_functions) @@ -160,7 +160,7 @@ def get_statistical_vector_data( @router.get("/statistical_vector_data_per_sensitivity/") -def get_statistical_vector_data_per_sensitivity( +async def get_statistical_vector_data_per_sensitivity( # fmt:off authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], @@ -173,7 +173,7 @@ def get_statistical_vector_data_per_sensitivity( ) -> list[schemas.VectorStatisticSensitivityData]: """Get statistical vector data for an ensemble per sensitivity""" - summmary_access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + summmary_access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) parameter_access = ParameterAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) sensitivities = parameter_access.get_parameters_and_sensitivities().sensitivities @@ -211,7 +211,7 @@ def get_statistical_vector_data_per_sensitivity( @router.get("/realization_vector_at_timestamp/") -def get_realization_vector_at_timestamp( +async def get_realization_vector_at_timestamp( # fmt:off authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], case_uuid: Annotated[str, Query(description="Sumo case uuid")], @@ -221,7 +221,7 @@ def get_realization_vector_at_timestamp( # realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be returned.")] = None, # fmt:on ) -> EnsembleScalarResponse: - summary_access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) + summary_access = await SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) ensemble_response = summary_access.get_vector_values_at_timestamp( vector_name=vector_name, timestamp_utc_ms=timestamp_utc_ms, realizations=None ) diff --git a/backend/src/services/sumo_access/summary_access.py b/backend/src/services/sumo_access/summary_access.py index e1fb859c7..2114285ea 100644 --- a/backend/src/services/sumo_access/summary_access.py +++ b/backend/src/services/sumo_access/summary_access.py @@ -20,18 +20,20 @@ LOGGER = logging.getLogger(__name__) - class SummaryAccess: - def __init__(self, access_token: str, case_uuid: str, iteration_name: str): + def __init__(self, case: Case, iteration_name: str): + self._case: Case = case + self._iteration_name: str = iteration_name + + @staticmethod + async def from_case_uuid(access_token: str, case_uuid: str, iteration_name: str) -> "SummaryAccess": sumo_client: SumoClient = create_sumo_client_instance(access_token) case_collection = CaseCollection(sumo_client).filter(uuid=case_uuid) - if len(case_collection) == 0: - raise ValueError(f"Could not find sumo cases {case_uuid=}") - if len(case_collection) > 1: - raise ValueError(f"Multiple sumo cases found {case_uuid=}") + if await case_collection.length_async() != 1: + raise ValueError(f"None or multiple sumo cases found {case_uuid=}") - self._case: Case = case_collection[0] - self._iteration_name: str = iteration_name + case = case_collection[0] + return SummaryAccess(case=case, iteration_name=iteration_name) def get_available_vectors(self) -> List[VectorInfo]: timer = PerfTimer()