Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrenault committed Mar 8, 2024
1 parent da249bf commit 147173e
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 7 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pre_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish to Test PyPI

on:
push:
tags:
- "v*.*.*"

env: # environment variables (available in any part of the action)
PYTHON_VERSION: 3.11

jobs:
pre-publish:
name: Publish to Test PyPI
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Config Repository
run: poetry config repositories.testpypi https://test.pypi.org/legacy/

- name: Login to PyPI Test
run: poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_API_KEY }}

- name: Publish package
run: poetry publish --build -r testpypi
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

env: # environment variables (available in any part of the action)
PYTHON_VERSION: 3.11

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code.
- name: Install dependencies
run: poetry install --no-interaction --no-root --with dev

- name: Test with pytest
run: poetry run pytest
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

env: # environment variables (available in any part of the action)
PYTHON_VERSION: 3.11

jobs:
lint-test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- name: Check Poetry File
run: poetry check

- name: Check lock file
run: poetry lock --check

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code.
- name: Install dependencies
run: poetry install --no-interaction --no-root --with dev --with stubs

- name: Test with pytest
run: poetry run pytest

- name: Run black
run: poetry run black --check --config ./pyproject.toml .

- name: Run mypy
run: poetry run mypy

- name: Run ruff
run: poetry run ruff check
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CPREx - Chemical Properties Relation Extraction

[![License](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)
![python_version](https://img.shields.io/badge/Python-%3E=3.10-blue)
![python_version](https://img.shields.io/badge/Python-%3E=3.11-blue)

CPREx is an end to end tool for Named Entity Recognition (NER) and Relation Extraction (RE) specifically designed for chemical compounds and their properties. The goal of the tool is to identify, extract and link chemical compounds and their properties from scientific literature. For ease of use, CPREx provides a custom [spacy](https://spacy.io/) pipeline to perform NER and RE.

Expand Down Expand Up @@ -69,9 +69,7 @@ Any modifications you make to the cprex codebase will be immediatly reflected th

#### Installing and running grobid

CPREx depends on [GROBID](https://github.com/kermitt2/grobid) and its extension [grobid-quantities](https://github.com/lfoppiano/grobid-quantities) for parsing PDF documents and extracting quantities from their text.

For convenience, CPREx provides a command line interface (CLI) to install grobid and start a grobid server.
CPREx depends on [GROBID](https://github.com/kermitt2/grobid) and its extension [grobid-quantities](https://github.com/lfoppiano/grobid-quantities) for parsing PDF documents and extracting quantities from their text. For convenience, CPREx provides a command line interface (CLI) to install grobid and start a grobid server.

Run

Expand All @@ -91,10 +89,10 @@ to start a grobid server and enable parsing of PDF documents from CPREx.

#### Installing NER et REL models

To perform Named Entity Recognition of chemical compounds and Relation Extraction, CPREx requires some pretrained models. These models can be installed by running
To perform Named Entity Recognition (NER) of chemical compounds and Relation Extraction (RE), CPREx requires some pretrained models. These models can be installed by running

```console
cprex install-models
```

This will install a PubmedBert model finetuned on the NLM-CHEM corpus for extraction of chemical named entities. This model was finetuned by the [BioCreative VII track](https://biocreative.bioinformatics.udel.edu/tasks/biocreative-vii/track-2/).
This will install a [PubmedBert model](https://ftp.ncbi.nlm.nih.gov/pub/lu/BC7-NLM-Chem-track/) finetuned on the NLM-CHEM corpus for extraction of chemical named entities. This model was finetuned by the [BioCreative VII track](https://biocreative.bioinformatics.udel.edu/tasks/biocreative-vii/track-2/).
48 changes: 47 additions & 1 deletion poetry.lock

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

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ version = "0.2.0"
description = "Chemical Properties Relation Extraction"
authors = ["Jonas Renault <[email protected]>", "Lucie Chasseur <[email protected]>"]
readme = "README.md"
license = "MIT"
homepage = "https://github.com/jonasrenault/cprex#readme"
repository = "https://github.com/jonasrenault/cprex"
keywords = ["pubchem", "crawler", "chemistry", "machine-learning", "relation-extraction", "named-entity-extraction", "deep-learning", "transformers", "spacy", "scientific-articles"]

[tool.poetry.dependencies]
python = "^3.11"
Expand All @@ -32,6 +34,7 @@ black = "^24.2.0"
mypy = "^1.8.0"
bandit = "^1.7.7"
jupyterlab = "^4.1.3"
pytest = "^8.0.2"


[tool.poetry.group.stubs]
Expand Down

0 comments on commit 147173e

Please sign in to comment.