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

Save pickled function as AiiDA node #383

Merged
merged 8 commits into from
Dec 5, 2024

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Dec 5, 2024

Fix issue #382 .

  • do not pickle the function when decorating the function using task
  • Only save it using PickledFunction data when launch the WorkGraph
@task.calcfunction()
def add(x, y):
    return x + y

@task.calcfunction()
def multiply(x, y):
    return x * y

wg = WorkGraph("add_multiply_workflow")
add_task = wg.add_task(add, name="add1", x=orm.Int(2), y=orm.Int(3))
wg.add_task(multiply, name="multiply1", x=add_task.outputs["result"], y=orm.Int(4))
wg.submit(wait=True)

The PickledFunction data will be the inputs of the WorkGraph, as shown below:

$ verdi process show 22462
Property     Value
-----------  ------------------------------------
type         WorkGraph<add_multiply_workflow>
state        Finished [0]
pk           22462
uuid         e79aac27-4065-4bc5-b199-8622bcdb045d
label        add_multiply_workflow
description
ctime        2024-12-05 21:34:27.117931+00:00
mtime        2024-12-05 21:34:30.034747+00:00

Inputs                         PK     Type
-----------------------------  -----  ---------------
wg
    tasks
        add1
            inputs
                x
                    property
                        value  22459  Int
                y
                    property
                        value  22460  Int
            executor
                callable       22457  PickledFunction
        multiply1
            inputs
                y
                    property
                        value  22461  Int
            executor
                callable       22458  PickledFunction

Outputs             PK  Type
---------------  -----  ------
execution_count  22467  Int

Called        PK  Type
---------  -----  --------
add1       22463  add
multiply1  22465  multiply

Log messages
----------------------------------------------
There are 11 log messages for this calculation
Run 'verdi process report 22462' to see them

@superstar54 superstar54 force-pushed the fix/382/save_pickled_data_in_repository branch from c484804 to ba8120d Compare December 5, 2024 16:41
@superstar54 superstar54 linked an issue Dec 5, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 98.40000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.00%. Comparing base (c08af7a) to head (6b86b4c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/aiida_workgraph/orm/pickled_function.py 0.00% 1 Missing ⚠️
src/aiida_workgraph/utils/__init__.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   90.82%   91.00%   +0.17%     
==========================================
  Files          64       65       +1     
  Lines        4601     4648      +47     
==========================================
+ Hits         4179     4230      +51     
+ Misses        422      418       -4     
Flag Coverage Δ
python-3.11 90.96% <98.40%> (+0.17%) ⬆️
python-3.12 90.96% <98.40%> (+0.17%) ⬆️
python-3.9 91.00% <98.40%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@superstar54 superstar54 merged commit 0f42d53 into main Dec 5, 2024
15 checks passed
@superstar54 superstar54 deleted the fix/382/save_pickled_data_in_repository branch December 5, 2024 22:39
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.

Save pickled data into repository
2 participants