diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..53e6075 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ml-evs diff --git a/.github/utils/release_tag_msg.txt b/.github/utils/release_tag_msg.txt new file mode 100644 index 0000000..39400fa --- /dev/null +++ b/.github/utils/release_tag_msg.txt @@ -0,0 +1,3 @@ +TAG_NAME + +The full release changelog can be seen in the [online docs](https://datalab-python-api.readthedocs.io/latest/changelog). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf1cc82..d6dd463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.9" - name: Install dependencies run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f5c4b58 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: Publish and release on PyPI + +on: + release: + types: + - published + +env: + PUBLISH_UPDATE_BRANCH: main + GIT_USER_NAME: datalab developers + GIT_USER_EMAIL: "datalab@odbx.science" + +jobs: + + release: + name: Release new version + runs-on: ubuntu-latest + permissions: + id-token: write + if: github.repository == 'datalab-org/datalab-api' && startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + ref: ${{ env.PUBLISH_UPDATE_BRANCH }} + + - name: Update changelog + uses: CharMixer/auto-changelog-action@v1 + with: + token: ${{ secrets.ORG_RELEASE_PAT }} + release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }} + exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,skip_changelog" + + - name: Configure git and commit CHANGELOG + run: | + git config --global user.email "${GIT_USER_EMAIL}" + git config --global user.name "${GIT_USER_NAME}" + git commit CHANGELOG.md -m "Release ${GITHUB_REF#refs/tags/}" + + - name: Move tag to new HEAD + run: | + TAG_MSG=.github/utils/release_tag_msg.txt + sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|" "${TAG_MSG}" + git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/} + + - name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}' + uses: CasperWA/push-protected@v2 + with: + token: ${{ secrets.ORG_RELEASE_PAT }} + branch: ${{ env.PUBLISH_UPDATE_BRANCH }} + unprotect_reviews: true + sleep: 15 + force: true + tags: true + + - name: Create release-specific changelog + uses: CharMixer/auto-changelog-action@v1 + with: + token: ${{ secrets.ORG_RELEASE_PAT }} + release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }} + since_tag: "${{ env.PREVIOUS_VERSION }}" + output: "release_changelog.md" + exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,CI,skip_changelog" + + - name: Append changelog to release body + run: | + gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md + cat release_changelog.md >> release_body.md + gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md' + env: + GITHUB_TOKEN: ${{ secrets.ORG_RELEASE_PAT }} + + publish: + name: "Publish on PyPI" + runs-on: ubuntu-latest + permissions: + id-token: write + if: github.repository == 'datalab-org/datalab-api' && startsWith(github.ref, 'refs/tags/v') + needs: [release] + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + ref: ${{ env.PUBLISH_UPDATE_BRANCH }} + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Build source distribution + run: | + pip install -U build + python -m build + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index cbc22fc..ac68439 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ #
datalab Python API
- +
-A simple Python API that can interact with [datalab](https://github.com/the-grey-group/datalab) instances. +A simple Python API that can interact with [*datalab*](https://github.com/the-grey-group/datalab) instances. The idea here is to provide a set of utility functions and models for manipulating samples, cells, inventory, files, users and metadata associated with *datalab* entries in an automated way. @@ -19,26 +19,28 @@ If you have any suggestions or feedback, please post it there. ## Installation -The API can be used by installing this repository with `pip`, ideally in a fresh Python environment (created using e.g., conda, virtualenv or other related tools -- if you're not sure about this, ask). +The API can be used by installing this repository with `pip`, ideally in a fresh Python 3.9+ environment (created using e.g., conda, virtualenv or other related tools -- if you're not sure about this, ask). + +Either from PyPI, for the latest released version: ```shell -git clone git@github.com:datalab-org/datalab-python-api -cd datalab-python-api -pip install . +pip install datalab-api ``` -or via (may require public release first): +or for the latest development version from GitHub: ```shell -pip install git+https://github.com/datalab-org/datalab-python-api +git clone git@github.com:datalab-org/datalab-api +cd datalab-api +pip install . ``` ## Usage Example usage as a Jupyter notebook can be found in the `examples` directory or -in the [online documentation](https://datalab-python-api.readthedocs.io/), as +in the [online documentation](https://datalab-api.readthedocs.io/), as well as the full [API -documentation](https://datalab-python-api.readthedocs.io/en/latest/reference/). +documentation](https://datalab-api.readthedocs.io/en/latest/reference/). ### Authentication diff --git a/docs/.pages b/docs/.pages index c0313a4..f82e865 100644 --- a/docs/.pages +++ b/docs/.pages @@ -1,3 +1,5 @@ nav: - index.md - reference.md + - "Example notebook": examples/client_example.ipynb + - changelog.md diff --git a/docs/changelog.md b/docs/changelog.md new file mode 120000 index 0000000..04c99a5 --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1 @@ +../CHANGELOG.md \ No newline at end of file diff --git a/examples/client_example.ipynb b/docs/examples/client_example.ipynb similarity index 100% rename from examples/client_example.ipynb rename to docs/examples/client_example.ipynb diff --git a/mkdocs.yml b/mkdocs.yml index b970600..5f0a52a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ -site_name: datalab-python-api +site_name: datalab-api site_description: Documentation for the datalab Python API -site_url: https://the-datalab-python-api.readthedocs.io +site_url: https://datalab-api.readthedocs.io theme: name: material @@ -32,8 +32,8 @@ theme: features: - content.code.copy -repo_name: datalab-org/datalab-python-api -repo_url: https://github.com/datalab-org/datalab-python-api +repo_name: datalab-org/datalab-api +repo_url: https://github.com/datalab-org/datalab-api docs_dir: "./docs" @@ -95,6 +95,10 @@ plugins: - autorefs - search: lang: en + - mkdocs-jupyter: + execute: false + allow_errors: false + include_requirejs: true watch: - src diff --git a/pyproject.toml b/pyproject.toml index 53bc8f6..db6ec01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,8 @@ docs = [ "mkdocs", "mkdocs-material", "mkdocstrings[python-legacy]", - "mkdocs-awesome-pages-plugin" + "mkdocs-awesome-pages-plugin", + "mkdocs-jupyter", ] cli = [