diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e11d09a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: Continuous integration + +on: + pull_request: + push: + branches: + - main + - "dev*" + +jobs: + test: + permissions: + contents: read + id-token: write + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ["3.10", 3.11, 3.12] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + + - name: Update pip and install the package + run: | + python -m pip install --upgrade pip + python -m pip install ".[test]" + + - name: Run tests + run: | + python -m pytest tests + + - name: Install and run linters + if: | + matrix.python-version == 3.11 + run: | + python -m pip install ".[dev]" + python -m ruff check . + python -m ruff format --check . + + # - name: Generate Report + # run: | + # coverage run -m pytest + # coverage xml + + # - name: Upload Coverage to Codecov + # uses: codecov/codecov-action@v3 + # with: + # file: ./coverage.xml + # flags: unittests + # verbose: true + # token: ${{secrets.CODECOV_TOKEN}} diff --git a/README.md b/README.md index e66d1f5..feb506d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,25 @@ This is the open-source code repository for the internal ParliAI project, allowing other developers to replicate non-sensitive features of the project and to encourage future collaboration and development in this space. Please do contact us at [datasciencecampus@ons.gov.uk](datasciencecampus@ons.gov.uk) to discuss this or any of our other projects. ## Installation -Details to follow... + +You are strongly recommended to install resources into a virtual environment. Project setup can be achieved as follows: + +``` bash +$ git clone https://github.com/datasciencecampus/parliai-public.git +$ cd parliai-public +$ python -m venv venv +$ source venv/bin/activate +$ python -m pip install --upgrade pip +$ python -m pip install . +``` + +> \[!NOTE\] If you intend on doing any development work, please install the package as editable (`-e`) and with the `dev` optional dependencies: +> +> ``` bash +> $ python -m pip install -e ".[dev]" +> ``` +> +> Moreover, once you have installed the package, please install the pre-commit hooks. These hooks help us to ensure repository security and a consistent code style. ### Pre-commit actions This repository contains a configuration of pre-commit hooks. These are language agnostic and focussed on repository security (such as detection of passwords and API keys). If approaching this project as a developer, you are encouraged to install and enable `pre-commits` by running the following in your shell: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..28f4fcf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,75 @@ +[project] +name = "parliai_public" +description = "Using LLMs to capture coverage of organisations, people or themes in UK political debate." +authors = [ + { name = "Data Science Campus", email = "datasciencecampus@ons.gov.uk" } +] +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.10" +dynamic = ["version"] +dependencies = [ + "bs4>=0.0.1", + "email-validator>=2.1.0.post1", + "feedparser>=6.0.11", + "google-cloud-secret-manager>=2.19.0", + "langchain-community>=0.0.13", + "langchain-google-vertexai>=0.0.1", + "langchain>=0.1.0", + "notifications-python-client>=9.0.0", + "python-dotenv>=1.0.1", + "toml>=0.10.2", + "tqdm>=4.66.1", +] + +[build-system] +requires = ["setuptools>=69"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.dynamic] +version = { attr = "parliai_public.__version__" } + +[tool.setuptools.package-data] +parliai_public = ["_config/*.toml"] + +[project.optional-dependencies] +test = [ + "hypothesis>=6.98.6", + "pytest>=8.0.0", + "pytest-cov>=4.1.0", + "pytest-randomly>=3.15.0", + "python-dateutil>=2.9.0", +] +dev = [ + "pre-commit==3.3.3", + "ruff==0.3.0", + "parliai_public[test]" +] + +# `coverage` configurations +[tool.coverage.run] +source = [ + "./src" +] +omit = ["**/__init__.py"] + +[tool.coverage.report] +exclude_lines = [ + "if __name__ == .__main__.:" +] + +[tool.ruff] +line-length = 79 + +[tool.ruff.lint] +extend-select = ["D", "I", "W"] +ignore = ["D105", "D107", "D202"] + +[tool.ruff.lint.isort] +known-first-party = ["parliai_public"] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" diff --git a/src/parliai_public/__init__.py b/src/parliai_public/__init__.py new file mode 100644 index 0000000..0e1ac55 --- /dev/null +++ b/src/parliai_public/__init__.py @@ -0,0 +1,7 @@ +"""Using LLMs to capture coverage of organisations, people or themes in UK political debate.""" + +__version__ = "0.0.1" + +__all__ = [ + "__version__", +] diff --git a/src/parliai_public/_config/.gitkeep b/src/parliai_public/_config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..6909a11 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Unit tests for the entire package.""" diff --git a/tests/test_placeholder.py b/tests/test_placeholder.py new file mode 100644 index 0000000..28921f2 --- /dev/null +++ b/tests/test_placeholder.py @@ -0,0 +1,7 @@ +"""Example test to facilitate CI operation.""" + + +def test_temp(): + """Test message.""" + msg = "I am a test" + assert msg == "I am a test"