Skip to content

Commit

Permalink
Merge pull request #65 from ainize-team/release/1.0.0
Browse files Browse the repository at this point in the history
Release/1.0.0
  • Loading branch information
yoojinko authored Sep 27, 2023
2 parents c64453f + 2ecb636 commit ebcce1e
Show file tree
Hide file tree
Showing 26 changed files with 5,138 additions and 79 deletions.
Binary file added .DS_Store
Binary file not shown.
93 changes: 35 additions & 58 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,39 @@
# github action name
name: Auto Publish - patch update

# develop 브랜치에 push 되면 자동 patch update를 한다는 구현
name: Create Release Branch
on:
push:
branches: [ develop ]

# 실제 실행 구현부
workflow_dispatch:
inputs:
version:
type: choice
description: Sematic version type of new version
options:
- patch
- minor
- major
jobs:
# build 환경
build:
release:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
node-version: [16.13.1]
# 실행할 순서

steps:
# github action에서 NodeJS 세팅을 위한 actions/setup-node@v2 action을 사용
- uses: actions/checkout@v2
- name: Set up NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
# yarn을 사용하기에 yarn을 global install하고 install dependencies
- name : Install Dependencies
run: |
npm install -g yarn
npm install --legacy-peer-deps --save-dev --ignore-scripts install-peers
yarn install
# npm version을 patch 명령어를 통해 올리고, 리눅스 파이프라인 명령어를 통해 patch로 변경한 버전을 저장
- name : Patch
run: |
npm version patch > version.txt
# 저장한 버전 파일을 읽어 변수로 사용하기 위해 외부 action을 사용 -> setps.{id}.outputs.content로 사용 가능
- name: Read version.txt
id: commit
uses: juliangruber/read-file-action@v1
with:
path: ./version.txt
# version을 변경한 package.json을 commit, 바뀐 버전으로 commit message 작성 후 push
- name: Deploy and Push
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add package.json
git commit -m "${{ (steps.commit.outputs.content) }}"
echo ${{ (steps.commit.outputs.content) }}
yarn deploy
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# slack 웹훅을 통해 채널에 전송
- name: Send result to slack
uses: Ilshidur/[email protected]
with:
args: "버전 ➡️${{ (steps.commit.outputs.content) }}의 결과는 ➡️${{ job.status }} 에요"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
- uses: actions/checkout@v3
with:
ref: develop
- name: Git configuration
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
- name: Upgrade version
run: |
yarn --no-git-tag-version version --$RELEASE_TYPE
echo "NEW_VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.version }}
- name: Create release branch
run: |
git checkout -b release/${{ env.NEW_VERSION }}
git add "package.json"
git commit -m "Upgrade version to ${{ env.NEW_VERSION }}"
git push origin release/${{ env.NEW_VERSION }}
gh pr create -B main -H release/${{ env.NEW_VERSION }} -d --title 'Upgrade version to ${{ env.NEW_VERSION }}' --body 'Upgrade version to ${{ env.NEW_VERSION }}'
gh pr create -B develop -H release/${{ env.NEW_VERSION }} -d --title 'Release/${{ env.NEW_VERSION }} -> develop' --body 'Upgrade version to ${{ env.NEW_VERSION }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docs
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- uses: actions/setup-node@v3
with:
node-version: 16 # typedoc require node version >= 14.14
- name: Build Docs
run: yarn && yarn docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
23 changes: 23 additions & 0 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test Pipeline for opened PR
on:
pull_request:
branches: [ main, develop ] #put your branches which you want to execute test pipeline
types: [ opened, ready_for_review ]
concurrency:
group: ${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
run_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16 ]
name: Run Test on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: yarn install --immutable --immutable-cache --check-cache
- run: yarn test
78 changes: 78 additions & 0 deletions .github/workflows/pr_test_when_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test Pipeline for Merged PR
on:
pull_request:
branches: [ main, develop ]
types: [ closed ]
concurrency:
group: ${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
run_test:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16 ]
name: Run Test on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: yarn install --immutable --immutable-cache --check-cache
- run: yarn test
publish:
needs: [ run_test ]
if: ${{ startsWith(github.head_ref, 'release/') && (github.base_ref == 'main') && (github.event.pull_request.merged == true) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn
- name: Test Success
run: yarn test
- name: Publish package
run: |
yarn
yarn build
yarn publish --access public
echo "NEW_VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Push tag
run: |
git tag ${{ env.NEW_VERSION }}
git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify package published to slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Ainize-SDK ${{ env.NEW_VERSION }} is published",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Ainize-SDK Release"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Version ${{ env.NEW_VERSION }} is published"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
53 changes: 53 additions & 0 deletions .github/workflows/send_slack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Send Error to Slack
on:
workflow_run:
workflows: [ Test Pipeline for Merged PR ]
types:
- completed
jobs:
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- uses: actions/checkout@v3
- name: Get error log
id: error_log
run: |
ERROR_LOG="$(gh run view ${{ github.event.workflow_run.id }} --log-failed | tail -n 7 | rev | cut -f 1 | rev | sed -r 's/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g' | sed -z 's/\n/\\n/g' | sed 's/\t/ /g')"
echo "ERROR_LOG=$ERROR_LOG" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify error to slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "${{ github.event.workflow.name }} failed",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rotating_light:PIPELINE FAILED",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ github.event.workflow.name }} failed"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Error log*\n```${{ steps.error_log.outputs.ERROR_LOG }}```\nCheck full logs in ${{ github.event.workflow_run.html_url }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# typedoc
docs/
37 changes: 17 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
This is free and unencumbered software released into the public domain.
MIT License

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Copyright (c) 2023 AINIZE Team

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

For more information, please refer to <https://unlicense.org>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# ainize-sdk
# ainize-sdk

A Typescript SDK for the Ainize, a system for running AI services on the AI Network.

## Requirements
node >= 16

## usage
### Install
```bash
npm install @ainize-team/ainize-sdk

yarn install @ainize-team/ainize-sdk
```

### Import
```typescript
import Ainize from '@ainize-team/ainize-sdk'
const ainize = new Ainize(<CHAIN_ID>);
```

CHAIN_ID
- 0: AI Network test net
- 1: AI Network main net

### Login
You should login to ainize with AI Network account before deploy the container.
```typescript
ainize.login(<YOUR_PRIVATE_KEY>);
```

### Deploy
You can deploy your AI model to ainize.
```typescript
const model = await ainize.deploy(<CONFIGURATION>);
```
CONFIGURATION
- modelName: The name you want to deploying model.
- billingConfig: Billing configuration required for model usage.
- depositAddress: The address for receiving AIN deposits.
- costPerToken: Cost per token for model usage.
- minCost: Minimum cost.
- maxCost: Maximum cost. (optional)

You can stop or run your model container. Model deployer only can use this.
```typescript
model.stop();
model.run();
```

### Using Model
You can use a model using `ainize.model(<MODEL_NAME>)`.
```typescript
const model = await ainize.model(<MODEL_NAME>);
```

You should deposit AIN to credit before using model.
```typescript
await model.deposit(<AMOUNT>);
const balance = await model.getCreditBalance();
```

If you have enough credit, you can use the model.
```typescript
const result = await model.use(<REQUEST_DATA>);
```
Loading

0 comments on commit ebcce1e

Please sign in to comment.