Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAT-839] Update GetPredictions Examples #125

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just use Jobs() instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this how it is for now.

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
Loading