Skip to content

Commit

Permalink
Add warnings for deprecated file formats (protobuf, hoomdxml, Hoomd-B…
Browse files Browse the repository at this point in the history
…lue and LAMMPS simulation writers) (#1188)

* add return statement for deprecation decorator, add dep warnings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* import deprecated method

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add path to writers

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Co Quach <[email protected]>
  • Loading branch information
3 people authored Jun 17, 2024
1 parent 3ceeda2 commit cd53189
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
11 changes: 11 additions & 0 deletions mbuild/formats/hoomd_forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import mbuild as mb
from mbuild.utils.conversion import RB_to_OPLS
from mbuild.utils.decorators import deprecated
from mbuild.utils.io import import_
from mbuild.utils.sorting import natural_sort

Expand All @@ -18,6 +19,16 @@
hoomd = import_("hoomd")


dep_msg = """
Support for Hoomd-Blue writers will be removed in mBuild 1.0.
See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/external/convert_hoomd) for
Hoomd-Blue 3.x and 4.x format support.
To convert to GMSO, use the method `Compound.to_gmso()`.
"""
print(dep_msg)


@deprecated(dep_msg)
def create_hoomd_forcefield(
structure,
r_cut,
Expand Down
11 changes: 11 additions & 0 deletions mbuild/formats/hoomd_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import mbuild as mb
from mbuild.utils.conversion import RB_to_OPLS
from mbuild.utils.decorators import deprecated
from mbuild.utils.io import import_
from mbuild.utils.sorting import natural_sort

Expand All @@ -21,6 +22,16 @@
hoomd.md = import_("hoomd.md")


dep_msg = """
Support for Hoomd-Blue 2.0 will be removed in mBuild 1.0.
See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/external/convert_hoomd) for
Hoomd-Blue 3.x and 4.x format support.
To convert to GMSO, use the method `Compound.to_gmso()`.
"""
print(dep_msg)


@deprecated(dep_msg)
def create_hoomd_simulation(
structure,
r_cut,
Expand Down
4 changes: 2 additions & 2 deletions mbuild/formats/hoomdxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import numpy as np

from mbuild.utils.conversion import RB_to_OPLS
from mbuild.utils.decorators import breaking_change
from mbuild.utils.decorators import deprecated
from mbuild.utils.geometry import coord_shift

__all__ = ["write_hoomdxml"]


@breaking_change("See PR#463 on github")
@deprecated("The .hoomdxml file format will be removed in mBuild 1.0.")
def write_hoomdxml(
structure,
filename,
Expand Down
11 changes: 11 additions & 0 deletions mbuild/formats/lammpsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from mbuild import Box
from mbuild.utils.conversion import RB_to_OPLS
from mbuild.utils.decorators import deprecated
from mbuild.utils.orderedset import OrderedSet
from mbuild.utils.sorting import natural_sort

Expand All @@ -22,6 +23,16 @@
ELEM_TO_COUL = 1.602176634e-19


dep_msg = """
Support for writing out LAMMPS data files will be removed
in mbuild 1.0.
See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/formats/lammpsdata) for
continued support for LAMMPS.
"""
print(dep_msg)


@deprecated(dep_msg)
def write_lammpsdata(
structure,
filename,
Expand Down
8 changes: 8 additions & 0 deletions mbuild/formats/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@

from mbuild import Box, Compound
from mbuild.formats import compound_pb2
from mbuild.utils.decorators import deprecated

__all__ = ["write_pb2", "read_pb2"]


dep_msg = """
Support for the Protobuf file format will be removed in mBuild 1.0.
"""
print(dep_msg)


@deprecated(dep_msg)
def write_pb2(cmpd, filename, binary=True):
"""Convert mb.Compound to Protobuf Message file.
Expand Down
2 changes: 1 addition & 1 deletion mbuild/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def wrapper(*args, **kwargs):
fcn.__name__, warning_string
)
warn(printed_message, DeprecationWarning)
fcn(*args, **kwargs)
return fcn(*args, **kwargs)

return wrapper

Expand Down

0 comments on commit cd53189

Please sign in to comment.