Hi folks, I'm having issues with `argo-workflows c...
# ask-metaflow
b
Hi folks, I'm having issues with
argo-workflows create --only-json
for
metaflow>=2.12.13
I have a flow for which I can generate the template OK with
metaflow==2.12.12
, but when I upgrade to
metaflow==2.12.13
I get:
TypeError: Object of type V1Container is not JSON serializable
I need to set
--no-enable-heartbeat-daemon --no-enable-error-msg-capture
for the template to generate again. Is this a bug, or a misconfiguration in my flow? 🤔
👀 1
d
do you have the full trace? I suspect it’s in something that was added to convert objects.
@thankful-ambulance-42457 for viz.
b
Sure @dry-beach-38304, I'm generating the template from a project that uses the pants build system, so here's the command I'm running and full error trace:
Copy code
$> pants run projects/flows/flow_template/main.py -- --no-pylint argo-workflows create --only-json

Metaflow 2.12.33 executing MyFlowName for user:leonor
Project: examples, Branch: user.leonor
Validating your flow...
    The graph looks good!
Deploying examples.user.leonor.myflowname to Argo Workflows...
It seems this is the first time you are deploying examples.user.leonor.myflowname to Argo Workflows.

A new production token generated.

The namespace of this production flow is
    production:mfprj-q7ashbgrztr3xcpe-0-gvzt
To analyze results of this production flow add this line in your notebooks:
    namespace("production:mfprj-q7ashbgrztr3xcpe-0-gvzt")
If you want to authorize other people to deploy new versions of this flow to Argo Workflows, they need to call
    argo-workflows create --authorize mfprj-q7ashbgrztr3xcpe-0-gvzt
when deploying this flow to Argo Workflows for the first time.
See "Organizing Results" at <https://docs.metaflow.org/> for more information about production tokens.

    Internal error
Traceback (most recent call last):
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/cli.py", line 1167, in main
    start(auto_envvar_prefix="METAFLOW", obj=state)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/tracing/__init__.py", line 27, in wrapper_func
    return func(args, kwargs)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 829, in __call__
    return self.main(args, kwargs)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, ctx.params)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/core.py", line 610, in invoke
    return callback(args, kwargs)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/_vendor/click/decorators.py", line 33, in new_func
    return f(get_current_context().obj, args, kwargs)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/plugins/argo/argo_workflows_cli.py", line 277, in create
    obj.echo_always(str(flow), err=False, no_bold=True)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/plugins/argo/argo_workflows.py", line 178, in __str__
    return str(self._workflow_template)
  File "/Users/leonor/.cache/pants/named_caches/pex_root/venvs/37acb20989dc39854e736319f4d61b6d9f9808c5/cc95e65237c9965687b2be41acff8e202ebd07c0/lib/python3.10/site-packages/metaflow/plugins/argo/argo_workflows.py", line 3096, in __str__
    return json.dumps(self.payload, indent=4)
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py", line 238, in dumps
    kw).encode(obj)
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type V1Container is not JSON serializable
d
ok — thanks. Yes, @thankful-ambulance-42457 will ahve to look at it. It’s not even in the to_pod portion. There was a change in 2.12.13 that turned both those options you have to disable on by default so I suspect that’s the cause. Have you also tried with the most recent version (maybe it was fixed in a later version).
b
Thanks! I tried the latest version (
2.12.33
) and I get the same error
d
alright, I’ll let @thankful-ambulance-42457 chime in. I am not very familiar with that part of the code
t
I'll take a look at this in a bit. my hunch is this has been present for a while now as the --only-json feature is not that heavily used
d
it seems since .12 🙂
b
yup this seems to have broken after the introduction of the additional templates for daemon-containers and error-msg-capture. I'll see if there is an easy workaround to make the V1Container serialisable for this purpose. on a related note @bulky-fireman-68939 are you using some static analysis on the json or what is your use-case for that, if you can go into some detail? I'm interested why a regular deploy is not suitable. Also for visibility, there are two limitations with
--only-json
, as it only outputs the workflow template json. This excludes • cronworkflow [1730] • argo sensors [1940]
b
@bulky-afternoon-92433 thanks for the heads up, we manage crons and sources/sensors separately so this doesn't affect us 🙂 We generate the template so that we can commit it to a repository and let ArgoCD deploy it. It fits better with our deployment workflow.
👌 1
b
fix for this is lined up to go out in the next version, hopefully today 🙂
mind blown 1
b
Amazing! thank you!