Skip to content

Commit

Permalink
Remove store_folder and export_root attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Oct 18, 2021
1 parent 41bfcd6 commit f7e7ea8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
4 changes: 1 addition & 3 deletions src/fmu/dataio/_export_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ def __init__(
self.iterfolder = dataio.iterfolder
self.createfolder = dataio.createfolder

self.storefolder = self.dataio.runpath / self.dataio.export_root

if subfolder is not None:
warnings.warn(
"Exporting to a subfolder is a deviation from the standard "
Expand Down Expand Up @@ -888,7 +886,7 @@ def _construct_filename_fmustandard1(self):
Returns stem for file name and destination
"""
stem = "unset"
outroot = self.storefolder
outroot = self.dataio.runpath / "share" / "results"
loc = self.efolder

stem = self.name.lower()
Expand Down
3 changes: 0 additions & 3 deletions src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ class ExportData:
grid_fformat = "roff"
cube_fformat = "segy"

# this realization output which is relative to self._runpath!
export_root = "share/results"

# this is case folder which is "outside runs" i.e. another relative!
# e.g. /somepath/mycase/share/metadata
case_folder = "share/metadata"
Expand Down
1 change: 0 additions & 1 deletion tests/test_fmu_dataio_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def test_file_block(tmp_path):

shutil.copytree("tests/data/drogon/ertrun1", current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.surface_fformat = "irap_binary"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down
3 changes: 0 additions & 3 deletions tests/test_fmu_dataio_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def test_gridprop_io_larger_case(tmp_path):
grdp = xtgeo.GridProperty(ncol=2, nrow=7, nlay=13)
grdp.name = "poro"

fmu.dataio.ExportData.export_root = tmp_path.resolve()
fmu.dataio.ExportData.grid_fformat = "roff"

exp = fmu.dataio.ExportData(
Expand Down Expand Up @@ -139,7 +138,6 @@ def test_grid_io_larger_case_ertrun(tmp_path):

shutil.copytree(CASEPATH, current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.surface_fformat = "roff"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down Expand Up @@ -196,7 +194,6 @@ def test_gridprop_io_larger_case_ertrun(tmp_path):

shutil.copytree(CASEPATH, current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.surface_fformat = "roff"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down
7 changes: 3 additions & 4 deletions tests/test_fmu_dataio_polygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
(1.1, 2.0, 3.0, 2),
]
CASEPATH = "tests/data/drogon/ertrun1"
FMUP1 = "share/results"


def test_polygons_io(tmp_path):
"""Minimal test polygons io, uses tmp_path."""

srf = xtgeo.Polygons(POLY)
fmu.dataio.ExportData.export_root = tmp_path.resolve()
fmu.dataio.ExportData.polygons_fformat = "csv"

exp = fmu.dataio.ExportData(name="test", content="depth", runfolder=tmp_path)
exp = fmu.dataio.ExportData(name="test", content="depth", runpath=tmp_path)
exp.export(srf)

assert (tmp_path / "polygons" / ".test.csv.yml").is_file() is True
assert (tmp_path / FMUP1 / "polygons" / ".test.csv.yml").is_file() is True


def test_polygons_io_larger_case_ertrun(tmp_path):
Expand All @@ -63,7 +63,6 @@ def test_polygons_io_larger_case_ertrun(tmp_path):

shutil.copytree(CASEPATH, current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.polygons_fformat = "irap_ascii"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down
18 changes: 8 additions & 10 deletions tests/test_fmu_dataio_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ def test_surface_io(tmp_path):
srf = xtgeo.RegularSurface(
ncol=20, nrow=30, xinc=20, yinc=20, values=np.ma.ones((20, 30)), name="test"
)
fmu.dataio.ExportData.export_root = tmp_path.resolve()
fmu.dataio.ExportData.surface_fformat = "irap_binary"

exp = fmu.dataio.ExportData(content="depth", runfolder=tmp_path)
exp = fmu.dataio.ExportData(content="depth", runpath=tmp_path)
exp.export(srf)

assert (tmp_path / "maps" / "test.gri").is_file() is True
assert (tmp_path / "maps" / ".test.gri.yml").is_file() is True
assert (tmp_path / FMUP1 / "maps" / "test.gri").is_file() is True
assert (tmp_path / FMUP1 / "maps" / ".test.gri.yml").is_file() is True


def test_surface_io_export_subfolder(tmp_path):
Expand All @@ -58,15 +57,16 @@ def test_surface_io_export_subfolder(tmp_path):
srf = xtgeo.RegularSurface(
ncol=20, nrow=30, xinc=20, yinc=20, values=np.ma.ones((20, 30)), name="test"
)
fmu.dataio.ExportData.export_root = tmp_path.resolve()
fmu.dataio.ExportData.surface_fformat = "irap_binary"

exp = fmu.dataio.ExportData(content="depth", runfolder=tmp_path)
exp = fmu.dataio.ExportData(content="depth", runpath=tmp_path)
with pytest.warns(UserWarning):
exp.export(srf, subfolder="mysubfolder")

assert (tmp_path / "maps" / "mysubfolder" / "test.gri").is_file() is True
assert (tmp_path / "maps" / "mysubfolder" / ".test.gri.yml").is_file() is True
assert (tmp_path / FMUP1 / "maps" / "mysubfolder" / "test.gri").is_file() is True
assert (
tmp_path / FMUP1 / "maps" / "mysubfolder" / ".test.gri.yml"
).is_file() is True


def test_surface_io_larger_case(tmp_path):
Expand All @@ -81,7 +81,6 @@ def test_surface_io_larger_case(tmp_path):
values=np.ma.ones((20, 30)),
name="TopVolantis",
)
fmu.dataio.ExportData.export_root = tmp_path.resolve()
fmu.dataio.ExportData.surface_fformat = "irap_binary"

exp = fmu.dataio.ExportData(
Expand Down Expand Up @@ -114,7 +113,6 @@ def test_surface_io_larger_case_ertrun(tmp_path):

shutil.copytree(CASEPATH, current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.surface_fformat = "irap_binary"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down
12 changes: 5 additions & 7 deletions tests/test_fmu_dataio_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,19 @@ def test_table_io_arrow(tmp_path):
# make a small pa.Table
df = pd.DataFrame({"STOIIP": [123, 345, 654], "PORO": [0.2, 0.4, 0.3]})
table = pa.Table.from_pandas(df)
fmu.dataio.ExportData.export_root = tmp_path.resolve()

exp = fmu.dataio.ExportData(
name="test", verbosity="INFO", content="timeseries", runfolder=tmp_path
name="test", verbosity="INFO", content="timeseries", runpath=tmp_path
)
exp.export(table)

assert (tmp_path / "tables" / "test.arrow").is_file() is True
assert (tmp_path / "tables" / ".test.arrow.yml").is_file() is True
assert (tmp_path / FMUP1 / "tables" / "test.arrow").is_file() is True
assert (tmp_path / FMUP1 / "tables" / ".test.arrow.yml").is_file() is True

table_in = pa.feather.read_table(tmp_path / "tables" / "test.arrow")
table_in = pa.feather.read_table(tmp_path / FMUP1 / "tables" / "test.arrow")
assert table_in.num_columns == 2

with open(tmp_path / "tables" / ".test.arrow.yml") as stream:
with open(tmp_path / FMUP1 / "tables" / ".test.arrow.yml") as stream:
metadata = yaml.safe_load(stream)
assert metadata["data"]["layout"] == "table"
assert metadata["data"]["spec"]["size"] == 6
Expand All @@ -103,7 +102,6 @@ def test_tables_io_larger_case_ertrun(tmp_path):
current.mkdir(parents=True, exist_ok=True)
shutil.copytree(CASEPATH, current / "mycase")

fmu.dataio.ExportData.export_root = "share/results"
fmu.dataio.ExportData.table_fformat = "csv"

runfolder = current / "mycase" / "realization-0" / "iter-0" / "rms" / "model"
Expand Down

0 comments on commit f7e7ea8

Please sign in to comment.