diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml deleted file mode 100644 index d820b508..00000000 --- a/.github/workflows/create-releases.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Create releases -on: - schedule: - - cron: '0 5 * * *' # every day at 5am UTC - push: - branches: - - main - -jobs: - release: - name: release - if: github.ref == 'refs/heads/main' && github.repository == 'openlayer-ai/openlayer-ts' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: stainless-api/trigger-release-please@v1 - id: release - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} - - - name: Set up Node - if: ${{ steps.release.outputs.releases_created }} - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Install dependencies - if: ${{ steps.release.outputs.releases_created }} - run: | - yarn install - - - name: Publish to NPM - if: ${{ steps.release.outputs.releases_created }} - run: | - bash ./bin/publish-npm - env: - NPM_TOKEN: ${{ secrets.OPENLAYER_NPM_TOKEN || secrets.NPM_TOKEN }} - diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 405e7690..361a64a4 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -1,9 +1,13 @@ -# workflow for re-running publishing to NPM in case it fails for some reason -# you can run this workflow by navigating to https://www.github.com/openlayer-ai/openlayer-ts/actions/workflows/publish-npm.yml +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to NPM in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/openlayer-ai/openlayer-ts/actions/workflows/publish-npm.yml name: Publish NPM on: workflow_dispatch: + release: + types: [published] + jobs: publish: name: publish diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index fe63f8cf..f021d930 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -18,6 +18,5 @@ jobs: run: | bash ./bin/check-release-environment env: - STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} NPM_TOKEN: ${{ secrets.OPENLAYER_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.stats.yml b/.stats.yml index dd473053..c2549479 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 14 +configured_endpoints: 15 diff --git a/api.md b/api.md index ccf5bcd7..93b42525 100644 --- a/api.md +++ b/api.md @@ -36,6 +36,14 @@ Methods: # Commits +Types: + +- CommitRetrieveResponse + +Methods: + +- client.commits.retrieve(projectVersionId) -> CommitRetrieveResponse + ## TestResults Types: diff --git a/bin/check-release-environment b/bin/check-release-environment index 5da9dd75..0f4fafe7 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,10 +2,6 @@ errors=() -if [ -z "${STAINLESS_API_KEY}" ]; then - errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.") -fi - if [ -z "${NPM_TOKEN}" ]; then errors+=("The OPENLAYER_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi diff --git a/src/index.ts b/src/index.ts index 537ab641..96767aab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import * as Core from './core'; import * as Errors from './error'; import * as Uploads from './uploads'; import * as API from './resources/index'; -import { Commits } from './resources/commits/commits'; +import { CommitRetrieveResponse, Commits } from './resources/commits/commits'; import { InferencePipelineRetrieveParams, InferencePipelineRetrieveResponse, @@ -206,7 +206,7 @@ export declare namespace Openlayer { type ProjectListParams as ProjectListParams, }; - export { Commits as Commits }; + export { Commits as Commits, type CommitRetrieveResponse as CommitRetrieveResponse }; export { InferencePipelines as InferencePipelines, diff --git a/src/resources/commits/commits.ts b/src/resources/commits/commits.ts index a4f808b6..05646de3 100644 --- a/src/resources/commits/commits.ts +++ b/src/resources/commits/commits.ts @@ -1,16 +1,177 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; +import * as Core from '../../core'; import * as TestResultsAPI from './test-results'; import { TestResultListParams, TestResultListResponse, TestResults } from './test-results'; export class Commits extends APIResource { testResults: TestResultsAPI.TestResults = new TestResultsAPI.TestResults(this._client); + + /** + * Retrieve a project version (commit) by its id. + */ + retrieve(projectVersionId: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.get(`/versions/${projectVersionId}`, options); + } +} + +export interface CommitRetrieveResponse { + /** + * The project version (commit) id. + */ + id: string; + + /** + * The details of a commit (project version). + */ + commit: CommitRetrieveResponse.Commit; + + /** + * The commit archive date. + */ + dateArchived: string | null; + + /** + * The project version (commit) creation date. + */ + dateCreated: string; + + /** + * The number of tests that are failing for the commit. + */ + failingGoalCount: number; + + /** + * The model id. + */ + mlModelId: string | null; + + /** + * The number of tests that are passing for the commit. + */ + passingGoalCount: number; + + /** + * The project id. + */ + projectId: string; + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to + * `running`. Finally, it can be `paused`, `failed`, or `completed`. + */ + status: 'queued' | 'running' | 'paused' | 'failed' | 'completed' | 'unknown'; + + /** + * The commit status message. + */ + statusMessage: string | null; + + /** + * The total number of tests for the commit. + */ + totalGoalCount: number; + + /** + * The training dataset id. + */ + trainingDatasetId: string | null; + + /** + * The validation dataset id. + */ + validationDatasetId: string | null; + + /** + * Whether the commit is archived. + */ + archived?: boolean | null; + + /** + * The deployment status associated with the commit's model. + */ + deploymentStatus?: string; + + links?: CommitRetrieveResponse.Links; +} + +export namespace CommitRetrieveResponse { + /** + * The details of a commit (project version). + */ + export interface Commit { + /** + * The commit id. + */ + id: string; + + /** + * The author id of the commit. + */ + authorId: string; + + /** + * The size of the commit bundle in bytes. + */ + fileSize: number | null; + + /** + * The commit message. + */ + message: string; + + /** + * The model id. + */ + mlModelId: string | null; + + /** + * The storage URI where the commit bundle is stored. + */ + storageUri: string; + + /** + * The training dataset id. + */ + trainingDatasetId: string | null; + + /** + * The validation dataset id. + */ + validationDatasetId: string | null; + + /** + * The commit creation date. + */ + dateCreated?: string; + + /** + * The ref of the corresponding git commit. + */ + gitCommitRef?: string; + + /** + * The SHA of the corresponding git commit. + */ + gitCommitSha?: number; + + /** + * The URL of the corresponding git commit. + */ + gitCommitUrl?: string; + } + + export interface Links { + app: string; + } } Commits.TestResults = TestResults; export declare namespace Commits { + export { type CommitRetrieveResponse as CommitRetrieveResponse }; + export { TestResults as TestResults, type TestResultListResponse as TestResultListResponse, diff --git a/src/resources/commits/index.ts b/src/resources/commits/index.ts index 935b4403..7147aef0 100644 --- a/src/resources/commits/index.ts +++ b/src/resources/commits/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Commits } from './commits'; +export { Commits, type CommitRetrieveResponse } from './commits'; export { TestResults, type TestResultListResponse, type TestResultListParams } from './test-results'; diff --git a/src/resources/index.ts b/src/resources/index.ts index 4752118c..1aa45cb9 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Commits } from './commits/commits'; +export { Commits, type CommitRetrieveResponse } from './commits/commits'; export { InferencePipelines, type InferencePipelineRetrieveResponse, diff --git a/tests/api-resources/commits/commits.test.ts b/tests/api-resources/commits/commits.test.ts new file mode 100644 index 00000000..4a618f2c --- /dev/null +++ b/tests/api-resources/commits/commits.test.ts @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Openlayer from 'openlayer'; +import { Response } from 'node-fetch'; + +const client = new Openlayer({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource commits', () => { + test('retrieve', async () => { + const responsePromise = client.commits.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + 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('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.commits.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Openlayer.NotFoundError); + }); +});