I'm sorry, that ask doesn't make sense to me. If you want to accept
_absolutely anything_ then you've lost all claimed benefits of a
statically typed language.

Something like I've shown, or like Kamil showed in his pastebin
<https://pastebin.com/UpUKYEvg> seems like a more likely use case --
where you pre-define in your Java source the possible DagRun conf types
via predefined classes.

But since you asked, if you do want to accept and pass on absolutely
arbitrary input: `run.setConf(gson.fromJson(userInput, JsonObject.cass))`

-ash

On May 29 2020, at 9:40 pm, Jarek Potiuk <jarek.pot...@polidea.com> wrote:

> On Fri, May 29, 2020 at 10:27 PM Ash Berlin-Taylor <a...@apache.org> wrote:
> 
>> 
>> 
>>     @Test
>>     public void confDynamicTest() {
>>         JsonObject x = new JsonObject();
>>         x.addProperty("x", 34);
>>         model.setConf(x);
>>         Assert.assertEquals(new JSON().serialize(model),
>> "{\"external_trigger\":true,\"conf\":{\"x\":34}}");
>> 
>>         JsonObject a = new JsonObject();
>>         JsonArray aa = new JsonArray();
>>         aa.add(1);
>>         aa.add(2);
>>         aa.add(3);
>>         a.add("a", aa);
>>         model.setConf(a);
>>         Assert.assertEquals(new JSON().serialize(model),
>> "{\"external_trigger\":true,\"conf\":{\"a\":[1,2,3]}}");
>> 
>>         JsonObject zw = new JsonObject();
>>         JsonArray z = new JsonArray();
>>         z.add(1);
>>         z.add(2);
>>         zw.add("Z", z);
>>         zw.addProperty("W", "a");
>>         model.setConf(zw);
>>         Assert.assertEquals(new JSON().serialize(model),
>> "{\"external_trigger\":true,\"conf\":{\"Z\":[1,2],\"W\":\"a\"}}");
>>     }
>> 
>> 
> Again I repeat the question: How do you do that without recompiling the
> client in java? T
> Take my example of "CLI". where you want to trigger different dag with
> different parameters to pass.
> 
> Please correct me if I am wrong, but your solution means that every time
> you have a new DAG you neeed to implement the logic in your Java
> client for
> this specific DAG.
> 
> I imagine as a user I would like to run
> 
> java -jar client.jar tirgger_dag dag_id ="dag_id"
> exection_date="2020-10-01" conf="{a: [1, 2, 3]"
> java -jar client.jar tirgger_dag dag_id ="dag_id"
> exection_date="2020-10-01" conf="{w:a}"
> 
> and when a new dag appears I would like to run it with "conf ="xy": z}
> 
> Remember that - unlike with python scripts -  people who use java clientx
> do not recompile them every time they run them, nor weekly. They usually
> have some pre-compiled, ready to run .jar files to run their code.
> 
> How do you want to do that?
> 
> J.
> 
> -- 
> 
> Jarek Potiuk
> Polidea <https://www.polidea.com/> | Principal Software Engineer
> 
> M: +48 660 796 129 <+48660796129>
> [image: Polidea] <https://www.polidea.com/>
> 

Reply via email to