Retrieving Submissions

Generate a result file for a Submission

Introduction

Once your Submission has completed processing, the SubmissionResult query can be used to generate a result file for a specific Submission. In cases where your Submission is still processing, the SubmissionResult query can be configured to check the status of the submission and generate a result file following a COMPLETE status. The query returns a Job object that can be monitored for the generation of the result file.

SubmissionResult

Inputs

📥

SubmissionResult Inputs

submission: int or Submission Id of the submission or Submission object

check_status: str Submission status to check for. Defaults to any status other than PROCESSING optional

wait: (bool, optional) Wait until the submission is check_status and wait for the result file to be generated. Defaults to False

timeout: (int or float, optional) Maximum number of seconds to wait before timing out. Ignored if not wait. Defaults to 30.

Outputs

📤

SubmissionResult Outputs

A Job that can be watched for results

Try It Out

You can try outSubmissionResult below:

from json import dump
from indico import IndicoClient, IndicoConfig
from indico.queries import RetreiveStorageObject, SubmissionResult

#submission id to use
sub_id=1234

#create client
HOST='mycluster.indico.io'
TOKEN='./indico-api-token.txt'
config = IndicoConfig(host=HOST, api_token_path=TOKEN)
client = IndicoClient(config=config)

#Create Submssion Result job
job = client.call(SubmissionResult(sub_id, wait=True))

#retrieve result file
result = client.call(RetrieveStorageObject(job.result))

#write output
with open(f"result_{sub_id}.json") as f:
  dump(result, f)
 
using System;
using System.IO;
using System.Threading.Tasks;
using IndicoV2;
using Newtonsoft.Json.Linq;

namespace Examples
{
    public class RetrieveSubmission
    {
        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"));
            int submissionId = 1;

            var jobResult = await client.GetSubmissionResultAwaiter().WaitReady(submissionId);
            Console.WriteLine(jobResult);
        }
    }
}

package com.indico;

import com.indico.query.GetSubmission;
import com.indico.query.Job;
import com.indico.storage.Blob;
import com.indico.storage.RetrieveBlob;
import com.indico.type.JobStatus;

import java.io.File;
import java.io.IOException;
import java.util.*;

import org.apache.commons.io.FileUtils;
import com.indico.entity.Submission;
import org.json.JSONObject;

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);

        
				Job job = client.submissionResult().submission(submission_id).execute();
        /**
               * each call to .status() executes a query.
               */
        while (job.status() == JobStatus.PENDING) {
          Thread.sleep(1000);
          System.out.println("Job Status: " + job.status());
        }

        JSONObject obj = job.result();
        String url = obj.getString("url");
        RetrieveBlob retrieveBlob = client.retrieveBlob();
        Blob blob = retrieveBlob.url(url).execute();
      	/**
        * It is important to close blob storage objects to release the
        * connections that may remain from reading the blob.
        */
      	blob.close();
      	System.out.println(blob.asString());
        System.exit(0);

    }
}