talend - retry subjob based on REST request results - rest

I have a RESTful api I am trying to consume using talend
in order to get data 2 api calls are needed, the first generates an ID for your report, which you then use to make a consecutive api call using that ID to get your data results
the issue is if the requested report in the 2nd api call has not yet completed it will return
[{data:{string:"Requested report ### has not finished processing yet, please try again later"}}]
so, i put a tJava to thread(5000) to stagger the 1st api call (tRestClient2) from the 2nd api call (tRestClient1), but I could forsee this being an issue
what i want to do is evaluate the 2nd tRest request result (tFileOutputJSON_3), and if it equals "Requested report...", then requeue the 2nd tRest request until the data is ready
here is a screenshot of my job

Like always there is ton of solutions.
But you are not far from what you want. This following design should respect your expectation :
I kept your components as I don't really know what you are doing inside(I retired tLogrow to make things concise). But I reorganized scheduling links.
tJava
|onSubjobOk
tRestClient -- >
tFileOutputJSON
|onSubjobOk
tFileInputJSON-- >
tExtractJSONFields -- > tJavaRow
|onSubjobOk
tSetGlobalVar1
|onSubjobOk
tLoop2 -- iterate (order1)-- > tRestClient -- >
tHashOutput3
| -- iterate
(order2)-- > tHashInput4 -- > tJavaRow5
| -- iterate
(order3)-- > tSleep6
|onSubjobOk
tHashInput7 -- > tFileOutputJSON
1:Use a variable to manage the loop.
2:Use a While loop. Leave declaration and iteration blank (""), and put your condition using the previously initialized variable.3:Do not use Append as you want to fetch new result at each loop.
4:Link it to your HashOutput and do not clear cache.
5:Do your work here. Do not forget to update the global variable.
6:Can be placed before the call if most calls required time before report getting ready.
7:Link it to your HashOutput too, you will be able to fetch the data that made a end to the loop.

Related

How can I submit unsubmitted Moodle attempt via SQL

Hello I ma trying to submit unsubmitted quiz attempts so I can grade them. So far I have set the timefinish column in mdl_quiz_attempts which changes the attempt status to "Not yet graded", then setting fraction to 0 from NULL and state to "gradewrong" from "complete" in mdl_question_attempt_steps to simulate submission but this seems to break the site. What am I missing?
You're going to have to trace through the code for the process_finish() function in mod/quiz/attemptlib.php ( https://github.com/moodle/moodle/blob/master/mod/quiz/attemptlib.php#L2171 ) and figure out how that all works.
This is a complex process and will require a lot of DB queries / updates in order to achieve it manually.
I would strongly recommend that you write a PHP script to do this, instead of trying to handle it manually (that way you can create an instance of 'quiz_attempt' for each user's attempt, then call $attempt->process_finish() on each, in order to close the attempt properly).
Thanks. The trick is to set the timefinish column in mdl_quiz_attempts which changes the attempt status to "Not yet graded", then setting the state to "gradewrong" from "complete" in mdl_question_attempt_steps for unsubmitted responses to simulate submission. Then set a fake 0 grade to sumgrades where grades are NULL in mdl_quiz_attempts and then running a regrade in the admin panel.

Debugging values into variables or user properties

How can I spy into my values when I'm on ADF debug mode ?
I want to build a simple pipeline that digs into a storage account table. For each row, enter the value of the second column, use it to create a URL and call a web service.
I saw the output of the Lookup command but how can I saw, for example, the content of each input() into the foreach activity. Can I used the user properties for debugging reason ?
When debugging, I frequently make use of the 'Set Variable' activity. Viewing the output of a 'Set Variable' activity is spying on the value.
You want to see the input to each iteration of your ForEach. Prepend the inner activity with a Set Variable activity. Dynamic content #string(item()) should be enough.

Dredd: Ruby-hooks: execute same hook for multiple requests

The problem I'm facing is:
I have a request and need to check 3 types of responses for this request. Each time I need to slightly modify my request body before sending it.
dredd --names:
info: Users > User Operations > Update User > Example 1
skip: PUT (204) myurl/users/userid-123
info: Users > User Operations > Update User > Example 2
skip: PUT (422) myurl/users/userid-123
info: Users > User Operations > Update User > Example 3
skip: PUT (429) myurl/users/userid-123
My idea was in the before hook do something like "cucumber-style":
before(/^Users > User Operations > Update User > Example (1|2|3)$/) do |myvar|
Here run loop from 1 to 3 and do necessary changes
But after several trials this doesn't seem to work, looks like ruby-hooks doesn't support variables in names.
Any ideas what would be the proper approach for this case, since having separate before-hook for every single request doesn't seem right here?
I don't think the Ruby hooks support regular expressions in the transaction names. A simple workaround would be to catch all and distinguish the transactions in the hook itself:
before_each do |transaction|
if transaction.name.match(/Example (1|2|3)$/)
...
end
end

How can I get all Actions for a Board using Trello's Rest API?

I want to get all the actions for a board, but Trello limits the results to 1000. I understand the correct way to deal with this is to paginate. I've tried both before and page as keywords:
Basic Call:
https://api.trello.com/1/board/[boardID]/
?key=[key]&token=[token]
&actions=commentCard&actions_limit=1000
Alternatives:
Before:
https://api.trello.com/1/board/[boardID]/
?key=[key]&token=[token]
&actions=commentCard&actions_limit=1000&
before=[oldest_returned_action's_date]
Page:
https://api.trello.com/1/board/[boardID]/
?key=[key]&token=[token]
&actions=commentCard&actions_limit=1000&
page=[page_number]
The result never varies --- I always get back [limit] number of actions, and they're always the same no matter the call. I checked the dates in what was returned and they certainly don't respect the before parameter. I even tried lowering the limit to make sure I wasn't trying to return more than I possessed. The problem persists.
How can I correctly get all actions for a Trello board?
Actions are in reverse chronological order (newest-to-oldest), so to page through the actions on a board, you would use something like:
curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000"
then, from the last element of the array returned by the the above, select the date or id and pass that as the before parameter in the next call, e.g.:
curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000&before=${DATE_OR_ID_OF_LAST_ACTION}"
and repeat, passing in either the id or date of the last action as the subsequent before parameter.
References:
Paging
Board Actions
Actions Nested Resource

How to perform a conditional test within a Talend job?

I am looking to trigger a series of processes, and I want to tell if each one succeeds or fails before starting the subsequent ones.
I am using tSSH (on Talend 6.4.1) to trigger a process and I only want the job to continue if it is a success. The tSSH "component" doesn't appear to fail if it receives a non-zero return code, so I have tried using an assert. However, even if the assert fails, it doesn't appear to prevent the component and subjob being "OK" which is a bit odd, so I can't use on-(component|subjob)-ok to link to the next job.
I don't seem to be able to find any conditional evaluation components which will allow me to stop the continuation of the job or subjob based on the evaluation result.
The only way I can find is to have
tSSH1 --IF globalMap.get("tSSH_1_EXIT_CODE").equals(0)--> tSSH2...
--IF !globalMap.get("tSSH_1_EXIT_CODE").equals(0)--> (failure logging subjob)
which means coding the test twice with negation.
Am I missing something, or are there no such conditional components?
you can put a if condition on tSSH component for success /failure using global variable of tSSH component i.e.
((String)globalMap.get("tSSH_1_STDERR")) and ((String)globalMap.get("tSSH_1_STDOUT")).
if condition you can check is :
if(((String)globalMap.get("tSSH_1_STDERR")) != null) than call error log
else call tSSH2.
Hope this helps...