-
Notifications
You must be signed in to change notification settings - Fork 4
support log dlc lineage #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
96eb6eb
99df4ed
124429a
b1d0a42
10c9d54
0dd26a4
f972256
05e391f
9ff250e
3ea7b77
487b212
22c68a4
67874dc
f82074d
7161b10
c071679
a63b181
a01c992
8534dff
47b45d9
0f7d2e5
45f6f39
9e1a08f
786057c
094092d
7f3c8d7
5705a75
cd5dcbc
d4238ed
50ad53b
130c99b
fb932ab
af857a7
be7962b
1dd66c0
ca7322c
3c3b162
cbe8ac7
9386329
46b3200
bf4dba2
0c12db6
d847a6f
2e3cf64
45ac6e9
4bb3cef
57f7579
dd73703
932b6ca
6ea65e6
f636fa0
1458d1b
86e4773
7abec53
a8c342e
5ac2ae2
33182af
61034f1
6743e11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | |||||||||||||||||||||||||||||
| name: Lint test | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| on: [push] | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| concurrency: | |||||||||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }} | |||||||||||||||||||||||||||||
| cancel-in-progress: true | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
| common-lint: | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
| - name: Set up Python 3.8 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: "3.8" | |||||||||||||||||||||||||||||
| - name: Install pre-commit hook | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| pip install pre-commit | |||||||||||||||||||||||||||||
| - name: Linting | |||||||||||||||||||||||||||||
| run: pre-commit run --all-files | |||||||||||||||||||||||||||||
| doc-lint: | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
| - name: Set up Python 3.8 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: "3.8" | |||||||||||||||||||||||||||||
| - name: Install Nox | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| pip install nox | |||||||||||||||||||||||||||||
| - name: Linting | |||||||||||||||||||||||||||||
| run: nox -s doc | |||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+35
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 2 months ago In general, the fix is to explicitly define a The best minimal fix while preserving behavior is to add a root-level Concretely, edit permissions:
contents: readafter
Suggested changeset
1
.github/workflows/lint.yaml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Publish Package | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Package | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PAI_PYPI_TOKEN: ${{ secrets.PAI_PYPI_TOKEN }} | ||
| ALIPAI_PYPI_TOKEN: ${{ secrets.ALIPAI_PYPI_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python 3.8 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.8' | ||
| - name: Install dependencies | ||
| run: pip install wheel setuptools twine | ||
| # build and upload package pai | ||
| - name: Build package for pai | ||
| run: python setup.py sdist bdist_wheel | ||
| - name: Publish package to PyPI (pai) | ||
| run: twine upload dist/* --skip-existing -u __token__ -p $PAI_PYPI_TOKEN | ||
| - name: cleanup | ||
| run: | | ||
| rm -rf dist | ||
| rm -rf build | ||
| rm -rf pai.egg-info | ||
| # build and upload package alipai | ||
| - name: Build package for alipai | ||
| run: PACKAGE_NAME=alipai python setup.py sdist bdist_wheel | ||
| - name: Publish package to PyPI (alipai) | ||
| run: twine upload dist/* --skip-existing -u __token__ -p $ALIPAI_PYPI_TOKEN |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Release Trigger | ||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - master | ||
| paths: | ||
| - 'pai/version.py' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Release Trigger | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v') | ||
| env: | ||
| PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
| PAI_PYPI_TOKEN: ${{ secrets.PAI_PYPI_TOKEN }} | ||
| ALIPAI_PYPI_TOKEN: ${{ secrets.ALIPAI_PYPI_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python 3.8 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.8' | ||
| - name: Check version match | ||
| id: check_version | ||
| run: | | ||
| BRANCH_VERSION=${{ github.head_ref }} | ||
| BRANCH_VERSION=${BRANCH_VERSION#releases/v} | ||
| FILE_VERSION=$(python -c "from pai.version import VERSION; print(VERSION)") | ||
| if [[ "$BRANCH_VERSION" != "$FILE_VERSION" ]]; then | ||
| echo "Version in branch name ($BRANCH_VERSION) does not match version in file ($FILE_VERSION)" | ||
| exit 1 | ||
| fi | ||
| - name: Get version and create version tag | ||
| run: | | ||
| VERSION=$(python -c "from pai.version import VERSION; print(VERSION)") | ||
| git tag v$VERSION | ||
| git push origin v$VERSION | ||
| # git tag pushed by GitHub action bot will not trigger another action. | ||
| - name: Install dependencies | ||
| run: pip install wheel setuptools twine | ||
| - name: Build package for pai | ||
| run: python setup.py sdist bdist_wheel | ||
| - name: Publish package to PyPI (pai) | ||
| run: twine upload dist/* --skip-existing -u __token__ -p $PAI_PYPI_TOKEN | ||
| - name: cleanup | ||
| run: | | ||
| rm -rf dist | ||
| rm -rf build | ||
| rm -rf pai.egg-info | ||
| - name: Build package for alipai | ||
| run: PACKAGE_NAME=alipai python setup.py sdist bdist_wheel | ||
| - name: Publish package to PyPI (alipai) | ||
| run: twine upload dist/* --skip-existing -u __token__ -p $ALIPAI_PYPI_TOKEN |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||
| name: Unit test | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: [push] | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||||||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| unit-test: | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| - name: Set up Python 3.8 | ||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| python-version: "3.8" | ||||||||||||||||||||||||||||||||
| - name: Install Nox | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| pip install nox | ||||||||||||||||||||||||||||||||
| - name: Linting | ||||||||||||||||||||||||||||||||
| run: nox -s unit | ||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+22
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 2 months ago In general, to fix this problem you should explicitly declare the minimal required The best minimal fix here is to add a Concretely, in permissions:
contents: readbetween the
Suggested changeset
1
.github/workflows/unit.yaml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,82 +1,119 @@ | ||
| # PAI Python SDK | ||
|
|
||
| [English](./README_CN.md) \| 简体中文 | ||
|
|
||
| English \| [简体中文](./README_CN.md) | ||
| PAI Python SDK是阿里云 [机器学习平台 PAI(Platform for Artificial Intelligence)](https://www.aliyun.com/product/bigdata/learn) 提供的Python SDK,提供了更易用的HighLevel API,支持机器学习工程师简单地使用Python在PAI完成模型训练和部署,串联机器学习的流程。 | ||
|
|
||
| The PAI Python SDK is provided by Alibaba Cloud\'s [Platform for Artificial Intelligence (PAI)](https://www.aliyun.com/product/bigdata/learn). It offers a user-friendly High-Level API, enabling machine learning engineers to easily train and deploy models on PAI using Python, streamlining the machine learning workflow. | ||
| ## 🔧 安装 | ||
|
|
||
| ## Installation 🔧 | ||
|
|
||
| Install the PAI Python SDK using the following command, which supports Python versions \>= 3.6 (it is recommended to use Python \>= 3.8): | ||
| 使用以下命令安装PAI Python SDK(支持Python版本 \>= 3.8): | ||
|
|
||
| ```shell | ||
| python -m pip install alipai | ||
| python -m pip install pai | ||
| ``` | ||
|
|
||
| ## Documentation 📖 | ||
| ## 📖 文档 | ||
|
|
||
| Find detailed documentation, including API references and user guides, in the [docs]{.title-ref} directory or visit [PAI Python SDK Documentation](https://pai-sdk.oss-cn-shanghai.aliyuncs.com/pai/doc/latest/index.html). | ||
| 请通过访问 [PAI Python SDK文档](https://pai.readthedocs.io/) 或是查看 [docs](./docs) 目录下的文件获取SDK的详细文档,包括用户指南和API文档。 | ||
|
|
||
| ## Basic Usage 🛠 | ||
| ## 🛠 使用示例 | ||
|
|
||
| - Submit a custom training job | ||
| - 提交自定义训练任务 | ||
|
|
||
| The following example demonstrates how to submit a custom training job to PAI: | ||
| 以下代码演示了如何通过SDK提交一个自定义的训练作业: | ||
|
|
||
| ```python | ||
| from pai.estimator import Estimator | ||
| from pai.image import retrieve | ||
|
|
||
| est = Estimator( | ||
| # Retrieve the latest PyTorch image provided by PAI | ||
| # 获取PAI提供的最新PyTorch镜像 | ||
| image_uri=retrieve( | ||
| framework_name="PyTorch", framework_version="latest" | ||
| ).image_uri, | ||
| command="echo hello", | ||
| # Optionally, specify the source_dir to upload your training code: | ||
| # 可选,指定source_dir上传你的训练代码: | ||
| # source_dir="./train_src", | ||
| instance_type="ecs.c6.large", | ||
| ) | ||
|
|
||
| # Submit the training job | ||
| # 提交训练任务 | ||
| est.fit() | ||
|
|
||
| print(est.model_data()) | ||
|
|
||
| ``` | ||
|
|
||
| - Deploy Large Language Model | ||
| - 部署大语言模型 | ||
|
|
||
| PAI provides numerous pretrained models that you can easily deploy using the PAI Python SDK: | ||
| PAI提供了大量预训练模型,可以使用PAI Python SDK轻松部署: | ||
|
|
||
| ```python | ||
| from pai.model import RegisteredModel | ||
|
|
||
| # Retrieve the QWen-7b model provided by PAI | ||
| qwen_model = RegisteredModel("qwen-7b-chat-lora", model_provider="pai") | ||
| # 获取PAI提供的QWen1.5-7b模型 | ||
| qwen_model = RegisteredModel("qwen1.5-7b-chat", model_provider="pai") | ||
|
|
||
| # Deploy the model | ||
| # 部署模型 | ||
| p = qwen_model.deploy(service_name="qwen_service") | ||
|
|
||
| # Call the service | ||
| # 调用服务 | ||
| p.predict( | ||
| data={ | ||
| "prompt": "How to install PyTorch?", | ||
| "system_prompt": "Act like you are programmer with 5+ years of experience.", | ||
| "prompt": "What is the purpose of life?", | ||
| "system_prompt": "You are helpful assistant.", | ||
| "temperature": 0.8, | ||
| } | ||
| ) | ||
|
|
||
| # PAI提供的大语言模型支持OpenAI API,可以通过openai SDK调用 | ||
| openai_client = p.openai() | ||
| res = openai_client.chat.completions.create( | ||
| model="default", | ||
| max_tokens=1024, | ||
| messages=[ | ||
| {"role": "system", "content": "You are a helpful assistant."}, | ||
| {"role": "user", "content": "What is the purpose of life?"} | ||
| ] | ||
| ) | ||
| print(res.choices[0].message.content) | ||
|
|
||
| ``` | ||
|
|
||
| For more details, please refer to the [PAI Python SDK Documentation](https://pai-sdk.oss-cn-shanghai.aliyuncs.com/pai/doc/latest/index.html). | ||
| - 微调预训练模型 | ||
|
|
||
| 通过PAI提供的微调脚本,提交一个模型微调任务 | ||
|
|
||
| ```python | ||
|
|
||
| from pai.model import ModelTrainingRecipe | ||
|
|
||
| training_recipe = ModelTrainingRecipe( | ||
| model_name="qwen2-0.5b-instruct", | ||
| model_provider="pai", | ||
| instance_type="ecs.gn6e-c12g1.3xlarge", | ||
| ) | ||
|
|
||
| training_recipe.train( | ||
| inputs={ | ||
| # 本地或是阿里云OSS上的数据路径(oss://<bucketname>/path/to/data) | ||
| "train": "<YourTrainingDataPath>" | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
| 通过访问PAI提供的示例仓库,可以了解更多使用示例:[pai-examples](https://github.com/aliyun/pai-examples/tree/master/pai-python-sdk) | ||
|
|
||
| ## 🤝 贡献代码 | ||
|
|
||
| ## Contributing 🤝 | ||
| 我们欢迎为PAI Python SDK贡献代码。请阅读 [CONTRIBUTING](./CONTRIBUTING.md) 文件了解如何为本项目贡献代码。 | ||
|
|
||
| Contributions to the PAI Python SDK are welcome. Please read our contribution guidelines in the [CONTRIBUTING](./CONTRIBUTING.md) file. | ||
| ## 📝 许可证 | ||
|
|
||
| ## License 📝 | ||
| PAI Python SDK是由阿里云开发,并根据Apache许可证(版本2.0)授权使用。 | ||
|
|
||
| PAI Python SDK is developed by Alibaba Cloud and licensed under the Apache License (Version 2.0). | ||
| ## 📬 联系方式 | ||
|
|
||
| ## Contact 📬 | ||
| 如需支持或咨询,请在GitHub仓库中提交issue,或通过钉钉群联系我们: | ||
|
|
||
| For support or inquiries, please open an issue on the GitHub repository. | ||
| <img src="./assets/dingtalk-group.png" alt="DingTalkGroup" width="500"/> |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 2 months ago
In general, the fix is to explicitly declare a restrictive
permissions:block for the workflow or each job, instead of relying on the potentially broad repository default. For a pure lint workflow that just checks out code and runs local tools, the minimal required permission iscontents: read.The best way to fix this without changing existing functionality is to add a top-level
permissions:block after theon:section in.github/workflows/lint.yaml, settingcontents: read. This will apply to bothcommon-lintanddoc-lintjobs, which do not need to write to the repository or otherwise modify GitHub resources. No changes to the individual jobs or steps are required, and no imports or external dependencies are involved because this is a YAML workflow definition.Concretely: in
.github/workflows/lint.yaml, insert:between the existing
on: [push]andconcurrency:keys.