Skip to content

Commit

Permalink
fix case if input is 'optimade.jsonl'
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Apr 23, 2024
1 parent e63e317 commit 74a7590
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/direct_from_jsonl/optimade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ database_description: >-
This database contains some example CIFs.
entries:
jsonl_path: example.jsonl
jsonl_path: optimade.jsonl
7 changes: 6 additions & 1 deletion src/optimake/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ def convert_archive(archive_path: Path, jsonl_path: Path | None = None) -> Path:
if isinstance(mc_config.entries, JSONLConfig):
if mc_config.entries.file is not None:
inflate_archive(archive_path, Path(mc_config.entries.file))
jsonl_path.symlink_to(archive_path / mc_config.entries.jsonl_path)
src_jsonl_path = archive_path / mc_config.entries.jsonl_path
if jsonl_path != src_jsonl_path:
# add a symlink to the specified jsonl_path
if jsonl_path.exists():
raise RuntimeError(f"Not overwriting existing file at {jsonl_path}")
jsonl_path.symlink_to(archive_path / src_jsonl_path)
return jsonl_path

# first, decompress any provided data paths
Expand Down
3 changes: 0 additions & 3 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ def test_convert_example_archives(archive_path, tmp_path):
tmp_path = tmp_path / archive_path.name
shutil.copytree(archive_path, tmp_path)

# remove 'optimade.jsonl' if the example was already run
(tmp_path / "optimade.jsonl").unlink(missing_ok=True)

jsonl_path = convert_archive(tmp_path)
assert jsonl_path.exists()

Expand Down

0 comments on commit 74a7590

Please sign in to comment.