Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Add parameter to list jobs (#57)
Browse files Browse the repository at this point in the history
* update swagger

* add job list query to listJobs

* fix tests

* update

* update

* update

* update
  • Loading branch information
yiyione committed Aug 24, 2020
1 parent c491de0 commit fa954c7
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 509 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
8 changes: 5 additions & 3 deletions src/api/v2/clients/jobClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
import { Util } from '@pai/commom/util';
import * as yaml from 'js-yaml';

import { IJobListQeury } from '../models/job';

import { OpenPAIBaseClient } from './baseClient';

/**
Expand Down Expand Up @@ -37,15 +39,15 @@ export class JobClient extends OpenPAIBaseClient {

/**
* Get the list of jobs.
* @param username filter jobs with username.
* @param query filter jobs by username, vc, state and keyword. Set offset, limit, order and withTotalCount.
*/
public async listJobs(username?: string): Promise<IJobInfo[]> {
public async listJobs(query?: IJobListQeury): Promise<IJobInfo[] | { totalCount: number, data: IJobInfo[] }> {
const url: string = Util.fixUrl(
`${this.cluster.rest_server_uri}/api/v2/jobs`,
this.cluster.https
);
return await this.httpClient.get(
url, undefined, undefined, { username }
url, undefined, undefined, query
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/api/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { StorageNodeV2 as StorageNode } from './clients/storageClient';
import { IAuthnInfo, ILoginInfo } from './models/authn';
import { IPAICluster, IPAIClusterInfo } from './models/cluster';
import { IGroup } from './models/group';
import { IJobAttempt, IJobFrameworkInfo, IJobInfo, IJobSshInfo, IJobStatus } from './models/job';
import { IJobAttempt, IJobFrameworkInfo, IJobInfo, IJobListQeury, IJobSshInfo, IJobStatus } from './models/job';
import { IPAIResponse } from './models/paiResponse';
import { IMountInfo, IStorageConfig, IStorageDetail, IStorageServer, IStorageSummary } from './models/storage';
import { IToken, ITokenList } from './models/token';
Expand Down Expand Up @@ -59,6 +59,7 @@ export {
IStorageDetail,
IMountInfo,
IJobStatus,
IJobListQeury,
StorageNode,
IGroup,
GroupClient,
Expand Down
24 changes: 24 additions & 0 deletions src/api/v2/models/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ export interface IJobInfo {
totalTaskRoleNumber: number;
}

/**
* Query object for list job, filter jobs by username, vc, state and keyword. Set offset, limit, order and withTotalCount.
* e.g.
* {
* username: 'user1,user2',
* vc: 'vc1,vc2',
* state: 'RUNNING,WAITING,STOPPED',
* keyword: 'mnist',
* offset: 0,
* order: 'submissionTime,DESC',
* withTotalCount: false
* }
*/
export interface IJobListQeury {
username?: string;
vc?: string;
state?: string;
keyword?: string;
offset?: number;
limit?: number;
order?: string; // format <field>,<ASC|DESC>, default value is "submissionTime,DESC"
withTotalCount?: boolean;
}

export interface IAppExitSpec {
code: number;
phrase: string;
Expand Down

0 comments on commit fa954c7

Please sign in to comment.