Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v5

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v4
9 changes: 5 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ jobs:
- name: Install dependencies
run: |
python${{ matrix.python-version }} -m pip install --upgrade "pip<25.3" build pip-tools pre-commit
python${{ matrix.python-version }} -m piptools compile --extra dev -o requirements.txt mpcontribs-client/setup.py mpcontribs-api/setup.py
python${{ matrix.python-version }} -m piptools compile --extra dev -o requirements.txt mpcontribs-client/pyproject.toml mpcontribs-api/pyproject.toml
python${{ matrix.python-version }} -m pip install -r requirements.txt
cd mpcontribs-api && python${{ matrix.python-version }} -m pip install --no-deps .
cd mpcontribs-api
python${{ matrix.python-version }} -m pip install --no-deps .
- name: Set SSL_CERT_FILE (Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
Expand All @@ -50,7 +51,6 @@ jobs:

- name: Run pre-commit
run: |
python${{ matrix.python-version }} -m pip install pre-commit
pre-commit install
pre-commit run --all-files

Expand All @@ -61,9 +61,10 @@ jobs:
shell: bash
run: |
cd mpcontribs-client
python${{ matrix.python-version }} -m pip install --no-deps .
python${{ matrix.python-version }} -m flake8 --max-line-length 100
python${{ matrix.python-version }} -m pycodestyle --max-line-length 100 .
python${{ matrix.python-version }} -m pytest -v -s --cov=mpcontribs/client --cov-report=term-missing --cov-report=xml --ignore=bravado
python${{ matrix.python-version }} -m pytest -n auto -v -s --cov=mpcontribs/client --cov-report=term-missing --cov-report=xml --ignore=bravado
python${{ matrix.python-version }} -m build --outdir ../dist

- name: Install lux and test with pytest
Expand Down
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ repos:
files: cloudformation/.*\.(json|yml|yaml)$
args: ["--ignore-checks=E3030,E3001,E3002,E3012"]

#- repo: https://gitlab.com/pycqa/flake8
# rev: 3.7.9
# hooks:
# - id: flake8
# args: [--max-line-length=99]

- repo: https://github.com/psf/black
rev: 25.9.0
hooks:
Expand All @@ -47,3 +41,8 @@ repos:
- --drop-empty-cells
- --strip-init-cells
- --extra-keys=metadata.kernelspec

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
hooks:
- id: pyupgrade
2 changes: 1 addition & 1 deletion mpcontribs-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends gcc git g++ lib
ENV PIP_FLAGS "--no-cache-dir --compile"
COPY requirements/deployment.txt ./requirements.txt
RUN pip install $PIP_FLAGS -r requirements.txt
COPY setup.py .
COPY pyproject.toml .
COPY mpcontribs mpcontribs
RUN pip install $PIP_FLAGS --no-deps .
#ENV SETUPTOOLS_SCM_PRETEND_VERSION 0.0.0
Expand Down
6 changes: 6 additions & 0 deletions mpcontribs-api/mpcontribs/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from email.message import EmailMessage
from importlib import import_module
from importlib.metadata import version
from websocket import create_connection
from flask import Flask, current_app, request, jsonify
from flask_marshmallow import Marshmallow
Expand All @@ -26,6 +27,11 @@
from notebook.gateway.managers import GatewayClient
from requests.exceptions import ConnectionError, Timeout

try:
__version__ = version("mpcontribs-api")
except Exception:
# package is not installed
pass

delimiter, max_depth = ".", 7 # = MAX_NESTING + 2 from client
invalidChars = set(punctuation.replace("*", "").replace("|", "") + whitespace)
Expand Down
11 changes: 2 additions & 9 deletions mpcontribs-api/mpcontribs/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"""configuration module for MPContribs Flask API"""

import os
import datetime
import json
import gzip

from semantic_version import Version
from mpcontribs.api import __version__

formulae_path = os.path.join(
os.path.dirname(__file__), "contributions", "formulae.json.gz"
Expand All @@ -15,12 +14,6 @@
with gzip.open(formulae_path) as f:
FORMULAE = json.load(f)

now = datetime.datetime.now()
VERSION = str(Version(
major=now.year, minor=now.month, patch=now.day,
prerelease=(str(now.hour), str(now.minute))
))

JSON_ADD_STATUS = False
SECRET_KEY = "super-secret" # TODO in local prod config

Expand Down Expand Up @@ -65,7 +58,7 @@
"title": "MPContribs API",
"description": "Operations to contribute, update and retrieve materials data on Materials Project",
"termsOfService": "https://materialsproject.org/terms",
"version": VERSION,
"version": __version__,
"contact": {
"name": "MPContribs",
"email": "[email protected]",
Expand Down
103 changes: 103 additions & 0 deletions mpcontribs-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[build-system]
requires = ["setuptools>=80.0.0","setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
root = ".."
relative_to = "__file__"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["."]
exclude = ["scripts","supervisord"]
include = ["mpcontribs.api"]

[project]
name = "mpcontribs-api"
dynamic = ["version"]
requires-python = ">=3.11"
description="API for community-contributed Materials Project data"
license = {text = "MIT"}
authors = [
{name = "Patrick Huck", email = "[email protected]"},
{name = "The Materials Project", email="[email protected]"},
]
dependencies = [
"numpy",
"apispec<6",
"asn1crypto",
"blinker",
"boltons",
"css-html-js-minify",
"dateparser",
"ddtrace",
"dnspython",
"filetype",
"flasgger-tschaume>=0.9.7",
"flask-compress",
"flask-marshmallow",
"flask-mongorest-mpcontribs>=3.2.1",
"Flask-RQ2",
"gunicorn[gevent]",
"jinja2",
"json2html",
"marshmallow<4",
"more-itertools",
"nbformat",
"notebook<7",
"pint>=0.24",
"psycopg2-binary",
"pymatgen",
"pyopenssl",
"python-snappy",
"rq<=2.3.2", # see https://github.com/rq/Flask-RQ2/issues/620
"supervisor",
"setproctitle",
"uncertainties",
"websocket_client",
"zstandard",
]

[project.urls]
Homepage = "https://github.com/materialsproject/MPContribs"
Documentation = "https://docs.materialsproject.org/services/mpcontribs"

[project.optional-dependencies]
dev = [
"flake8",
"pytest",
"pytest-flake8",
"pytest-pycodestyle",
"pytest-xdist",
]
all = [
"mpcontribs-api[dev]"
]

[tool.pytest]
markers = [
"base: basic resource testing",
"extra: all extra views",
]

[tool.pycodestyle]
count = true
ignore = ["E121","E123","E126","E133","E226","E241","E242","E704","W503","W504","W505","E741","W605"]
max-line-length = 120
statistics = true
exclude = ["flasgger","flask-mongorest"]

[tool.flake8]
exclude = [".git","__pycache__","tests","flasgger","flask-mongorest"]
extend-ignore = ["E741",]
max-line-length = 120

[tool.pydocstyle]
ignore = ["D105","D2","D4"]

[tool.mypy]
ignore_missing_imports = true
namespace_packages = true
python_version = 3.11
25 changes: 0 additions & 25 deletions mpcontribs-api/setup.cfg

This file was deleted.

52 changes: 0 additions & 52 deletions mpcontribs-api/setup.py

This file was deleted.

Loading