Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022-09-19-mp-elemental-reference-entries.json missing #17

Closed
pbenner opened this issue Apr 29, 2023 · 3 comments · Fixed by #21
Closed

2022-09-19-mp-elemental-reference-entries.json missing #17

pbenner opened this issue Apr 29, 2023 · 3 comments · Fixed by #21
Labels
bug Something isn't working

Comments

@pbenner
Copy link
Collaborator

pbenner commented Apr 29, 2023

> python fetch_process_wbm_dataset.py 
Downloading 'wbm_summary' from https://figshare.com/ndownloader/files/40344475
Cached 'wbm_summary' to '/home/pbenner/.cache/matbench-discovery/1.0.0/wbm/2022-10-19-wbm-summary.csv'
Traceback (most recent call last):
  File "/home/pbenner/Source/tmp/matbench-discovery/data/wbm/fetch_process_wbm_dataset.py", line 25, in <module>
    from matbench_discovery.energy import get_e_form_per_atom
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/matbench_discovery/energy.py", line 66, in <module>
    pd.read_json(DATA_FILES.mp_elemental_ref_entries, typ="series")
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/pandas/io/json/_json.py", line 733, in read_json
    json_reader = JsonReader(
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/pandas/io/json/_json.py", line 818, in __init__
    data = self._get_data_from_filepath(filepath_or_buffer)
  File "/home/pbenner/.local/opt/anaconda3/envs/crysfeat/lib/python3.10/site-packages/pandas/io/json/_json.py", line 874, in _get_data_from_filepath
    raise FileNotFoundError(f"File {filepath_or_buffer} does not exist")
FileNotFoundError: File /home/pbenner/.cache/matbench-discovery/1.0.0/mp/2022-09-19-mp-elemental-reference-entries.json does not exist

Solved this issue using:

> mkdir /home/pbenner/.cache/matbench-discovery/1.0.0/mp/
> cp ../mp/2022-09-19-mp-elemental-reference-entries.json /home/pbenner/.cache/matbench-discovery/1.0.0/mp/
@janosh janosh added the bug Something isn't working label Apr 29, 2023
@janosh
Copy link
Owner

janosh commented Apr 30, 2023

Are you sure you're running the latest code? It should prompt you to download that file on the fly if it doesn't exist yet. Maybe this answer = "" if sys.stdin.isatty() else "y" doesn't work as I expect...

class DataFiles(Files):
"""Data files provided by Matbench Discovery.
See https://janosh.github.io/matbench-discovery/contribute for data descriptions.
"""
def _on_not_found(self, key: str, msg: str) -> None: # type: ignore[override]
msg += (
" Would you like to download it now using matbench_discovery."
f"data.load_train_test({key!r}). This will cache the file for future use."
)
# default to 'y' if not in interactive session, and user can't answer
answer = "" if sys.stdin.isatty() else "y"
while answer not in ("y", "n", "\x1b", ""):
answer = input(f"{msg} [y/n] ").lower().strip()
if answer == "y":
load_train_test(key) # download and cache data file

@pbenner
Copy link
Collaborator Author

pbenner commented Apr 30, 2023

The isatty() check is ok. The error is one line below:

while answer not in ("y", "n", "\x1b", ""):

Instead of

        while answer not in ("y", "n", "\x1b", ""):
            answer = input(f"{msg} [y/n] ").lower().strip()

You should use

        while answer not in ("y", "n", "\x1b"):
            answer = input(f"{msg} [y/n] ").lower().strip()

With this fix, the query appears and when answering yes the file is downloaded and cached.

@janosh
Copy link
Owner

janosh commented Apr 30, 2023

while answer not in ("y", "n", "\x1b"):

Oops, that was committed by accident. I'd briefly considered trying to support ESCAPE to answer "no" but then decided against and forgot to remove this.

janosh added a commit that referenced this issue Apr 30, 2023
* fix load_train_test() for compressed figshare data (closes #20)

* load_train_test() only accept answer 'y' or 'n' (as orig intended) (close #17)

* add test covering load_train_test() with compressed JSON file from URL

* mv run-scripts.yml test-scripts.yml

* add slow-tests.yml for running slow tests only on PR merges (to save CI budget)
janosh added a commit that referenced this issue Jun 20, 2023
* fix load_train_test() for compressed figshare data (closes #20)

* load_train_test() only accept answer 'y' or 'n' (as orig intended) (close #17)

* add test covering load_train_test() with compressed JSON file from URL

* mv run-scripts.yml test-scripts.yml

* add slow-tests.yml for running slow tests only on PR merges (to save CI budget)
janosh added a commit that referenced this issue Jun 20, 2023
* fix load_train_test() for compressed figshare data (closes #20)

* load_train_test() only accept answer 'y' or 'n' (as orig intended) (close #17)

* add test covering load_train_test() with compressed JSON file from URL

* mv run-scripts.yml test-scripts.yml

* add slow-tests.yml for running slow tests only on PR merges (to save CI budget)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants