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

StashCalculation: a new CalcJob plugin #6772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khsrali
Copy link
Contributor

@khsrali khsrali commented Feb 26, 2025

Historically, stashing was only possible, if it was instructed before running a generic calcjob. The instruction had to be "attached" to the original calcjob, like this for example:

inputs = {
    'MyInputs': <MyInputs>,
    'metadata': {
        'computer': Computer.collection.get(label="localhost"),
        'options': {
            'resources': {'num_machines': 1}, 
            'stash': {
                'stash_mode': StashMode.COPY.value,
                'target_base': '/scratch/',
                 'source_list': ['heavy_data.xyz'],
            },
        },
    },
}
run(MyCalculation, **inputs)

However, if a user would realize they need to stash something only after running th calcjob, this would not be possible.

This PR, defines a new calcjob, that is able to perform a stashing operation even after a calculation is finished.
The usage is very similar, and for consistency and user-friendliness, we keep the instruction as part of the metadata. The only main input is obviously a source node, for example:

StashCalculation_ = CalculationFactory('core.stash')


MyCalculation = orm.load_node(pk=<PK>)
inputs = {
    'metadata': {
        'computer': Computer.collection.get(label="localhost"),
        'options': {
            'resources': {'num_machines': 1}, 
            'stash': {
                'stash_mode': StashMode.COPY.value,
                'target_base': '/scratch/',
                 'source_list': ['heavy_data.xyz'],
            },
        },
    },
    'source_node': MyCalculation,
}

result = run(StashCalculation_, **inputs)

P.S. This PR is part of the upcoming changes, reference in #6764

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.32%. Comparing base (ae49af6) to head (4c1504b).

Files with missing lines Patch % Lines
src/aiida/engine/daemon/execmanager.py 72.73% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6772      +/-   ##
==========================================
+ Coverage   78.30%   78.32%   +0.02%     
==========================================
  Files         566      567       +1     
  Lines       42751    42777      +26     
==========================================
+ Hits        33474    33499      +25     
- Misses       9277     9278       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@agoscinski agoscinski left a comment

Choose a reason for hiding this comment

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

First quick review.

spec.inputs.pop('code', None)

# Ideally one could use the same computer as the one of the `source_node`.
# However, if another computer has access to the directory, we don't want to restrict.`
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure how would I pass another computer here? Maybe you could also explain more scenario more detailed.

Suggested change
# However, if another computer has access to the directory, we don't want to restrict.`
# However if you cannot access the stash storage from the same computer anymore but you have access to it from another computer, you can can specify the computer with this commented block below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks I updated the comment, and moved it to docstring.
Passing computer appears to be a very routing procedure it's done via metadata.computer.
It should be very clear, now, even for the users.

COMPRESS_TARBZ2 = 'tar.bz2'
COMPRESS_TARGZ = 'tar.gz'
COMPRESS_TARXZ = 'tar.xz'
CUSTOM_SCRIPT = 'custom_script'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the CUSTOM_SCRIPT is part of a different PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! my bad :) fixed now.


logger_extra = get_dblogger_extra(calculation)

if calculation.process_type == 'aiida.calculations:core.stash':
remote_node = load_node(calculation.inputs.source_node.pk)
uuid = calculation.inputs.source_node.uuid
Copy link
Contributor

Choose a reason for hiding this comment

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

might increase readability

Suggested change
uuid = calculation.inputs.source_node.uuid
uuid = remote_node.uuid

@khsrali khsrali closed this Mar 5, 2025
@khsrali khsrali force-pushed the stashing/calcjob branch from 239ff8e to c535928 Compare March 5, 2025 11:40
@khsrali khsrali reopened this Mar 5, 2025
@khsrali
Copy link
Contributor Author

khsrali commented Mar 5, 2025

First quick review.

applied!

@khsrali khsrali force-pushed the stashing/calcjob branch from 84f49a7 to 4c1504b Compare March 7, 2025 14:03
@khsrali khsrali requested a review from agoscinski March 7, 2025 14:21
@khsrali khsrali changed the title StashCalculation: new CalcJob plugin StashCalculation: a new CalcJob plugin Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants