From 56792ef5c1e5b1ee542e821c2e7a9622715a1706 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Fri, 5 Jul 2024 17:25:09 +0000 Subject: [PATCH] chore: go live --- .gitignore | 1 + .stats.yml | 2 +- api.md | 4 + src/index.ts | 2 + src/resources/index.ts | 8 +- src/resources/projects/index.ts | 10 +- src/resources/projects/inference-pipelines.ts | 120 +++++++++++ src/resources/projects/projects.ts | 196 ++++++++++++++++++ .../projects/inference-pipelines.test.ts | 26 +++ tests/api-resources/projects/projects.test.ts | 28 +++ 10 files changed, 394 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9a5858a7..3eed6ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.prism.log node_modules yarn-error.log codegen.log diff --git a/.stats.yml b/.stats.yml index 2b7dbf39..699660ea 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 6 +configured_endpoints: 8 diff --git a/api.md b/api.md index a5dc9707..8e1c3f52 100644 --- a/api.md +++ b/api.md @@ -2,10 +2,12 @@ Types: +- ProjectCreateResponse - ProjectListResponse Methods: +- client.projects.create({ ...params }) -> ProjectCreateResponse - client.projects.list({ ...params }) -> ProjectListResponse ## Commits @@ -22,10 +24,12 @@ Methods: Types: +- InferencePipelineCreateResponse - InferencePipelineListResponse Methods: +- client.projects.inferencePipelines.create(id, { ...params }) -> InferencePipelineCreateResponse - client.projects.inferencePipelines.list(id, { ...params }) -> InferencePipelineListResponse # Commits diff --git a/src/index.ts b/src/index.ts index 337bc83a..ca4d7420 100644 --- a/src/index.ts +++ b/src/index.ts @@ -191,7 +191,9 @@ export namespace Openlayer { export import RequestOptions = Core.RequestOptions; export import Projects = API.Projects; + export import ProjectCreateResponse = API.ProjectCreateResponse; export import ProjectListResponse = API.ProjectListResponse; + export import ProjectCreateParams = API.ProjectCreateParams; export import ProjectListParams = API.ProjectListParams; export import Commits = API.Commits; diff --git a/src/resources/index.ts b/src/resources/index.ts index d68108a0..e22e510a 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -2,4 +2,10 @@ export { Commits } from './commits/commits'; export { InferencePipelines } from './inference-pipelines/inference-pipelines'; -export { ProjectListResponse, ProjectListParams, Projects } from './projects/projects'; +export { + ProjectCreateResponse, + ProjectListResponse, + ProjectCreateParams, + ProjectListParams, + Projects, +} from './projects/projects'; diff --git a/src/resources/projects/index.ts b/src/resources/projects/index.ts index b51837cd..62a84c5a 100644 --- a/src/resources/projects/index.ts +++ b/src/resources/projects/index.ts @@ -2,8 +2,16 @@ export { CommitListResponse, CommitListParams, Commits } from './commits'; export { + InferencePipelineCreateResponse, InferencePipelineListResponse, + InferencePipelineCreateParams, InferencePipelineListParams, InferencePipelines, } from './inference-pipelines'; -export { ProjectListResponse, ProjectListParams, Projects } from './projects'; +export { + ProjectCreateResponse, + ProjectListResponse, + ProjectCreateParams, + ProjectListParams, + Projects, +} from './projects'; diff --git a/src/resources/projects/inference-pipelines.ts b/src/resources/projects/inference-pipelines.ts index 1fa533f4..28c51863 100644 --- a/src/resources/projects/inference-pipelines.ts +++ b/src/resources/projects/inference-pipelines.ts @@ -6,6 +6,17 @@ import * as Core from '../../core'; import * as InferencePipelinesAPI from './inference-pipelines'; export class InferencePipelines extends APIResource { + /** + * Create an inference pipeline under a project. + */ + create( + id: string, + body: InferencePipelineCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post(`/projects/${id}/inference-pipelines`, { body, ...options }); + } + /** * List the inference pipelines in a project. */ @@ -27,6 +38,91 @@ export class InferencePipelines extends APIResource { } } +export interface InferencePipelineCreateResponse { + /** + * The inference pipeline id. + */ + id: string; + + /** + * The creation date. + */ + dateCreated: string; + + /** + * The last test evaluation date. + */ + dateLastEvaluated: string | null; + + /** + * The last data sample received date. + */ + dateLastSampleReceived: string | null; + + /** + * The next test evaluation date. + */ + dateOfNextEvaluation: string | null; + + /** + * The last updated date. + */ + dateUpdated: string; + + /** + * The inference pipeline description. + */ + description: string | null; + + /** + * The number of tests failing. + */ + failingGoalCount: number; + + links: InferencePipelineCreateResponse.Links; + + /** + * The inference pipeline name. + */ + name: string; + + /** + * The number of tests passing. + */ + passingGoalCount: number; + + /** + * The project id. + */ + projectId: string; + + /** + * The status of test evaluation for the inference pipeline. + */ + status: 'queued' | 'running' | 'paused' | 'failed' | 'completed' | 'unknown'; + + /** + * The status message of test evaluation for the inference pipeline. + */ + statusMessage: string | null; + + /** + * The total number of tests. + */ + totalGoalCount: number; + + /** + * The storage type. + */ + storageType?: 'local' | 's3' | 'gcs' | 'azure'; +} + +export namespace InferencePipelineCreateResponse { + export interface Links { + app: string; + } +} + export interface InferencePipelineListResponse { _meta: InferencePipelineListResponse._Meta; @@ -142,6 +238,28 @@ export namespace InferencePipelineListResponse { } } +export interface InferencePipelineCreateParams { + /** + * The inference pipeline description. + */ + description: string | null; + + /** + * The inference pipeline name. + */ + name: string; + + /** + * The reference dataset URI. + */ + referenceDatasetUri?: string | null; + + /** + * The storage type. + */ + storageType?: 'local' | 's3' | 'gcs' | 'azure'; +} + export interface InferencePipelineListParams { /** * Filter list of items by name. @@ -160,6 +278,8 @@ export interface InferencePipelineListParams { } export namespace InferencePipelines { + export import InferencePipelineCreateResponse = InferencePipelinesAPI.InferencePipelineCreateResponse; export import InferencePipelineListResponse = InferencePipelinesAPI.InferencePipelineListResponse; + export import InferencePipelineCreateParams = InferencePipelinesAPI.InferencePipelineCreateParams; export import InferencePipelineListParams = InferencePipelinesAPI.InferencePipelineListParams; } diff --git a/src/resources/projects/projects.ts b/src/resources/projects/projects.ts index 95e43d75..3a6ad577 100644 --- a/src/resources/projects/projects.ts +++ b/src/resources/projects/projects.ts @@ -13,6 +13,13 @@ export class Projects extends APIResource { this._client, ); + /** + * Create a project under the current workspace. + */ + create(body: ProjectCreateParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/projects', { body, ...options }); + } + /** * List the projects in a user's workspace. */ @@ -29,6 +36,145 @@ export class Projects extends APIResource { } } +export interface ProjectCreateResponse { + /** + * The project id. + */ + id: string; + + /** + * The project creator id. + */ + creatorId: string | null; + + /** + * The project creation date. + */ + dateCreated: string; + + /** + * The project last updated date. + */ + dateUpdated: string; + + /** + * The number of tests in the development mode of the project. + */ + developmentGoalCount: number; + + /** + * The total number of tests in the project. + */ + goalCount: number; + + /** + * The number of inference pipelines in the project. + */ + inferencePipelineCount: number; + + /** + * Links to the project. + */ + links: ProjectCreateResponse.Links; + + /** + * The number of tests in the monitoring mode of the project. + */ + monitoringGoalCount: number; + + /** + * The project name. + */ + name: string; + + /** + * Whether the project is a sample project or a user-created project. + */ + sample: boolean; + + /** + * The source of the project. + */ + source: 'web' | 'api' | 'null' | null; + + /** + * The task type of the project. + */ + taskType: 'llm-base' | 'tabular-classification' | 'tabular-regression' | 'text-classification'; + + /** + * The number of versions (commits) in the project. + */ + versionCount: number; + + /** + * The workspace id. + */ + workspaceId: string | null; + + /** + * The project description. + */ + description?: string | null; + + gitRepo?: ProjectCreateResponse.GitRepo | null; + + /** + * The slack channel id connected to the project. + */ + slackChannelId?: string | null; + + /** + * The slack channel connected to the project. + */ + slackChannelName?: string | null; + + /** + * Whether slack channel notifications are enabled for the project. + */ + slackChannelNotificationsEnabled?: boolean; + + /** + * The number of unread notifications in the project. + */ + unreadNotificationCount?: number; +} + +export namespace ProjectCreateResponse { + /** + * Links to the project. + */ + export interface Links { + app: string; + } + + export interface GitRepo { + id: string; + + dateConnected: string; + + dateUpdated: string; + + gitAccountId: string; + + gitId: number; + + name: string; + + private: boolean; + + projectId: string; + + slug: string; + + url: string; + + branch?: string; + + rootDir?: string; + } +} + export interface ProjectListResponse { _meta: ProjectListResponse._Meta; @@ -198,6 +344,52 @@ export namespace ProjectListResponse { } } +export interface ProjectCreateParams { + /** + * The project name. + */ + name: string; + + /** + * The task type of the project. + */ + taskType: 'llm-base' | 'tabular-classification' | 'tabular-regression' | 'text-classification'; + + /** + * The project description. + */ + description?: string | null; + + gitRepo?: ProjectCreateParams.GitRepo | null; + + /** + * The slack channel id connected to the project. + */ + slackChannelId?: string | null; + + /** + * The slack channel connected to the project. + */ + slackChannelName?: string | null; + + /** + * Whether slack channel notifications are enabled for the project. + */ + slackChannelNotificationsEnabled?: boolean; +} + +export namespace ProjectCreateParams { + export interface GitRepo { + gitAccountId: string; + + gitId: number; + + branch?: string; + + rootDir?: string; + } +} + export interface ProjectListParams { /** * Filter list of items by project name. @@ -221,12 +413,16 @@ export interface ProjectListParams { } export namespace Projects { + export import ProjectCreateResponse = ProjectsAPI.ProjectCreateResponse; export import ProjectListResponse = ProjectsAPI.ProjectListResponse; + export import ProjectCreateParams = ProjectsAPI.ProjectCreateParams; export import ProjectListParams = ProjectsAPI.ProjectListParams; export import Commits = CommitsAPI.Commits; export import CommitListResponse = CommitsAPI.CommitListResponse; export import CommitListParams = CommitsAPI.CommitListParams; export import InferencePipelines = InferencePipelinesAPI.InferencePipelines; + export import InferencePipelineCreateResponse = InferencePipelinesAPI.InferencePipelineCreateResponse; export import InferencePipelineListResponse = InferencePipelinesAPI.InferencePipelineListResponse; + export import InferencePipelineCreateParams = InferencePipelinesAPI.InferencePipelineCreateParams; export import InferencePipelineListParams = InferencePipelinesAPI.InferencePipelineListParams; } diff --git a/tests/api-resources/projects/inference-pipelines.test.ts b/tests/api-resources/projects/inference-pipelines.test.ts index 0529a243..2b030a28 100644 --- a/tests/api-resources/projects/inference-pipelines.test.ts +++ b/tests/api-resources/projects/inference-pipelines.test.ts @@ -9,6 +9,32 @@ const openlayer = new Openlayer({ }); describe('resource inferencePipelines', () => { + test('create: only required params', async () => { + const responsePromise = openlayer.projects.inferencePipelines.create( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { description: 'This pipeline is used for production.', name: 'production' }, + ); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await openlayer.projects.inferencePipelines.create( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { + description: 'This pipeline is used for production.', + name: 'production', + referenceDatasetUri: 's3://...', + storageType: 's3', + }, + ); + }); + test('list', async () => { const responsePromise = openlayer.projects.inferencePipelines.list( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', diff --git a/tests/api-resources/projects/projects.test.ts b/tests/api-resources/projects/projects.test.ts index b007bb43..87e2c7b5 100644 --- a/tests/api-resources/projects/projects.test.ts +++ b/tests/api-resources/projects/projects.test.ts @@ -9,6 +9,34 @@ const openlayer = new Openlayer({ }); describe('resource projects', () => { + test('create: only required params', async () => { + const responsePromise = openlayer.projects.create({ name: 'My Project', taskType: 'llm-base' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await openlayer.projects.create({ + name: 'My Project', + taskType: 'llm-base', + description: 'My project description.', + gitRepo: { + gitId: 0, + branch: 'string', + rootDir: 'string', + gitAccountId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + slackChannelId: 'C01B2PZQX1Z', + slackChannelName: '#my-project', + slackChannelNotificationsEnabled: true, + }); + }); + test('list', async () => { const responsePromise = openlayer.projects.list(); const rawResponse = await responsePromise.asResponse();