add debugging
This commit is contained in:
Родитель
288782611b
Коммит
9ecaba98bf
|
@ -15,9 +15,11 @@ export class Experiment {
|
|||
|
||||
constructor() {
|
||||
this.endpointUrl = task.getInput('kubeflowEndpoint', true)!;
|
||||
// strip trailing backslash
|
||||
this.endpointUrl = this.endpointUrl.replace(/\/$/,"");
|
||||
this.name = task.getInput('experimentName', true)!;
|
||||
this.description = task.getInput('experimentDescription', false)!;
|
||||
this.getAllExperimentsEndpoint = 'pipeline/apis/v1beta1/experiments';
|
||||
this.getAllExperimentsEndpoint = '/pipeline/apis/v1beta1/experiments';
|
||||
this.restAPIClient = new rest.RestClient('agent');
|
||||
this.bearerToken = task.getInput('bearerToken', false)!;
|
||||
}
|
||||
|
@ -25,6 +27,7 @@ export class Experiment {
|
|||
public async validateEndpointUrl() {
|
||||
try {
|
||||
var options: rest.IRequestOptions = { additionalHeaders: { 'authorization': `Bearer ${this.bearerToken}` } };
|
||||
task.debug(`Validating endpoint url ${this.endpointUrl}`);
|
||||
var req = await this.restAPIClient.get(this.endpointUrl, options);
|
||||
if (req.statusCode == 200) {
|
||||
return true;
|
||||
|
@ -40,6 +43,7 @@ export class Experiment {
|
|||
try {
|
||||
var url = `${this.endpointUrl}${this.getAllExperimentsEndpoint}`;
|
||||
var options: rest.IRequestOptions = { additionalHeaders: { 'authorization': `Bearer ${this.bearerToken}` } };
|
||||
task.debug(`Loading experiment names from ${url}`);
|
||||
var webRequest = await this.restAPIClient.get<IAllExperiment>(url, options)!;
|
||||
if (webRequest.result != null) {
|
||||
if (webRequest.result.experiments != undefined) {
|
||||
|
@ -87,8 +91,7 @@ export class Experiment {
|
|||
else {
|
||||
var form: string = JSON.stringify({ "name": this.name, "description": this.description });
|
||||
}
|
||||
var reqHost = this.endpointUrl.substring(7, this.endpointUrl.length - 1);
|
||||
|
||||
var reqHost = new URL(this.endpointUrl).host;
|
||||
var reqHeaders = {
|
||||
'authorization': `Bearer ${this.bearerToken}`,
|
||||
'content-type': 'application/json'
|
||||
|
@ -101,10 +104,11 @@ export class Experiment {
|
|||
}
|
||||
|
||||
public async postRequest(reqHost: string, form: string, reqHeaders: OutgoingHttpHeaders) {
|
||||
task.debug(`Posting experiment request to ${this.endpointUrl}${this.getAllExperimentsEndpoint}`)
|
||||
var req = request(
|
||||
{
|
||||
host: reqHost,
|
||||
path: `/${this.getAllExperimentsEndpoint}`,
|
||||
path: `${this.getAllExperimentsEndpoint}`,
|
||||
method: 'POST',
|
||||
headers: reqHeaders,
|
||||
},
|
||||
|
|
|
@ -199,8 +199,7 @@ export class Run {
|
|||
{"key": {"id": "${this.pipelineVersionID}", "type": "PIPELINE_VERSION"}, "relationship": "CREATOR"}]}`;
|
||||
}
|
||||
|
||||
var reqHost = this.endpointUrl.substring(7, this.endpointUrl.length - 1);
|
||||
|
||||
var reqHost = new URL(this.endpointUrl).host;
|
||||
var reqHeaders = {
|
||||
'authorization': `Bearer ${this.bearerToken}`,
|
||||
'content-type': 'application/json'
|
||||
|
@ -225,6 +224,7 @@ export class Run {
|
|||
|
||||
public async postRequest(reqHost: string, form: string, reqHeaders: OutgoingHttpHeaders) {
|
||||
try {
|
||||
task.debug(`Posting run request to ${this.endpointUrl}${this.getAllRunsEndpoint}`)
|
||||
var req = request(
|
||||
{
|
||||
host: reqHost,
|
||||
|
@ -287,6 +287,7 @@ export class Run {
|
|||
var url = `${this.endpointUrl}${this.getAllRunsEndpoint}?resource_key.type=PIPELINE_VERSION&resource_key.id=${this.pipelineVersionID}&filter={"predicates":[{"key":"name","op":"EQUALS","string_value":"${this.runName}"}]}&sort_by=created_at desc`;
|
||||
url = encodeURI(url);
|
||||
var options: rest.IRequestOptions = { additionalHeaders: { 'authorization': `Bearer ${this.bearerToken}` } };
|
||||
task.debug(`Getting run id from ${url}`);
|
||||
var webRequest = await this.restAPIClient.get<IAllRun>(url, options)!;
|
||||
if (webRequest.result != null) {
|
||||
if (webRequest.result.runs[0].id != undefined) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче