question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Cannot find how to type pipeline parameters for JsonArray or JsonObject

See original GitHub issue

What steps did you take

I’m trying to utilize the ModelBatchPredictOp from the GCP Components. There are two fields, one with a type of JsonObject and the other with the type JsonArray. The pipeline accepts the fields for this operator as input parameters to the pipeline and passes them to the operator in the constructor. Since they’re in the pipeline params, they must be typed. However, I am unable to find any type configuration that coerces to JsonArray or JsonObject, and I cannot find any documentation on how to do this.

How do I pass these values?

For example, gcs_source_uris is supposed to be a JsonArray. When passing this through as a pipeline param typed to List[str] it fails to compile with this error:

kfp.dsl.types.InconsistentTypeException: Incompatible argument passed to the input "gcs_source_uris" of component "model_batch_predict": Argument type "typing.List[str]" is incompatible with the input type "JsonArray"
@kfp.v2.dsl.pipeline(
    name="batch-predict-v0",
    pipeline_root=pipeline_gcs_root_path)
def batch_predict_pipeline(
                           ...
                           gcs_source_uris: List[str],
                           ...
                           ):


        predict_op = ModelBatchPredictOp(
            ...
            gcs_source_uris=gcs_source_uris,
            ....
        )

I understand the error, and I’ve exhausted any other potential types I could think of. I’ve also tried to find any references to JsonObject or JsonArray in the SDK and none of them reference any Python classes I can import to type these parameters as. I’m gathering this is some kind of protobuf type, but when trying to use that, it still fails. Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ark-kuncommented, Jul 22, 2022

@dboshardy

Python’s list type is mapped to JsonArray Python’s dict type is mapped to JsonObject.

kfp.dsl.types.InconsistentTypeException: Incompatible argument passed to the input “gcs_source_uris” of component “model_batch_predict”: Argument type “typing.List[str]” is incompatible with the input type “JsonArray”

typing.List[str] should work the same as list, but there might be newly introduced bugs in v2 that break that.

For anyone who comes across this, jsonobject is the package that contains the classes required. This should be in the documentation somewhere.

The jsonobject package has no relation to the JsonObject type name in KFP components.

0reactions
Luci1306commented, Dec 10, 2022

I have a question: how can we use the for loop for gcs_source_uris at batch_predict_pipeline, not inside the component which was passed. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing JSON arrays between pipelines in Azure Data Factory
(1) I can set a default value both for an array type parameter or variable by simply passing a JSON text value as...
Read more >
JSONException: Value of type java.lang.String cannot be ...
I solved my problem by creating the JSONObject with an empty JSON object as follows: final JSONObject emptyJsonObject = new JSONObject("{}");.
Read more >
JSONObject - Android Developers
When the requested type is a String, other non-null values will be coerced using String#valueOf(Object) . Although null cannot be coerced, the sentinel ......
Read more >
ConvertTo-Json (Microsoft.PowerShell.Utility) - Microsoft Learn
Note As of PowerShell 7.2, Extended Type System properties of DateTime and String objects ... cmdlet to convert a JSON-formatted string to a...
Read more >
PostgreSQL JSON Functions & Operators: Types, Syntax ...
Read along to get detailed insights on working with PostgreSQL Functions ... collects all input values & converts them into a JSON array....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found