Skip to content

Commit

Permalink
🌿 introduce generators and OpenAPI spec merging
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo committed Mar 5, 2024
1 parent 78f246a commit 93d6faa
Show file tree
Hide file tree
Showing 22 changed files with 415 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: ci

on:
push: {}
release:
types:
- published

jobs:
fern-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Fern
run: npm install -g fern-api

- name: Check Fern API is valid
run: fern check

fern-generate-python:
needs: fern-check
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'python@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Generate Python SDK
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
tag=${{ github.event.release.tag_name }}
prefix="python@"
SDK_VERSION="${tag#$prefix}"
fern generate --api api --group python-sdk --log-level debug --version "$SDK_VERSION"
fern-generate-ts:
needs: fern-check
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'node@')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3

- name: Download Fern
run: npm install -g fern-api

- name: Generate Node SDK
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
tag=${{ github.event.release.tag_name }}
prefix="node@"
SDK_VERSION="${tag#$prefix}"
fern generate --api api --group ts-sdk --log-level debug --version "$SDK_VERSION"
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
Fern Config
# Octo Fern Configuration

This repository contains your Fern Configuration:
- OpenAPI specs
- [Asset Lake OpenAPI Spec](./fern/apis/asset-lake/openapi/openapi.json)
- [Fine Tuning OpenAPI Spec](./fern/apis/fine-tuning/openapi/openapi.json)
- [Image Gen OpenAPI Spec](./fern/apis/image-gen/openapi/openapi.json)
- [Text Gen OpenAPI Spec](./fern/apis/text-gen/openapi/openapi.json)
- [Generators config](./fern/apis/api/generators.yml)

## Validating your API Definition

To validate your API, run:
```sh
npm install -g fern-api # only required once
fern check
```
## Updating your SDKs

To update your SDKs, simply tag a release with `<language>@<version>`
e.g. `python@<version>` or `node@<version>` on the repository. Under the hood,
this leverages the Fern CLI:

```sh
npm install -g fern-api # only required once
fern generate --group python-sdk --api api
```
24 changes: 24 additions & 0 deletions fern/apis/api/definition/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: api
display-name: OctoAI

error-discrimination:
strategy: status-code

auth: BearerAuthScheme
auth-schemes:
BearerAuthScheme:
scheme: bearer
token:
name: api_key
env: OCTOAI_TOKEN

default-environment: Production
# environments:
# Production:
# urls:
# Default: https://api.octoai.cloud
# ImageGen: https://image.octoai.cloud
# TextGen: https://text.octoai.cloud
environments:
Production: https://api.octoai.cloud

1 change: 1 addition & 0 deletions fern/apis/api/definition/asset-lake/__package__.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export: asset-lake
1 change: 1 addition & 0 deletions fern/apis/api/definition/fine-tuning/__package__.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export: fine-tuning
1 change: 1 addition & 0 deletions fern/apis/api/definition/image-gen/__package__.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export: image-gen
1 change: 1 addition & 0 deletions fern/apis/api/definition/text-gen/__package__.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export: text-gen
5 changes: 5 additions & 0 deletions fern/apis/api/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
asset-lake: ../asset-lake
fine-tuning: ../fine-tuning
image-gen: ../image-gen
text-gen: ../text-gen
59 changes: 59 additions & 0 deletions fern/apis/api/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
default-group: local
groups:
local:
generators:
- name: fernapi/fern-python-sdk
version: 0.11.9
output:
location: local-file-system
path: ../../../python
config:
client_class_name: OctoAI
improved_imports: true
pydantic_config:
use_str_enums: true
- name: fernapi/fern-typescript-node-sdk
version: 0.12.5
output:
location: local-file-system
path: ../../../typescript
config:
namespaceExport: OctoAI
skipResponseValidation: true
allowCustomFetcher: true
includeApiReference: true
smart-casing: true
python-sdk:
generators:
- name: fernapi/fern-python-sdk
version: 0.11.9
output:
location: pypi
package-name: "octoai"
token: ${PYPI_TOKEN}
github:
repository: octoml/octoai-python-sdk-fern
mode: pull-request
config:
client_class_name: OctoAI
improved_imports: true
pydantic_config:
use_str_enums: true
smart-casing: true
ts-sdk:
generators:
- name: fernapi/fern-typescript-node-sdk
version: 0.12.5
output:
location: npm
package-name: "@octoai/octoai-node-client"
token: ${NPM_TOKEN}
github:
repository: octoml/octoai-typescript-sdk-fern
mode: pull-request
config:
namespaceExport: OctoAI
skipResponseValidation: true
allowCustomFetcher: true
includeApiReference: true
smart-casing: true
2 changes: 2 additions & 0 deletions fern/apis/asset-lake/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openapi: ./openapi/openapi.json
openapi-overrides: ./openapi/openapi-overrides.yml
75 changes: 75 additions & 0 deletions fern/apis/asset-lake/openapi/openapi-overrides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
paths:
# Hide healthcheck
/health:
get:
x-fern-ignore: true
/v1/assets:
get:
x-fern-sdk-method-name: list
post:
x-fern-sdk-method-name: create
/v1/assets/{asset_id}:
delete:
x-fern-sdk-method-name: delete
/v1/assets/{asset_id}/complete-upload:
post:
x-fern-sdk-method-name: completeUpload
/v1/assets/{asset_owner_and_name_or_id}:
get:
x-fern-sdk-method-name: get
components:
schemas:
Asset:
x-fern-type-name: Asset
AssetType:
x-fern-type-name: AssetType
BaseEngine:
x-fern-type-name: BaseEngine
CheckpointData:
x-fern-type-name: CheckpointData
CompleteAssetUploadRequest:
x-fern-type-name: CompleteAssetUploadRequest
CompleteAssetUploadResponse:
x-fern-type-name: CompleteAssetUploadResponse
CreateAssetRequest:
x-fern-type-name: CreateAssetRequest
CreateAssetResponse:
x-fern-type-name: CreateAssetResponse
DataType:
x-fern-type-name: DataType
DeleteAssetResponse:
x-fern-type-name: DeleteAssetResponse
FileData:
x-fern-type-name: FileData
FileExtension:
x-fern-type-name: FileExtension
FileFormat:
x-fern-type-name: FileFormat
FileStructure:
x-fern-type-name: FileStructure
HTTPValidationError:
x-fern-type-name: HTTPValidationError
LatentData:
x-fern-type-name: LatentData
ListAssetsResponse:
x-fern-type-name: ListAssetsResponse
LoraData:
x-fern-type-name: LoraData
NoTransferApi:
x-fern-type-name: NoTransferApi
PresignedUrlTransferApi:
x-fern-type-name: PresignedUrlTransferApi
RetrieveAssetResponse:
x-fern-type-name: RetrieveAssetResponse
Status:
x-fern-type-name: Status
StsTransferApi:
x-fern-type-name: StsTransferApi
TextualInversionData:
x-fern-type-name: TextualInversionData
TransferApiType:
x-fern-type-name: TransferApiType
VAEData:
x-fern-type-name: VAEData
ValidationError:
x-fern-type-name: ValidationError
File renamed without changes.
2 changes: 2 additions & 0 deletions fern/apis/fine-tuning/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openapi: ./openapi/openapi.json
openapi-overrides: ./openapi/openapi-overrides.yml
52 changes: 52 additions & 0 deletions fern/apis/fine-tuning/openapi/openapi-overrides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
paths:
# Hide healthcheck
/health:
get:
x-fern-ignore: true
/v1/tune:
post:
x-fern-sdk-method-name: create
/v1/tune/{tune_id}:
get:
x-fern-sdk-method-name: get
delete:
x-fern-sdk-method-name: delete
/v1/tune/{tune_id}/cancel:
post:
x-fern-sdk-method-name: cancel
/v1/tunes:
get:
x-fern-sdk-method-name: list
components:
schemas:
BaseEngine:
x-fern-type-name: BaseEngine
CreateTuneRequest:
x-fern-type-name: CreateTuneRequest
HTTPValidationError:
x-fern-type-name: HTTPValidationError
ListTunesResponse:
x-fern-type-name: ListTunesResponse
LoraTune-Input:
x-fern-type-name: LoraTune
LoraTune-Output:
x-fern-type-name: LoraTune
LoraTuneCheckpoint:
x-fern-type-name: LoraTuneCheckpoint
LoraTuneFile:
x-fern-type-name: LoraTuneFile
TextToSpeechLatentTune:
x-fern-type-name: TextToSpeechLatentTune
Tune:
x-fern-type-name: Tune
properties:
details:
x-fern-type-name: TuneDetails
TuneResult:
x-fern-type-name: TuneResult
TuneStatus:
x-fern-type-name: TuneStatus
TuneType:
x-fern-type-name: TuneType
ValidationError:
x-fern-type-name: ValidationError
File renamed without changes.
2 changes: 2 additions & 0 deletions fern/apis/image-gen/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openapi: ./openapi/openapi.json
openapi-overrides: ./openapi/openapi-overrides.yml
38 changes: 38 additions & 0 deletions fern/apis/image-gen/openapi/openapi-overrides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
paths:
/generate/ssd:
post:
x-fern-sdk-method-name: generateSsd
/generate/controlnet-sdxl:
post:
x-fern-sdk-method-name: generateControlnetSdxl
/generate/controlnet-sd15:
post:
x-fern-sdk-method-name: generateControlnetSd15
/generate/sdxl:
post:
x-fern-sdk-method-name: generateSdxl
/generate/sd:
post:
x-fern-sdk-method-name: generateSd
# Hide healthcheck
/healthcheck:
get:
x-fern-ignore: true
components:
schemas:
HTTPValidationError:
x-fern-type-name: HTTPValidationError
ImageEncoding:
x-fern-type-name: ImageEncoding
ImageGeneration:
x-fern-type-name: ImageGeneration
ImageGenerationRequest:
x-fern-type-name: ImageGenerationRequest
ImageGenerationResponse:
x-fern-type-name: ImageGenerationResponse
SDXLStyles:
x-fern-type-name: SDXLStyles
Scheduler:
x-fern-type-name: Scheduler
ValidationError:
x-fern-type-name: ValidationError
File renamed without changes.
2 changes: 2 additions & 0 deletions fern/apis/text-gen/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openapi: ./openapi/openapi.json
openapi-overrides: ./openapi/openapi-overrides.yml
Loading

0 comments on commit 93d6faa

Please sign in to comment.