mirror of
https://github.com/OpenFreeEnergy/openfe.git
synced 2026-06-05 06:44:24 +08:00
* add more checks * make precommit manual * apply formatting to pyproject.toml * add TODO * remove unneeded, add a few more * add ruff, but turn everything off * add openfe known first party * format highest-level files * first half of openfe protocols * second half of openfe protocols * openfe protocols formatting, with alyssa's fmt skips * add ruff formatter to precommit * fmt: off all vendored _rfe_utils code * addressing review comments * format openfe/utils * format openfe/setup * first batch of cli formatting * second batch of cli formatting * formatting the rest of openfecli commands * format openfecli/parameters * format openfe/storage * run precommit * Update openfecli/commands/gather.py Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com> * update example notebooks branch for v1.7.0 docs changes (#1615) * bump example notebooks branch * add ipykernel to env * roll back to fixing septop branch * i dont think we want ipykernel * bump to tmp_fix_docs branch * point to branch revert-237-v1.7_cookbooks * point to latest example notebooks release * remove colab button, point to updated example notebooks, reorg landing page (#1618) * remove colab button from example notebooks in docs * point to example notebooks 2025.10.2 * replace 'try' with CLI --------- Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
69 lines
1.7 KiB
Python
69 lines
1.7 KiB
Python
# This code is part of OpenFE and is licensed under the MIT license.
|
|
# For details, see https://github.com/OpenFreeEnergy/openfe
|
|
|
|
import click
|
|
import urllib
|
|
import shutil
|
|
from plugcli.cli import CLI, CONTEXT_SETTINGS
|
|
from openfecli.fetching import FetchablePlugin
|
|
from openfecli import OFECommandPlugin
|
|
|
|
# MOVE SINGLEMODULEPLUGINLOADER UPSTREAM TO PLUGCLI
|
|
import importlib
|
|
from plugcli.plugin_management import CLIPluginLoader
|
|
|
|
|
|
class SingleModulePluginLoader(CLIPluginLoader):
|
|
"""Load plugins from a specific module"""
|
|
|
|
def __init__(self, module_name, plugin_class):
|
|
super().__init__(
|
|
plugin_type="single_module",
|
|
search_path=module_name,
|
|
plugin_class=plugin_class,
|
|
)
|
|
|
|
def _find_candidates(self):
|
|
return [importlib.import_module(self.search_path)]
|
|
|
|
@staticmethod
|
|
def _make_nsdict(candidate):
|
|
return vars(candidate)
|
|
|
|
|
|
class FetchCLI(CLI):
|
|
"""Custom command class for the Fetch subcommand.
|
|
|
|
This provides the command sections used in help and defines where
|
|
plugins should be kept.
|
|
"""
|
|
|
|
COMMAND_SECTIONS = ["Tutorials"]
|
|
|
|
def get_loaders(self):
|
|
return [SingleModulePluginLoader("openfecli.fetchables", FetchablePlugin)]
|
|
|
|
def get_installed_plugins(self):
|
|
loader = self.get_loaders()[0]
|
|
return list(loader())
|
|
|
|
|
|
@click.command(cls=FetchCLI, short_help="Fetch tutorial or other resource.")
|
|
def fetch():
|
|
"""
|
|
Fetch the given resource. Some resources require internet; others are
|
|
built-in.
|
|
"""
|
|
|
|
|
|
PLUGIN = OFECommandPlugin(
|
|
command=fetch,
|
|
section="Miscellaneous",
|
|
requires_ofe=(0, 7),
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
# it's useful to keep a main here for debugging where problems happen in
|
|
# the command tree
|
|
fetch()
|