Skip to content

Commit

Permalink
Update to ChargeDensityRester (#396)
Browse files Browse the repository at this point in the history
* Update ChargeDensityRester [...]

Ensure it follows examples set from other routes.

* Remove charge density patched methods

* Move `MPRester` to root level and remove unnecessary methods

* Try using Generics for type hints in `BaseRester`

* Remove `query_by_task_id`

* Add type hint

* Add type hints for all routes

* Remove all type hint stubs

* Remove unnecessary `type: ignore`

* Add type hints throughout and propagate `use_document_model` kwarg

* Change `query` to `_query_resource_data` to avoid confusion with `search` and old `MPRester.query`

Specifically, `_query_resource_data` only returns a single page of results which could be misleading. It's really an internal method.

* Allow same instance of `BaseRester` to be used in multiple contexts

* Make `use_document_model` and `monty_decode` instance attributes

* Add type hints

* Remove unimplemented method

* Fix client for POST documents

* Add tolerances from Emmet to `find_structure` + fix bug

* Use Emmet `TaskType`, add user_settings type hint, `NotImplementedError` for `notify_db_version`

* Import `UserSettingsRester`

* Change `user_settings` to `_user_settings`

* Update UserSettingsRester with appropriate metadata

* Ensure `tqdm` total document count respects paging

* Add `download_for_task_ids`

* Add only specific fields

* Add `_user_settings`

* Update for BaseRester changes, change for `task_id` from `calculation_id` for consistency

* Restore code from bad refactor

* Change to use attribute from document model

* Temporarily remove substrates, surfaces tests

FYI @munrojm, think these are superfluous, possibly pending adding the miller index info to the API endpoint

* Also comment out get_gb_data

* Remove `use_document_model`

* Use attributes for surface properties document

* Add check for sub-urls

* Add better check for suburl

* Clarify `find_structure` behavior + add `allow_multiple_results` kwarg

* Allow for multiple types of POST that may return a single document or list of documents

* Add missing type hint

* Try to bugs introduced when refactoring `use_document_model`

* Add new Charge Density methods

* Fix electronis structure tests

* Enable get_by_key for charge density endpoint

* Small test fixes

* Add chgcar client tests

* Linting and temp xfail

* mypy fixes

* More linting

* Fix start imports with flake8

* Clean up mprester test

Co-authored-by: Jason Munro <jmunro@lbl.gov>
  • Loading branch information
mkhorton and Jason Munro authored Oct 13, 2021
1 parent 8f810d8 commit abf3ffc
Show file tree
Hide file tree
Showing 64 changed files with 1,153 additions and 1,772 deletions.
3 changes: 1 addition & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@
collection_name="settings",
)


else:
materials_store = loadfn(materials_store_json)
formula_autocomplete_store = loadfn(formula_autocomplete_store_json)
Expand Down Expand Up @@ -525,7 +524,7 @@
# Consumers
from mp_api.routes._consumer.resources import settings_resource

resources.update({"user_settings": [settings_resource(consumer_settings_store)]})
resources.update({"_user_settings": [settings_resource(consumer_settings_store)]})

# === MAPI setup
from mp_api.core.documentation import description, tags_meta
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exclude = documentation.py
[flake8]
exclude = .git,__pycache__,docs_rst/conf.py,tests,__init__.py,documentation.py
# max-complexity = 10
extend-ignore = E741, F401, F403
extend-ignore = E741, F401, F403, F405
max-line-length = 120

[pydocstyle]
Expand Down
2 changes: 2 additions & 0 deletions src/mp_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import os
from monty.serialization import loadfn
from pkg_resources import get_distribution, DistributionNotFound
from mp_api.client import MPRester

try:
from setuptools_scm import get_version

__version__ = get_version(root="../../", relative_to=__file__)
except (ImportError, LookupError): # pragma: no cover
try:
Expand Down
Loading

0 comments on commit abf3ffc

Please sign in to comment.