Skip to content

Commit

Permalink
feature: datashare-python CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemDoum committed Dec 23, 2024
1 parent 6f1713c commit 61804a4
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 27 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
tag: ${{ github.ref_name }}

publish-to-dockerhub:
if: false
needs: [ create-release ]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

publish-pypi:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -58,16 +59,41 @@ jobs:
url: https://pypi.org/p/datashare-python
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build dependencies
run: pip install build
- name: Publish
uses: pypa/[email protected]
- name: Build the project
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-pypi:
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/datashare-python
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
cancel-in-progress: false
Binary file added docs/assets/clone_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions docs/get-started/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ $ ./datashare-python build datashare-python

## Publish to [Docker Hub](https://hub.docker.com/)

You can also fork the template repository and use the CI to build and publish the worker image to [Docker Hub](https://hub.docker.com/).
You can also clone the template repository:

To publish, make sure to set the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` ([see documentation](https://docs.docker.com/security/for-developers/access-tokens/))
and then just create a tag to trigger the build.
<p align="center">
<img alt="clone_template.png" src="../../assets/clone_template.png"/>
</p>

and use the CI to build and publish the worker image to [Docker Hub](https://hub.docker.com/).

To publish:

- make sure to set the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` ([see documentation](https://docs.docker.com/security/for-developers/access-tokens/))
- remove or comment the `:::yml if: false` line in the `publish-to-dockerhub` job of the `.github/pyblish.yml` workflow
- then commit, create a tag and push it to trigger the build
9 changes: 3 additions & 6 deletions docs/get-started/implement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ The [datashare-python](https://github.com/ICIJ/datashare-python) repository is m
## Clone the template repository

Start by cloning the [template repository](https://github.com/ICIJ/datashare-python):

<!-- termynal -->
```console
$ git clone [email protected]:ICIJ/datashare-python.git
---> 100%
```
<p align="center">
<img alt="clone_template.png" src="../../assets/clone_template.png"/>
</p>

## Explore the codebase

Expand Down
14 changes: 6 additions & 8 deletions docs/get-started/implement/worker-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ Make sure you've followed the [basic worker example](worker-basic.md) to underst

Start over and clone the [template repository](https://github.com/ICIJ/datashare-python) once again:

<!-- termynal -->
```console
$ git clone [email protected]:ICIJ/datashare-python.git
---> 100%
```
<p align="center">
<img alt="clone_template.png" src="../../../assets/clone_template.png"/>
</p>

## Install extra dependencies

Expand Down Expand Up @@ -205,11 +203,11 @@ We can then run the tests after starting test services using the `datashare-pyth
<!-- termynal -->
```console
$ ./datashare-python up -d postgresql redis elasticsearch rabbitmq datashare_web
$ uv run --frozen pytest datashare_python/tests/tasks/test_vectorize.py
$ uv run --frozen pytest tests/tasks/test_vectorize.py
===== test session starts =====
collected 3 items

datashare_python/tests/tasks/test_vectorize.py ... [100%]
tests/tasks/test_vectorize.py ... [100%]

====== 3 passed in 6.87s ======
....
Expand All @@ -224,5 +222,5 @@ Rather than copy-pasting the above code blocks, you can replace/update your code
- [`datashare_python/tasks/vectorize.py`](https://github.com/ICIJ/datashare-python/blob/main/docs/src/vectorize.py)
- [`datashare_python/tasks/dependencies`](https://github.com/ICIJ/datashare-python/blob/main/docs/src/vector_db_dependencies.py)
- [`datashare_python/app.py`](https://github.com/ICIJ/datashare-python/blob/main/docs/src/vectorize_app.py)
- [`datashare_python/tests/tasks/test_vectorize.py](https://github.com/ICIJ/datashare-python/blob/main/docs/src/test_vectorize.py)
- [`tests/tasks/test_vectorize.py](https://github.com/ICIJ/datashare-python/blob/main/docs/src/test_vectorize.py)

15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
name = "datashare-python"
version = "0.1.0"
description = "Implement Datashare task in Python"
authors = [{ name = "Clément Doumouro", email = "[email protected]" }]
authors = [
{ name = "Clément Doumouro", email = "[email protected]" },
{ name = "Clément Doumouro", email = "[email protected]" }
]
readme = "README.md"
requires-python = "~=3.11"
dependencies = [
Expand All @@ -15,12 +18,13 @@ dependencies = [
"transformers~=4.46.3",
"pycountry>=24.6.1",
"sentencepiece>=0.2.0",
"termynal~=0.12.2",
"typer>=0.13.1",
"alive-progress>=3.2.0",
]
[tool.setuptools]
py-modules = []

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.uv]
package = true
Expand Down Expand Up @@ -51,7 +55,8 @@ dev = [
"nest-asyncio>=1.6.0",
]
doc = [
"mkdocs-material~=9.5.48"
"mkdocs-material~=9.5.48",
"termynal~=0.12.2",
]

[tool.uv.pip]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61804a4

Please sign in to comment.