Skip to content

Commit

Permalink
Handle missing OpenVDS, add warnings (#200)
Browse files Browse the repository at this point in the history
adnejacobsen authored Aug 31, 2023
1 parent e348f5b commit ad21f6d
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ This package is intended for interaction with Sumo within the FMU (Fast Model Up

## Explorer

> :warning: OpenVDS does not publish builds for MacOS. You can still use the Explorer without OpenVDS, but some Cube methods will not work.
Explore and retrieve data from Sumo.

```python
4 changes: 4 additions & 0 deletions docs/explorer.rst
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ Api Reference

- `API reference <apiref/fmu.sumo.explorer.html>`_

.. warning::
OpenVDS does not publish builds for MacOS. You can still use the Explorer without OpenVDS,
but some Cube methods will not work.

Usage and examples
------------------

19 changes: 15 additions & 4 deletions src/fmu/sumo/explorer/objects/cube.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"""Module containing class for cube object"""
import json
import openvds
from typing import Dict
from sumo.wrapper import SumoClient
from fmu.sumo.explorer.objects._child import Child
import sys
import warnings

if sys.platform == "darwin":
try:
import openvds
except ImportError:
warnings.warn("OpenVDS is missing. Some Cube methods will not work.")
else:
import openvds


class Cube(Child):
@@ -29,7 +38,9 @@ def _populate_url(self):
self._url = res.decode("UTF-8")

async def _populate_url_async(self):
res = await self._sumo.get_async(f"/objects('{self.uuid}')/blob/authuri")
res = await self._sumo.get_async(
f"/objects('{self.uuid}')/blob/authuri"
)
try:
res = json.loads(res.decode("UTF-8"))
self._url = res.get("baseuri") + self.uuid
@@ -74,7 +85,7 @@ async def sas_async(self) -> str:
return self._sas

@property
def openvds_handle(self) -> openvds.core.VDS:
def openvds_handle(self):
if self._url is None:
self._populate_url()

@@ -86,7 +97,7 @@ def openvds_handle(self) -> openvds.core.VDS:
return openvds.open(url, sas)

@property
async def openvds_handle_async(self) -> openvds.core.VDS:
async def openvds_handle_async(self):
if self._url is None:
await self._populate_url_async()

0 comments on commit ad21f6d

Please sign in to comment.