Hi all! I've recently started using Metaflow and h...
# ask-metaflow
g
Hi all! I've recently started using Metaflow and have been getting a ton of value out of it! I'm new to the OB slack, and I have two quick questions: 1. Can anyone confirm whether the
index
attr of a foreach step is guaranteed to have the same ordering as the iterable that is passed to
foreach
? I see "This property returns the zero based index of the current task" in the docs but didn't want to assume that the ordering is guaranteed even in cloud environments and such. 2. I noticed that some cards in one of my flows were not rendering in the UI; when trying to load them with the API after the fact, I see the result below. I assume this is probably because I tried to put too many figures (probably inside a loop), etc. into the card? If so, are there any rules of thumb for what is a reasonable amount of things for a card? Any way to know in advance whether it's going to be too much?
Copy code
from metaflow.cards import get_cards
cards = get_cards('FooTask')
cards[0].get()
# Javascript Error: Maximum call stack size exceeded
1
s
Hi! Welcome! re: 1 - there isn't any strict ordering guarantee at the moment - curious what your use case is and we can figure something out re: 2 - @hallowed-glass-14538 would you happen to know?
thankyou 1
g
For 1, the use case is something like: I have a config file with a list of params, e.g.
Copy code
[
    {'a': 1, 'b': 2},
    {'a': 3, 'b": 4},
]
and I want to fanout across those params. For each task in the fanout, I want to write results to a unique location (say on s3), and a convenient one for bookkeeping would be the list index (
i
) of the parameter set, e.g.
Copy code
<s3://foo/bar/params={i}/>
I could of course handle this manually (current approach is to add a
_index
key to the param set when I load the config), or give a unique name to each element in the list or something. If the
index
attr had this kind of guarantee, that would be nice, but certainly not necessary (I know parallelization can make it hard to make these sorts of guarantees). Thanks for the clarification!
🫡 1
If anyone happened to be following this, I came across this in the docs:
Images, as well as all other content, are embedded in the card itself so it is a good idea the keep their total size under 10MB or so.