Skip to content

Commit

Permalink
Add poetry and update CI (#108)
Browse files Browse the repository at this point in the history
* Install packages with poetry

* Add mongomock dev dependency

* Create initial GitHub Actions workflow

* Fix parser grammar weights

* Update pymongo insertion function

* Add poetry entrypoint for CLI

* Update pymongo update function

* Move contents of setup to pyproject

* Fix unit tests

* Remove travis config

* Update dependencies

* Update gitignore

---------

Co-authored-by: ElliottKasoar <[email protected]>
  • Loading branch information
ElliottKasoar and ElliottKasoar authored Jun 11, 2024
1 parent 8157bbd commit d00f0b8
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 68 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci

on: [push, pull_request]

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: pipx install poetry

- name: Install python dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install --with dev
- name: Run unit tests
run: |
poetry run python -m unittest -v tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
_build/
develop-eggs/
dist/
downloads/
Expand All @@ -31,6 +32,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
*.lock
MANIFEST

# PyInstaller
Expand Down
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions abcd/backends/atoms_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def _id(self):

def save(self):
if not self._id:
self._collection.insert(self)
self._collection.insert_one(self)
else:
self._collection.update(
{"_id": ObjectId(self._id)}, self)
new_values = { "$set": self }
self._collection.update_one(
{"_id": ObjectId(self._id)}, new_values)

def remove(self):
if self._id:
Expand Down
2 changes: 1 addition & 1 deletion abcd/parsers/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
key: NAME
key_value: NAME "=" value
NAME.2: ("_"|LETTER|DIGIT) ("_"|"-"|LETTER|DIGIT)*
NAME: ("_"|LETTER|DIGIT) ("_"|"-"|LETTER|DIGIT)*
?value:
| ESCAPED_STRING -> string
Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[tool.poetry]
name = "abcd"
version = "0.6.0"
description = "This is a package which helps to store and share atomistic data."
authors = ["Adam Fekete", "Gabor Csanyi"]
keywords=["ase", "database", "mongo", "flask", "opensearch"]
readme = "README.md"
homepage = "https://libatoms.github.io/abcd/"
repository = "https://github.com/libatoms/abcd"
documentation = "https://libatoms.github.io/abcd/"

[tool.poetry.dependencies]
python = "^3.9"
notebook = "^7.2"
numpy = "^1.26"
tqdm = "^4.66"
pymongo = "^4.7.3"
matplotlib = "^3.9"
ase = "^3.23"
lark = "^1.1.9"

[tool.poetry.group.dev.dependencies]
mongomock = "^4.1.2"

[tool.poetry.extras]
tests = ["mongomock"]
mongo = ["pymongo"]
http = ["requests"]
server-api = ["flask"]
server-app = ["flask", "Flask-Nav", "Flask-MongoEngine", "gunicorn", "flask-paginate"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins."console_scripts"]
"abcd" = "abcd.frontends.commandline:main"
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

28 changes: 0 additions & 28 deletions setup.py

This file was deleted.

0 comments on commit d00f0b8

Please sign in to comment.