(Fixed "send on return".) Hi. I'm new to metaflo...
# ask-metaflow
e
(Fixed "send on return".) Hi. I'm new to metaflow (about 3 weeks, part-time). So far, it looks like exactly what I need for my use case. I've put together a toy calculation to learn the ropes: "03-mf_stats.py". The version below seems not to return the results of the foreach in order. The documentation is quite clear that it should. So I'm thinking I'm doing something really wrong. Can you comment on what's going on? (I've also attached additional files to make a runnable package.) Thanks Very Much!
g
hi, what metaflow version are you using?
e
Hi Luis. And thanks! I'm using 2.19.18
g
hi @eager-activity-66247, sorry for the late reply. I couldn't reproduce this behavior. Do you have screenshots for the output you are getting
e
And I'm also sorry for being late. Too many things going on. (I've attached a set of files that should allow someone to run this test case. The .py file and the notebook differ slightly from what I attached in my original post.) I run the code locally, that is, without
batch
. The python file now prints the "magnitude" array (
self.all_mags
) as it is reassembled in
join
. The code is:
Copy code
@step
    def join(self, inputs):
        """
        Join our parallel branches and merge results into an array.

        """
        # Collect both the statistics arrays and the noise magnitudes.
        self.stat_set = np.array([inp.stat for inp in inputs])
        self.all_mags = np.array([inp.mag for inp in inputs])
        # Note that self.stat_set is a 3D ndarray:

        # Merge results into prior value of "self".
        self.merge_artifacts(inputs, exclude=["mag", "stat"])
        
        # Print "all_mags". Is it in order?
        print("Noise magnitudes as return in 'inputs':")
        print( self.all_mags)
        
        self.next(self.end)
The log of the job (again, run locally) is:
Copy code
% python 03-mf_stats.py run
Metaflow 2.19.18 executing NoisePropForeachMagFlow for user:bwilfley
Validating your flow...
    The graph looks good!
Running pylint...
    Pylint is happy!
2026-03-06 11:34:24.383 Workflow starting (run-id 44):
2026-03-06 11:34:28.905 [44/start/139 (pid 28519)] Task is starting.
2026-03-06 11:34:36.317 [44/start/139 (pid 28519)] Foreach yields 6 child steps.
2026-03-06 11:34:36.318 [44/start/139 (pid 28519)] Task finished successfully.
2026-03-06 11:34:40.406 [44/compute_for_a_magnitude/140 (pid 28611)] Task is starting.
2026-03-06 11:34:41.330 [44/compute_for_a_magnitude/141 (pid 28614)] Task is starting.
2026-03-06 11:34:42.258 [44/compute_for_a_magnitude/142 (pid 28617)] Task is starting.
2026-03-06 11:34:43.021 [44/compute_for_a_magnitude/143 (pid 28621)] Task is starting.
2026-03-06 11:34:44.010 [44/compute_for_a_magnitude/144 (pid 28625)] Task is starting.
2026-03-06 11:34:44.938 [44/compute_for_a_magnitude/145 (pid 28630)] Task is starting.
2026-03-06 11:34:47.547 [44/compute_for_a_magnitude/140 (pid 28611)] Task finished successfully.
2026-03-06 11:34:49.447 [44/compute_for_a_magnitude/141 (pid 28614)] Task finished successfully.
2026-03-06 11:34:51.385 [44/compute_for_a_magnitude/142 (pid 28617)] Task finished successfully.
2026-03-06 11:34:52.277 [44/compute_for_a_magnitude/143 (pid 28621)] Task finished successfully.
2026-03-06 11:34:55.476 [44/compute_for_a_magnitude/144 (pid 28625)] Task finished successfully.
2026-03-06 11:34:56.380 [44/compute_for_a_magnitude/145 (pid 28630)] Task finished successfully.
2026-03-06 11:34:59.600 [44/join/146 (pid 28660)] Task is starting.
2026-03-06 11:35:08.033 [44/join/146 (pid 28660)] Noise magnitudes as return in 'inputs':
2026-03-06 11:35:08.033 [44/join/146 (pid 28660)] [0.6 0.1 0.8 0.2 0.4 1. ]
2026-03-06 11:35:12.316 [44/join/146 (pid 28660)] Task finished successfully.
2026-03-06 11:35:14.384 [44/end/147 (pid 28780)] Task is starting.
2026-03-06 11:35:19.557 [44/end/147 (pid 28780)] Task finished successfully.
2026-03-06 11:35:20.170 Done!
Note the two lines in the log for
44/join/164
that end with:
Copy code
Noise magnitudes as return in 'inputs':
[0.6 0.1 0.8 0.2 0.4 1. ]
The array should have been
[0.1 0.2 0.4 0.6 0.8 1.]
In the notebook, the reassembled array as retrieved:
Copy code
array([0.6, 0.1, 0.8, 0.2, 0.4, 1. ])
This agrees with the job output. Also in the notebook are some plots, but they just illustrate the same discrepancy.
h
looks like a bug, checking
👍 1
g
I just saw this. I don't have my laptop right now. Let me know if you fixed the bug
h
i did, testing the fix now
👍 1