Waiting for a Submission
Given submission_ids, wait for all to finish processing
Introduction
As an alternative to waiting for Submission(s) manually, use the WaitForSubmissions
query.WaitForSubmissions
continuously polls Indico for the status of your Submission, up until the max waiting period. Once the Submission has either failed or succeeded to process, it returns a Submission
object just like GetSubmission
.
WaitForSubmissions
Inputs
WaitforSubmissions Inputs
submission_ids: List[int]
submission IDs
Outputs
WaitforSubmissions Outputs
Submission object
Try It Out
You can try outWaitForSubmissions
below:
from indico.errors import IndicoTimeoutError
from indico.queries import WaitForSubmissions
# your list of Submission ids
submission_ids = [1, 2, 3, 4]
# wait for those Submissons to process.
submissions: list | None = None
while not submissions:
try:
# configuring a timeout here can help increase and / or reduce the number
# of API calls made.
submissions = client.call(WaitForSubmissions(submission_ids, timeout = 60))
except IndicoTimeoutError:
print("Still waiting...")
submission = submissions[0]
print(submission.status, submission.input_filename, submission.retrieved, submission.id)
// Waiting for a submission is handled within GetAsync which awaits until a Submission has reached a complete status
namespace Examples
{
public class GetSubmission
{
private static string GetToken() =>
File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"indico_api_token.txt"));
public static async Task Main()
{
var client = new IndicoClient(GetToken(), new Uri("https://mycluster.indico.io"));
var submissionId = 1;
var submissionClient = client.Submissions();
var submission = await submissionClient.GetAsync(submissionId);
Console.WriteLine(submission.Id);
}
}
}
package com.indico;
import com.indico.entity.Submission;
import com.indico.query.GetSubmission;
import com.indico.type.SubmissionStatus;
public class main {
public IndicoClient client;
private static String token_path = "./indico_api_token.txt";
private static String host = "mycluster.indico.io"
private static Integer submission_id = 1;
public static void main(String args[]) throws Exception {
IndicoConfig config = new IndicoConfig.Builder().host(host)
.protocol("https")
.tokenPath(token_path)
.build();
client = new IndicoKtorClient(config);
GetSubmission submission = client.getSubmission();
submission.submissionId(submission_id);
Submission result = submission.query();
/*
Wait for submission to reach COMPLETE or FAILED status
*/
while(result.status != SubmissionStatus.COMPLETE && result.status != SubmissionStatus.FAILED){
result = submission.query();
}
System.exit(0);
}
}
Updated 9 months ago
What’s Next