Skip to content

Map zone adds gather method - #638

Merged
superstar54 merged 10 commits into
aiidateam:mainfrom
superstar54:fix/636/collect_socket_inside_map
Oct 3, 2025
Merged

Map zone adds gather method#638
superstar54 merged 10 commits into
aiidateam:mainfrom
superstar54:fix/636/collect_socket_inside_map

Conversation

@superstar54

@superstar54 superstar54 commented Aug 17, 2025

Copy link
Copy Markdown
Member

This PR adds the following changes:

  • map_zone.item has two outputs: key and value.
  • add gather method to collect the results
  • use map_zone.outputs to pass data to other tasks outside the map zone

Here is an example:

@task()
def generate_data(n: int) -> Annotated[dict, namespace(data=dynamic(int))]:
    """Generate a dictionary of integers."""
    result = {f'key_{i}': i for i in range(n)}
    return {'data': result}

@task()
def add(x, y):
    """Add two numbers."""
    return x + y

@task()
def calc_sum(data: Annotated[dict, dynamic(orm.Int)]) -> float:
    """Compute the sum of all provided values."""
    return sum(data.values())


x = 1
y = 2
n = 3
with WorkGraph('add_graph') as wg:
    data = generate_data(n=n).data
    with Map(data) as map_zone:
        out1 = add(x=map_zone.item.value, y=x).result
        out2= add(x=map_zone.item.value, y=y).result
        map_zone.gather({"sum1": out1, "sum2": out2})
    out3 = calc_sum(data=map_zone.outputs.sum1).result
    out4 = calc_sum(data=map_zone.outputs.sum2).result
Screenshot from 2025-10-03 22-34-11

@superstar54 superstar54 linked an issue Aug 17, 2025 that may be closed by this pull request
@superstar54
superstar54 marked this pull request as draft August 17, 2025 06:29
@superstar54
superstar54 force-pushed the fix/636/collect_socket_inside_map branch from 5729d65 to 83a1835 Compare September 29, 2025 09:09
@superstar54
superstar54 force-pushed the fix/636/collect_socket_inside_map branch from 83a1835 to c36ddad Compare September 29, 2025 09:09
@superstar54
superstar54 marked this pull request as ready for review October 3, 2025 20:29
@superstar54
superstar54 force-pushed the fix/636/collect_socket_inside_map branch from bcfe8e7 to 1cd8fe5 Compare October 3, 2025 20:42
@superstar54
superstar54 force-pushed the fix/636/collect_socket_inside_map branch from 1cd8fe5 to 16993ec Compare October 3, 2025 20:55
@codecov-commenter

codecov-commenter commented Oct 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (83b0a26) to head (16993ec).
⚠️ Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #638      +/-   ##
==========================================
- Coverage   90.87%   90.10%   -0.76%     
==========================================
  Files          44       44              
  Lines        3184     3038     -146     
==========================================
- Hits         2893     2737     -156     
- Misses        291      301      +10     

☔ 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.

@superstar54
superstar54 merged commit b266005 into aiidateam:main Oct 3, 2025
4 checks passed
@superstar54
superstar54 deleted the fix/636/collect_socket_inside_map branch October 3, 2025 21:04
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.

Socket mismatch when using Map

2 participants