Files
openfe/openfecli/parameters/utils.py
Alyssa Travitz 588f552ca9 add ruff isort linting rule (#1665)
* isort for docs and utils

* isort for top-level openfe, analysis, setup

* isort setup/

* isort storage/

* isort protocols

* isort openn_afe

* isort openmm_rfe

* isort all protocols

* apply isort to openfe/tests

* apply isort to openfecli

* apply isort to devtools/

* add TODO for setup init
2025-11-10 21:58:30 +00:00

32 lines
873 B
Python

# This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from plugcli.params import NOT_PARSED
from openfecli.utils import import_thing
def import_parameter(import_str: str):
"""Return object from a qualname, or NOT_PARSED if not valid.
This is used specifically for parameter instantiation strategies based
on importing an object given by the user on the command line. If the
user input cannot interpreted as a qualname, then NOT_PARSED is
returned.
Parameters
----------
import_str : str
the qualname
Returns
-------
Any :
the desired object or NOT_PARSED if an error was encountered.
"""
try:
result = import_thing(import_str)
except (ImportError, AttributeError):
result = NOT_PARSED
return result