Skip to content

Commit

Permalink
Merge pull request #125 from IndicoDataSolutions/nate/update_examples
Browse files Browse the repository at this point in the history
[CAT-839] Update GetPredictions Examples
  • Loading branch information
nateshim-indico authored Dec 1, 2023
2 parents 31daf54 + a066f8f commit d4000aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
23 changes: 4 additions & 19 deletions Examples/GetPredictionsBasic/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using IndicoV2;
using Newtonsoft.Json.Linq;

namespace Examples
{
Expand All @@ -18,23 +16,10 @@ private static string GetToken() =>

public static async Task Main()
{
var client = new IndicoClient(GetToken(), new Uri("https://app.indico.io"));

var submissionClient = client.Submissions();

var storageClient = client.Storage();

int submissionId = 152070;
var submission = await submissionClient.GetAsync(submissionId);

string resultFileUrl = submission.ResultFile;
var storageResult = await storageClient.GetAsync(new Uri(resultFileUrl), default);
using (var reader = new StreamReader(storageResult))
{
string resultAsString = reader.ReadToEnd();
JObject resultObject = JObject.Parse(resultAsString);
Console.WriteLine(resultObject);
}
var client = new IndicoClient(GetToken(), new Uri("https://try.indico.io"));
int submissionId = 91345;
var jobResult = await client.GetSubmissionResultAwaiter().WaitReady(submissionId);
Console.WriteLine(jobResult);
}
}
}
21 changes: 6 additions & 15 deletions Examples/GetPredictionsWithReview/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using IndicoV2;
using Newtonsoft.Json.Linq;
Expand All @@ -18,26 +17,18 @@ private static string GetToken() =>

public static async Task Main()
{
var client = new IndicoClient(GetToken(), new Uri("https://app.indico.io"));
var client = new IndicoClient(GetToken(), new Uri("https://try.indico.io"));
int submissionId = 91345;

var submissionClient = client.Submissions();

var jobClient = client.Jobs();

var storageClient = client.Storage();

int submissionId = 152070;
var submission = await submissionClient.GetAsync(submissionId);

string jobId = await submissionClient.GenerateSubmissionResultAsync(submissionId);
JToken jobResult = await jobClient.GetResultAsync<JToken>(jobId);
string jobId = await client.Submissions().GenerateSubmissionResultAsync(submissionId);
var jobResult = await client.JobAwaiter().WaitReadyAsync<JToken>(jobId, default, default);
string jobResultUrl = jobResult.Value<string>("url");

var storageResult = await storageClient.GetAsync(new Uri(jobResultUrl), default);
var storageResult = await client.Storage().GetAsync(new Uri(jobResultUrl), default);
using (var reader = new StreamReader(storageResult))
{
string resultAsString = reader.ReadToEnd();
JObject resultObject = JObject.Parse(resultAsString);
var resultObject = JObject.Parse(resultAsString);
Console.WriteLine(resultObject);
}
}
Expand Down

0 comments on commit d4000aa

Please sign in to comment.