mp-api 0.46.5__tar.gz → 0.47.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mp_api-0.47.0/PKG-INFO +63 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/_test_utils.py +4 -4
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/__init__.py +8 -3
- mp_api-0.47.0/mp_api/client/contribs/_logger.py +49 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/_types.py +4 -1
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/client.py +192 -165
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/settings.py +5 -1
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/utils.py +5 -23
- mp_api-0.47.0/mp_api/client/core/_display.py +1020 -0
- mp_api-0.47.0/mp_api/client/core/_entries.py +251 -0
- mp_api-0.47.0/mp_api/client/core/_external.py +352 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/_oxygen_evolution.py +2 -4
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/client.py +813 -388
- mp_api-0.47.0/mp_api/client/core/delta.py +433 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/exceptions.py +14 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/schemas.py +67 -16
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/settings.py +20 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/utils.py +178 -30
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/mprester.py +404 -174
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/_server.py +2 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/absorption.py +7 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/alloys.py +8 -3
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/bonds.py +12 -7
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/chemenv.py +19 -14
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/dielectric.py +11 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/doi.py +2 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/elasticity.py +15 -10
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/electrodes.py +26 -23
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/electronic_structure.py +30 -27
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/eos.py +7 -8
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/grain_boundaries.py +7 -8
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/magnetism.py +12 -7
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/materials.py +19 -14
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/oxidation_states.py +10 -5
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/phonon.py +7 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/piezo.py +8 -3
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/provenance.py +7 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/robocrys.py +11 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/similarity.py +2 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/substrates.py +5 -5
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/summary.py +64 -69
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/surface_properties.py +6 -7
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/synthesis.py +25 -15
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/tasks.py +8 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/thermo.py +53 -28
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/xas.py +8 -10
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/molecules/jcesr.py +9 -12
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/molecules/summary.py +6 -6
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/_schemas.py +1 -1
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/server.py +4 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/utils.py +2 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/pyproject.toml +31 -21
- mp_api-0.47.0/tests/client/contribs/test_side_effects.py +192 -0
- mp_api-0.47.0/tests/client/core/test_client_progress.py +179 -0
- mp_api-0.47.0/tests/client/core/test_delta.py +517 -0
- mp_api-0.47.0/tests/client/core/test_delta_versions.py +949 -0
- mp_api-0.47.0/tests/client/core/test_display.py +335 -0
- mp_api-0.47.0/tests/client/core/test_external.py +675 -0
- mp_api-0.47.0/tests/client/core/test_ids.py +192 -0
- mp_api-0.47.0/tests/client/core/test_quiet.py +353 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/core/test_schemas.py +43 -11
- mp_api-0.47.0/tests/client/core/test_session_headers.py +81 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/core/test_utils.py +3 -1
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_electrodes.py +16 -13
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_eos.py +2 -2
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_summary.py +26 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/molecules/test_jcesr.py +14 -7
- mp_api-0.47.0/tests/client/molecules/test_molecules.py +21 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/test_client.py +1 -1
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/test_core_client.py +1 -1
- mp_api-0.47.0/tests/client/test_entry_progress.py +433 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/test_mprester.py +256 -157
- mp_api-0.47.0/tests/conftest.py +23 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/mcp/test_utils.py +2 -2
- mp_api-0.46.5/.coveragerc +0 -7
- mp_api-0.46.5/.github/workflows/lint.yml +0 -30
- mp_api-0.46.5/.github/workflows/release.yml +0 -66
- mp_api-0.46.5/.github/workflows/testing.yml +0 -60
- mp_api-0.46.5/.github/workflows/upgrade_dependencies.yml +0 -89
- mp_api-0.46.5/.pre-commit-config.yaml +0 -42
- mp_api-0.46.5/CODE_OF_CONDUCT.md +0 -48
- mp_api-0.46.5/PKG-INFO +0 -71
- mp_api-0.46.5/README.md +0 -7
- mp_api-0.46.5/dev/generate_mcp_tools.py +0 -165
- mp_api-0.46.5/dev/inspect_mcp.sh +0 -12
- mp_api-0.46.5/docs/Makefile +0 -20
- mp_api-0.46.5/docs/_templates/custom-class-template.rst +0 -32
- mp_api-0.46.5/docs/_templates/custom-module-template.rst +0 -66
- mp_api-0.46.5/docs/conf.py +0 -122
- mp_api-0.46.5/docs/index.rst +0 -33
- mp_api-0.46.5/docs/make.bat +0 -35
- mp_api-0.46.5/docs/modules.rst +0 -14
- mp_api-0.46.5/mp_api/client/contribs/_logger.py +0 -97
- mp_api-0.46.5/mp_api.egg-info/PKG-INFO +0 -71
- mp_api-0.46.5/mp_api.egg-info/SOURCES.txt +0 -146
- mp_api-0.46.5/mp_api.egg-info/dependency_links.txt +0 -1
- mp_api-0.46.5/mp_api.egg-info/entry_points.txt +0 -2
- mp_api-0.46.5/mp_api.egg-info/requires.txt +0 -53
- mp_api-0.46.5/mp_api.egg-info/scm_file_list.json +0 -142
- mp_api-0.46.5/mp_api.egg-info/scm_version.json +0 -8
- mp_api-0.46.5/mp_api.egg-info/top_level.txt +0 -1
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.11.txt +0 -179
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.11_extras.txt +0 -711
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.12.txt +0 -177
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.12_extras.txt +0 -702
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.13.txt +0 -176
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.13_extras.txt +0 -696
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.14.txt +0 -176
- mp_api-0.46.5/requirements/requirements-ubuntu-latest_py3.14_extras.txt +0 -696
- mp_api-0.46.5/setup.cfg +0 -4
- mp_api-0.46.5/test_files/Si_mp_149.cif +0 -34
- mp_api-0.46.5/tests/client/molecules/test_molecules.py +0 -18
- {mp_api-0.46.5 → mp_api-0.47.0}/.gitignore +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/LICENSE +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/_server_utils.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/_units.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/contribs/schemas.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/core/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/materials/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/molecules/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/client/routes/molecules/molecules.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/mp_mcp.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/mcp/tools.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/mp_api/py.typed +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/contribs/conftest.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/contribs/test_client.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/contribs/test_contribs_schemas.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/contribs/test_contribs_utils.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/contribs/test_types.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/core/test_oxygen_evolution.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_absorption.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_alloys.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_bonds.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_chemenv.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_dielectric.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_doi.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_elasticity.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_electronic_structure.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_grain_boundary.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_magnetism.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_materials.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_oxidation_states.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_phonon.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_piezo.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_provenance.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_robocrys.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_similarity.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_substrates.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_surface_properties.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_synthesis.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_tasks.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_thermo.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/materials/test_xas.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/molecules/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/molecules/test_summary.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/client/test_heartbeat.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/mcp/__init__.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/mcp/test_server.py +0 -0
- {mp_api-0.46.5 → mp_api-0.47.0}/tests/mcp/test_tools.py +0 -0
mp_api-0.47.0/PKG-INFO
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mp-api
|
|
3
|
+
Version: 0.47.0
|
|
4
|
+
Summary: API Client for the Materials Project
|
|
5
|
+
Author-email: The Materials Project <feedback@materialsproject.org>
|
|
6
|
+
License-Expression: BSD-3-Clause-LBNL
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Information Technology
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: boto3
|
|
20
|
+
Requires-Dist: deltalake<1.6.0,>=1.4.0
|
|
21
|
+
Requires-Dist: emmet-core>=0.88.0
|
|
22
|
+
Requires-Dist: monty>=2024.12.10
|
|
23
|
+
Requires-Dist: orjson<4,>=3.10
|
|
24
|
+
Requires-Dist: pyarrow>=20.0.0
|
|
25
|
+
Requires-Dist: pymatgen>2024.2.20
|
|
26
|
+
Requires-Dist: requests>=2.23.0
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: custodian; extra == 'all'
|
|
30
|
+
Requires-Dist: emmet-core[all]>=0.88.0; extra == 'all'
|
|
31
|
+
Requires-Dist: fastmcp; extra == 'all'
|
|
32
|
+
Requires-Dist: flask; extra == 'all'
|
|
33
|
+
Requires-Dist: ipywidgets; extra == 'all'
|
|
34
|
+
Provides-Extra: contribs
|
|
35
|
+
Requires-Dist: boltons; extra == 'contribs'
|
|
36
|
+
Requires-Dist: bravado; extra == 'contribs'
|
|
37
|
+
Requires-Dist: cachetools; extra == 'contribs'
|
|
38
|
+
Requires-Dist: filetype; extra == 'contribs'
|
|
39
|
+
Requires-Dist: ipython; extra == 'contribs'
|
|
40
|
+
Requires-Dist: json2html; extra == 'contribs'
|
|
41
|
+
Requires-Dist: pint>=0.25.0; extra == 'contribs'
|
|
42
|
+
Requires-Dist: pyisemail; extra == 'contribs'
|
|
43
|
+
Requires-Dist: pymongo; extra == 'contribs'
|
|
44
|
+
Requires-Dist: requests-futures; extra == 'contribs'
|
|
45
|
+
Requires-Dist: swagger-spec-validator; extra == 'contribs'
|
|
46
|
+
Provides-Extra: docs
|
|
47
|
+
Requires-Dist: sphinx; extra == 'docs'
|
|
48
|
+
Provides-Extra: mcp
|
|
49
|
+
Requires-Dist: fastmcp; extra == 'mcp'
|
|
50
|
+
Provides-Extra: notebook
|
|
51
|
+
Requires-Dist: ipywidgets; extra == 'notebook'
|
|
52
|
+
Provides-Extra: server
|
|
53
|
+
Requires-Dist: flask; extra == 'server'
|
|
54
|
+
Provides-Extra: test
|
|
55
|
+
Requires-Dist: mypy; extra == 'test'
|
|
56
|
+
Requires-Dist: pre-commit; extra == 'test'
|
|
57
|
+
Requires-Dist: pytest; extra == 'test'
|
|
58
|
+
Requires-Dist: pytest-asyncio; extra == 'test'
|
|
59
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
60
|
+
Requires-Dist: pytest-mock; extra == 'test'
|
|
61
|
+
Requires-Dist: pytest-xdist; extra == 'test'
|
|
62
|
+
Requires-Dist: types-requests; extra == 'test'
|
|
63
|
+
Requires-Dist: types-setuptools; extra == 'test'
|
|
@@ -46,8 +46,8 @@ def client_search_testing(
|
|
|
46
46
|
alt_name_dict (dict[str, str]): Alternative names for parameters used in the projection and subsequent data checking
|
|
47
47
|
custom_field_tests (dict[str, Any]): Custom queries for specific fields.
|
|
48
48
|
sub_doc_fields (list[str]): Prefixes for fields to check in resulting data. Useful when data to be tested is nested.
|
|
49
|
-
int_bounds (tuple[int,int]) : integer bounds to use in testing int-type query arguments
|
|
50
|
-
float_bounds (tuple[float,float]) : float bounds to use in testing float-type query arguments
|
|
49
|
+
int_bounds (tuple[int, int]) : integer bounds to use in testing int-type query arguments
|
|
50
|
+
float_bounds (tuple[float, float]) : float bounds to use in testing float-type query arguments
|
|
51
51
|
"""
|
|
52
52
|
if search_method is None:
|
|
53
53
|
return
|
|
@@ -58,7 +58,8 @@ def client_search_testing(
|
|
|
58
58
|
for entry in param_tuples:
|
|
59
59
|
param = entry[0]
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
# `db_version` selects a dataset version rather than filtering docs
|
|
62
|
+
if param not in excluded_params + ["return", "db_version"]:
|
|
62
63
|
param_type = entry[1]
|
|
63
64
|
q: dict[str, Any] = {"chunk_size": 1, "num_chunks": 1}
|
|
64
65
|
|
|
@@ -139,7 +140,6 @@ def client_sort(
|
|
|
139
140
|
if k not in ("_page", "_sort_fields", "chunk_size", "fields")
|
|
140
141
|
}
|
|
141
142
|
for sort_field in [sort_fields] if isinstance(sort_fields, str) else sort_fields:
|
|
142
|
-
|
|
143
143
|
asc = search_method(
|
|
144
144
|
_page=1,
|
|
145
145
|
_sort_fields=sort_field,
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import logging
|
|
6
5
|
import os
|
|
7
6
|
from importlib.metadata import PackageNotFoundError, version
|
|
8
7
|
|
|
8
|
+
from mp_api.client.core._display import (
|
|
9
|
+
_configure_from_settings,
|
|
10
|
+
enable_logging,
|
|
11
|
+
is_quiet,
|
|
12
|
+
quiet,
|
|
13
|
+
)
|
|
9
14
|
from mp_api.client.core.exceptions import MPRestError
|
|
10
15
|
from mp_api.client.mprester import MPRester
|
|
11
16
|
|
|
12
|
-
__all__ = ["MPRestError", "MPRester"]
|
|
17
|
+
__all__ = ["MPRestError", "MPRester", "enable_logging", "is_quiet", "quiet"]
|
|
13
18
|
|
|
14
19
|
try:
|
|
15
20
|
__version__ = version("mp_api")
|
|
16
21
|
except PackageNotFoundError: # pragma: no cover
|
|
17
22
|
__version__ = os.getenv("SETUPTOOLS_SCM_PRETEND_VERSION", "")
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
_configure_from_settings()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Logger for the MPContribs client.
|
|
2
|
+
|
|
3
|
+
Records go through the `mp_api.client` logger's default handler (stderr),
|
|
4
|
+
see `mp_api.client.core._display`. No handlers or level are set here: the
|
|
5
|
+
level is configured once, for the whole client, with `MPRESTER_LOG_LEVEL`.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
from mp_api.client.contribs.settings import MPCC_SETTINGS
|
|
14
|
+
from mp_api.client.core._display import mp_deprecation
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CustomLoggerAdapter(logging.LoggerAdapter):
|
|
18
|
+
"""Prefix messages with the supervisor group/process, if running under supervisor."""
|
|
19
|
+
|
|
20
|
+
def process(self, msg, kwargs):
|
|
21
|
+
prefix = self.extra.get("prefix") # type: ignore[union-attr]
|
|
22
|
+
return f"[{prefix}] {msg}" if prefix else msg, kwargs
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_logger(name: str = "mp_api.client.contribs") -> CustomLoggerAdapter:
|
|
26
|
+
"""Get the contribs logger.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
name (str) : logger name, a child of `mp_api.client`
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
CustomLoggerAdapter
|
|
33
|
+
"""
|
|
34
|
+
logger = logging.getLogger(name)
|
|
35
|
+
process = os.environ.get("SUPERVISOR_PROCESS_NAME")
|
|
36
|
+
group = os.environ.get("SUPERVISOR_GROUP_NAME")
|
|
37
|
+
cfg = {"prefix": f"{group}/{process}"} if process and group else {}
|
|
38
|
+
return CustomLoggerAdapter(logger, cfg)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if MPCC_SETTINGS.CLIENT_LOG_LEVEL is not None:
|
|
42
|
+
mp_deprecation(
|
|
43
|
+
"MPCONTRIBS_CLIENT_LOG_LEVEL is deprecated and ignored, use MPRESTER_LOG_LEVEL "
|
|
44
|
+
"(which sets the level for the whole client) instead.",
|
|
45
|
+
stacklevel=2,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
MPCC_LOGGER = get_logger()
|
|
@@ -69,7 +69,10 @@ class Table(pd.DataFrame, _Component):
|
|
|
69
69
|
try:
|
|
70
70
|
allowed_kwargs = getfullargspec(line_chart).args
|
|
71
71
|
attrs = {k: v for k, v in self.attrs.items() if k in allowed_kwargs}
|
|
72
|
-
|
|
72
|
+
# Plot with plotly directly, rather than changing the
|
|
73
|
+
# process-wide pandas plotting backend / plotly template.
|
|
74
|
+
attrs.setdefault("template", "simple_white")
|
|
75
|
+
return line_chart(self, **attrs)
|
|
73
76
|
except Exception as e:
|
|
74
77
|
MPCC_LOGGER.error(f"Can't display table: {e}")
|
|
75
78
|
|