Skip to content

Commit

Permalink
Change way of detecting if inside rms python env
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Oct 18, 2021
1 parent 639d4c3 commit 00c4df1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import getpass
import json
import logging
import os
import pathlib
import re
import sys
import uuid
from collections import OrderedDict
from typing import Any, List, Optional, Union
Expand Down Expand Up @@ -245,12 +245,15 @@ def __init__(
# in tmp_path!
self._runpath = (self._pwd / "../../.").absolute()
logger.info("Pretend to run from inside RMS")
elif self._runpath is None and ("RMS_ENABLE_HAVANA_EXPORT" in os.environ):
elif (
self._runpath is None
and "rms" in sys.executable
and "komodo" not in sys.executable
):
# this is the case when running RMS which happens in runpath/rms/model
# menaing that actual root runpath is at ../.. Note:
# a bit fragile to rely on this variable, so TODO find more reliable method
# menaing that actual root runpath is at ../..
self._runpath = pathlib.Path("../../.").absolute()
logger.info("Detect 'inside RMS' from env var RMS_ENABLE_HAVANA_EXPORT")
logger.info("Detect 'inside RMS' from 'rms' being in sys.executable")
else:
self._runpath = self._pwd
logger.info("Assuming RUNPATH at PWD which is %s", self._pwd)
Expand Down

0 comments on commit 00c4df1

Please sign in to comment.