updated build system and deprecated modules#76
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the build system from setup.py to pyproject.toml and removes deprecated dependencies (six, joblib, pyknotid) to streamline the package. The PR also adds an OpenMM installation warning to help users install the correct version for their system.
Key changes:
- Migrated build configuration to pyproject.toml with modern Python packaging standards
- Removed joblib and six dependencies, deprecating associated file format support
- Added OpenMM installation warning at package import time
Reviewed Changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added complete project configuration including metadata, dependencies, and build system |
| setup.py | Simplified to minimal Cython extension builder |
| requirements.txt | Removed deprecated dependencies (six, joblib, pyknotid) |
| polychrom/init.py | Added OpenMM installation warning |
| polychrom/polymerutils.py | Removed joblib/text file support, keeping only HDF5 URIs |
| utilities/showChainWithRasmol.py | Removed joblib import and moved polymerutils import to top |
| polychrom/cli/xyz | Removed unused joblib import |
| polychrom/cli/show | Removed unused joblib import and fixed "useage" typo |
| polychrom/__polymer_math.cpp | Removed unused omp.h include |
| docs/index.rst | Updated dependency documentation |
| docs/conf.py | Removed joblib from mocked modules |
| .gitignore | Added compiled .so files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pyproject.toml
Outdated
| version = "0.1.1" | ||
| description = "A library for polymer simulations and their analyses." | ||
| readme = "README.md" | ||
| requires-python = ">=3.7" |
There was a problem hiding this comment.
The PR description claims 'Bumped python version to 3.13', but requires-python is set to '>=3.7'. This is inconsistent. If the intention is to require Python 3.13 as the minimum version, this should be requires-python = '>=3.13'. If Python 3.7+ is the correct minimum version, the PR description should be updated to reflect that Python 3.13 is added to the classifiers (supported versions) rather than being the minimum requirement.
| requires-python = ">=3.7" | |
| requires-python = ">=3.13" |
| if not full_output: | ||
| block = block["pos"] | ||
| return block["pos"] | ||
|
|
There was a problem hiding this comment.
Missing return statement when full_output=True for HDF5 files. When full_output=True, the function should return the full block dictionary but currently falls through without returning it. Add return block after line 115 or change line 115 to return block['pos'] and add an else: return block clause.
| return block |
polychrom/polymerutils.py
Outdated
|
|
||
| else: | ||
| raise ValueError("Unknown mode : %s, use h5dict, joblib, txt or pdb" % mode) | ||
| raise ValueError("Unknown mode : %s, use or pdb" % mode) |
There was a problem hiding this comment.
Error message is grammatically incorrect. 'use or pdb' should be 'use pdb' since pdb is now the only supported mode after removing txt and joblib modes.
| raise ValueError("Unknown mode : %s, use or pdb" % mode) | |
| raise ValueError("Unknown mode: %s. Only 'pdb' is supported." % mode) |
polychrom/polymerutils.py
Outdated
| if len(blocksdat) > 0: | ||
| block = load(os.path.join(folder, f"block{ind}.dat")) | ||
| return block | ||
| return load(os.path.join(folder, f"block{ind}.dat")) |
There was a problem hiding this comment.
This line will always raise a ValueError since the load() function no longer supports .dat files (line 62 raises ValueError for non-URI filenames). The function should either handle .dat files differently or remove this deprecated code path entirely. If .dat files are still expected to be supported for backward compatibility, the load() function needs to be updated, or this should call a different function.
docs/conf.py
Outdated
| "simtk.unit.nanometer", | ||
| "simtk.openmm", | ||
| "joblib", | ||
| "simtk.openmm", |
There was a problem hiding this comment.
Trailing whitespace after 'simtk.openmm'. Remove the extra spaces at the end of the line.
| "simtk.openmm", | |
| "simtk.openmm", |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 14 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
polychrom/legacy/polymerutils.py:1
- Import pollutes the enclosing namespace, as the imported module polychrom.polymerutils does not define 'all'.
from polychrom.polymerutils import * # noqa: F403
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Text files in openmm-polymer format | ||
| joblib files in openmm-polymer format | ||
| """ | ||
| A function to load a single conformation from a URI. Deprecated. |
There was a problem hiding this comment.
The docstring should be formatted properly. It should start with a brief one-line summary followed by a blank line, then additional details.
| A function to load a single conformation from a URI. Deprecated. | |
| A function to load a single conformation from a URI. Deprecated. |
| filename to load or a URI | ||
|
|
||
| """ | ||
| warnings.warn("polymerutils.load is deprecated. Use hdf5_format.load_URI instead.", DeprecationWarning) |
There was a problem hiding this comment.
The deprecation warning should include a stacklevel parameter (typically stacklevel=2) to show the warning at the caller's location rather than within the deprecated function itself, making it more useful for users.
| warnings.warn("polymerutils.load is deprecated. Use hdf5_format.load_URI instead.", DeprecationWarning) | |
| warnings.warn("polymerutils.load is deprecated. Use hdf5_format.load_URI instead.", DeprecationWarning, stacklevel=2) |
| warnings.warn( | ||
| "fetch_block is deprecated. Use hdf5_format.list_uris followed by hdf5_format.load_URI instead.", | ||
| DeprecationWarning, | ||
| ) |
There was a problem hiding this comment.
The deprecation warning should include a stacklevel parameter (typically stacklevel=2) to show the warning at the caller's location rather than within the deprecated function itself, making it more useful for users.
| @@ -0,0 +1 @@ | |||
| from polychrom.polymerutils import * # noqa: F403 No newline at end of file | |||
There was a problem hiding this comment.
Using wildcard imports (import *) can make it unclear what symbols are being imported and can cause namespace pollution. Consider explicitly importing the specific functions or modules needed, or at minimum document what this legacy module is expected to provide.
| from polychrom.polymerutils import * # noqa: F403 | |
| # Legacy compatibility shim: re-exporting all public symbols from polychrom.polymerutils. | |
| # If you know the specific symbols needed, replace the wildcard import below with explicit imports. | |
| from polychrom.polymerutils import ( | |
| # List the specific functions, classes, or variables to import here, e.g.: | |
| # function1, | |
| # function2, | |
| # Class1, | |
| # ... | |
| ) |
| import numpy | ||
|
|
||
| # Define Cython extensions |
There was a problem hiding this comment.
The setup.py imports setuptools.Extension and Cython.Build.cythonize directly, but these should be available at build time from the build-system requirements. However, importing numpy directly at the module level can cause issues if numpy is not yet installed. Consider using a try-except block or ensuring numpy is installed before this import executes, or use the PEP 517 isolated build which should handle this correctly.
| import numpy | |
| # Define Cython extensions | |
| # Define Cython extensions | |
| import numpy |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
No change in functionality. Did the following:
Black and better py314 compatibility are coming in the next PR.
PR Checklist
black .)isort .)flake8and try to resolve all the issues (work in progress!)