diff --git a/.github/workflows/poetry-publish.yml b/.github/workflows/poetry-publish.yml new file mode 100644 index 00000000..263e590f --- /dev/null +++ b/.github/workflows/poetry-publish.yml @@ -0,0 +1,67 @@ +# Workflow following resources at: +# - https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-pypi +# - https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives +# Jobs are split to prevent unneccessary priviledge elevation through write permissions during building. + +name: Build and publish on Pypi + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + run-tests: + uses: ./.github/workflows/poetry-pytest.yml + + release-build: + name: Build python wheels + needs: + - run-tests + runs-on: ubuntu-latest + steps: + # https://github.com/actions/checkout + - uses: actions/checkout@v4 + - name: Set up Python + # https://github.com/actions/setup-python + uses: actions/setup-python@v5.1.1 + with: + python-version: "3.10" + + - name: Install Poetry + run: | + pip install poetry + + - name: Build source and wheel archives + run: poetry build + + - name: Upload distributions + # https://github.com/actions/upload-artifact + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + + pypi-publish: + name: Upload release to PyPI + needs: + - release-build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/modos + permissions: + id-token: write + # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Retrieve release distributions + # https://github.com/actions/download-artifact + uses: actions/download-artifact@v4.1.8 + with: + name: release-dists + path: dist/ + - name: Publish package distributions to PyPI + # https://github.com/pypa/gh-action-pypi-publish + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/poetry-pytest.yml b/.github/workflows/poetry-pytest.yml index fea061bb..27cab0e9 100644 --- a/.github/workflows/poetry-pytest.yml +++ b/.github/workflows/poetry-pytest.yml @@ -1,6 +1,6 @@ name: tests -on: [push] +on: [push, workflow_call] jobs: diff --git a/.github/workflows/poetry-test-publish.yml b/.github/workflows/poetry-test-publish.yml new file mode 100644 index 00000000..1833641e --- /dev/null +++ b/.github/workflows/poetry-test-publish.yml @@ -0,0 +1,67 @@ +# Workflow following resources at: +# - https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-pypi +# - https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives +# Jobs are split to prevent unneccessary priviledge elevation through write permissions during building. + +name: Build and publish on Pypi Test + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + run-tests: + uses: ./.github/workflows/poetry-pytest.yml + test-build: + name: Build python wheels + needs: + - run-tests + runs-on: ubuntu-latest + steps: + # https://github.com/actions/checkout + - uses: actions/checkout@v4 + - name: Set up Python + # https://github.com/actions/setup-python + uses: actions/setup-python@v5.1.1 + with: + python-version: "3.10" + + - name: Install Poetry + run: | + pip install poetry + + - name: Build source and wheel archives + run: poetry build + + - name: Upload distributions + # https://github.com/actions/upload-artifact + uses: actions/upload-artifact@v4 + with: + name: test-dists + path: dist/ + + pypi-test-publish: + name: Upload release to PyPI Test + needs: + - test-build + runs-on: ubuntu-latest + environment: + name: test-pypi + url: https://test.pypi.org/p/modos + permissions: + id-token: write + # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Retrieve release distributions + # https://github.com/actions/download-artifact + uses: actions/download-artifact@v4.1.8 + with: + name: test-dists + path: dist/ + - name: Publish package distributions to TestPyPI + # https://github.com/pypa/gh-action-pypi-publish + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/README.md b/README.md index fe84d91b..7b912f79 100644 --- a/README.md +++ b/README.md @@ -111,11 +111,11 @@ For advanced use cases, the object's metadata can be queried with SPARQL! >>> ex.query(""" ... SELECT ?assay ?sample ?file ... WHERE { -... [] schema1:name ?assay ; +... [] schema:name ?assay ; ... modos:has_data [ ... modos:data_path ?file ; ... modos:has_sample [ -... schema1:name ?sample ; +... schema:name ?sample ; ... modos:sex ?sex . ... ] ... ] . diff --git a/docs/conf.py b/docs/conf.py index 732aba5d..dd5160ce 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ project = "modos-api" copyright = "2024, sdsc-ordes" author = "sdsc-ordes" -release = "0.2.0" +release = "0.2.1" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/tutorials/modo_access.md b/docs/tutorials/modo_access.md index 35045d0b..fd205525 100644 --- a/docs/tutorials/modo_access.md +++ b/docs/tutorials/modo_access.md @@ -120,12 +120,12 @@ modos publish --base-uri "http://demo-data" "data/ex" # @prefix EDAM: . # @prefix NCIT: . # @prefix modos: . -# @prefix schema1: . +# @prefix schema: . # @prefix xsd: . # # a modos:Assay ; -# schema1:description "Dummy assay for tests." ; -# schema1:name "Assay 1" ; +# schema:description "Dummy assay for tests." ; +# schema:name "Assay 1" ; # modos:has_data ; # modos:has_sample ; # modos:omics_type NCIT:C84343 . diff --git a/modos/rdf.py b/modos/rdf.py index 97001552..570c6c58 100644 --- a/modos/rdf.py +++ b/modos/rdf.py @@ -16,7 +16,7 @@ def attrs_to_graph(meta: dict, uri_prefix: str) -> rdflib.Graph: """Convert a attribute dictionary to an RDF graph of metadata.""" kg = rdflib.Graph() for prefix in load_prefixmap().values(): - kg.bind(prefix.prefix_prefix, prefix.prefix_reference) + kg.bind(prefix.prefix_prefix, prefix.prefix_reference, replace=True) # Assuming the dict is flat, i.e. all subjects are top level for subject, attrs in meta.items(): diff --git a/pyproject.toml b/pyproject.toml index 3535665c..62d1817c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "modos" -version = "0.2.0" +version = "0.2.1" description = "SMOC Multi-Omics Digital Object System API" authors = ["SDSC-ORDES"] license = "Apache-2.0"