From 00c4df18964da0744237958704aa3ba3659a8756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20C=2E=20Riven=C3=A6s?= Date: Sun, 17 Oct 2021 20:31:54 +0200 Subject: [PATCH] Change way of detecting if inside rms python env --- src/fmu/dataio/dataio.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fmu/dataio/dataio.py b/src/fmu/dataio/dataio.py index 1e4ea47aa..d296f9d01 100644 --- a/src/fmu/dataio/dataio.py +++ b/src/fmu/dataio/dataio.py @@ -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 @@ -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)