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

Dumping: Check non-empty input node repositories #6734

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/aiida/tools/dumping/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,15 @@ def _dump_calculation(
# Dump the node_inputs
if self.include_inputs:
input_links = calculation_node.base.links.get_incoming(link_type=LinkType.INPUT_CALC)
self._dump_calculation_io(parent_path=output_path / io_dump_mapping.inputs, link_triples=input_links)
all_input_nodes = input_links.all_nodes()
all_have_repositories = all([hasattr(node.base, 'repository') for node in all_input_nodes])
if all_have_repositories:
non_empty_repository = any([len(node.base.repository.list_objects()) > 0 for node in all_input_nodes])
if non_empty_repository:
self._dump_calculation_io(
parent_path=output_path / io_dump_mapping.inputs,
link_triples=input_links,
)
Comment on lines +288 to +296
Copy link
Member

@unkcpz unkcpz Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
all_input_nodes = input_links.all_nodes()
all_have_repositories = all([hasattr(node.base, 'repository') for node in all_input_nodes])
if all_have_repositories:
non_empty_repository = any([len(node.base.repository.list_objects()) > 0 for node in all_input_nodes])
if non_empty_repository:
self._dump_calculation_io(
parent_path=output_path / io_dump_mapping.inputs,
link_triples=input_links,
)
all_input_nodes = input_links.all_nodes()
if (
all(hasattr(node.base, 'repository') for node in all_input_nodes)
and any(len(node.base.repository.list_objects()) for node in all_input_nodes)
):
self._dump_calculation_io(
parent_path=output_path / io_dump_mapping.inputs,
link_triples=input_links,
)

nitpick: I think it can be simplified by merging two if (seems even hard to read, if you think so, feel free to ignore)?


# Dump the node_outputs apart from `retrieved`
if self.include_outputs:
Expand Down
6 changes: 6 additions & 0 deletions tests/tools/dumping/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def test_dump_multiply_add(tmp_path, generate_workchain_multiply_add):
assert all([input_file.is_file() for input_file in input_files])
assert all([output_file.is_file() for output_file in output_files])

missing_dir = dump_parent_path / node_inputs_relpath
assert not missing_dir.exists()

# Flat dumping
dump_parent_path = tmp_path / 'wc-dump-test-multiply-add-flat'
process_dumper = ProcessDumper(flat=True)
Expand Down Expand Up @@ -328,6 +331,9 @@ def test_dump_calculation_add(tmp_path, generate_calculation_node_add):
assert all([input_file.is_file() for input_file in input_files])
assert all([output_file.is_file() for output_file in output_files])

missing_dir = dump_parent_path / node_inputs_relpath
assert not missing_dir.exists()


# Tests for helper methods
@pytest.mark.usefixtures('chdir_tmp_path')
Expand Down
Loading