Obtain JobID inside the workflow

Hi,

I launch Knime jobs through REST calls.

I need to obtain the JobId of the Job, INSIDE the workflow. I tried to use the “Extract System/Context Properties” nodes but without success.

How can I have it?

Thanks in advance,
Lionel

Hi Lionel,

You can use a GET Request node from inside that workflow to query the KNIME Server :jobs endpoint. It’ll return a list with all jobs currently on the server and their respective states. From this, you should be able to identify the job that
a) has the name of the current workflow (which you can get beforehand from either Extract System/Context Properties) and that
b) has status “EXECUTING”

This presumes that you won’t run that workflow in parallel. If you do, it might be a bit trickier to pinpoint which of the jobs in the list is actually the right one.

Hope that helps!

Cheers,
Roland

1 Like

Hi @RolandBurger,

Thanks for this tricky solution. But yes we can imagine that the workflow will be launched multi time in parallel (it is a possibility).

We were also thinking to add an input string to the wf and send the JobID in the input when the wf is executed (as we first create the job, and we execute it in a second time i should work).

We will see which solution we will use.

If you think of another solution you are welcomed :wink:

Lionel

@RolandBurger, can I strongly suggest you to add the possibility to obtain the JobId through one of the Extract properties nodes ?

Thanks, Lionel

Hi @lcollia

Happy to open a feature request for you about this.

I was actually wondering, why would you need the job id?

Cheers, Iris

Hi @Iris,

Thanks for your action.

In a few words, in a workflow that is executed through REST calls, I am generating a file. With the use of the “File Download” node, the file will be accessible in the job directory through a second REST call (in the Output Resources). This second call must be made with an URL based on the job ID.
In the same workflow, I am generating a script that contain commands that will use the previously generated file. Thus I have to construct in the workflow the URL that will allow the file to be downloaded, at the end of the workflow execution. So to construct the URL I need in the workflow the jobID of the current job.

I hope this is clear enough.

Regards, Lionel

Hi @lcollia

okay understood. I will forward this internally so we make this process simpler for the future.

I also added @Marten_Pfannenschmidt s component to the KNIME Hub. He implemented the reading of the job id from the workflow there.

It is kind of hard to debug, because the execution fails locally.

1 Like

Hi @Iris, @Marten_Pfannenschmidt,

Many thanks to you. The component work perfectly on the server!

Yes sometime debuging locally can be very tricky for workflows that are running on the server.

Thanks again,
Lionel

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Extract Context Properties node now (v. 4.2.2) provides the job-id when executed on the server: https://kni.me/n/vaCOTKFPaiaqwUa8

No need to fiddle with my broken component anymore :wink:

3 Likes