Skip to content

Commit ffc0dc0

Browse files
authored
Merge pull request #98 from NREL/local-scratch
Remove use of LOCAL_SCRATCH
2 parents 941c3f0 + 5b195e1 commit ffc0dc0

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

jade/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
import logging
44

5-
__version__ = "0.10.1"
5+
__version__ = "0.10.2"
66

77
logging.getLogger(__name__).addHandler(logging.NullHandler())

jade/hpc/slurm_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def get_job_stats(self, job_id):
254254
return stats
255255

256256
def get_local_scratch(self):
257-
for key in ("LOCAL_SCRATCH", "TMPDIR"):
257+
for key in ("TMPDIR",):
258258
if key in os.environ:
259259
return os.environ[key]
260260
return tempfile.gettempdir()

jade/utils/dataframe_utils.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@timed_debug
1919
def read_dataframe(filename, index_col=None, columns=None, parse_dates=False, **kwargs):
20-
"""Convert filename to a dataframe. Supports .csv, .json, .feather, .h5.
20+
"""Convert filename to a dataframe. Supports .csv, .json, .feather.
2121
Handles compressed files.
2222
2323
Parameters
@@ -64,11 +64,13 @@ def read_dataframe(filename, index_col=None, columns=None, parse_dates=False, **
6464
needs_new_index = True
6565
with open_func(filename, "rb") as f_in:
6666
df = pd.read_feather(f_in, **kwargs)
67-
elif ext == ".h5":
68-
# This assumes that the file has a single dataframe, and so the
69-
# key name is not relevant.
70-
df = pd.read_hdf(filename, **kwargs)
71-
needs_new_index = True
67+
# This requires the pytables library which is painful to install on many platforms.
68+
# Disable for now because the functionality isn't worth it.
69+
# elif ext == ".h5":
70+
# # This assumes that the file has a single dataframe, and so the
71+
# # key name is not relevant.
72+
# df = pd.read_hdf(filename, **kwargs)
73+
# needs_new_index = True
7274
else:
7375
raise InvalidParameter(f"unsupported file extension {ext}")
7476

@@ -184,13 +186,10 @@ def read_dataframes_by_substrings(
184186
def write_dataframe(df, file_path, compress=False, keep_original=False, **kwargs):
185187
"""Write the dataframe to a file with in a format matching the extension.
186188
187-
Note that the feather and h5 formats do not support row indices.
189+
Note that the feather formats do not support row indices.
188190
Index columns will be lost for those formats. If the dataframe has an index
189191
then it should be converted to a column before calling this function.
190192
191-
This function only supports storing a single dataframe inside an HDF5 file.
192-
It always uses the key 'data'.
193-
194193
Parameters
195194
----------
196195
df : pd.DataFrame
@@ -216,15 +215,16 @@ def write_dataframe(df, file_path, compress=False, keep_original=False, **kwargs
216215
df.to_csv(file_path, **kwargs)
217216
elif ext == ".feather":
218217
df.to_feather(file_path, **kwargs)
219-
elif ext == ".h5":
220-
# HDF5 supports built-in compression, levels 1-9
221-
if "complevel" in kwargs:
222-
complevel = kwargs["complevel"]
223-
elif compress:
224-
complevel = 9
225-
else:
226-
complevel = 0
227-
df.to_hdf(file_path, "data", mode="w", complevel=complevel, **kwargs)
218+
# See note above regarding pytables dependency.
219+
# elif ext == ".h5":
220+
# # HDF5 supports built-in compression, levels 1-9
221+
# if "complevel" in kwargs:
222+
# complevel = kwargs["complevel"]
223+
# elif compress:
224+
# complevel = 9
225+
# else:
226+
# complevel = 0
227+
# df.to_hdf(file_path, "data", mode="w", complevel=complevel, **kwargs)
228228
elif ext == ".json":
229229
df.to_json(file_path, **kwargs)
230230
else:

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ dev = [
6262
"sphinx>=2.0",
6363
"sphinxcontrib-plantuml",
6464
"statsmodels",
65-
"tables",
6665
"tox",
6766
]
6867

tests/unit/utils/test_dataframe_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_read_dataframe__feather():
6565
assert_frame_equal(df1, df2)
6666

6767

68+
@mark.skip
6869
def test_read_dataframe__h5():
6970
"""Should create identical dataframe on reading HDF5 file
7071
@@ -155,6 +156,7 @@ def test_write_dataframe__feather(compress):
155156
assert_frame_equal(df1, df2)
156157

157158

159+
@mark.skip
158160
@mark.parametrize("compress", [False, True])
159161
def test_write_dataframe__h5(compress):
160162
"""Should write dataframe into a file with matching extension"""

0 commit comments

Comments
 (0)