Files
openfe/openfecli/cli.py
Alyssa Travitz 2311a2f2d9 ruff formatting part 2 - everything but the tests (#1610)
* 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>
2025-10-24 14:09:45 -07:00

52 lines
1.4 KiB
Python

# This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pathlib
import logging
import click
from plugcli.cli import CLI, CONTEXT_SETTINGS
from plugcli.plugin_management import FilePluginLoader
import openfecli
from openfecli.plugins import OFECommandPlugin
class OpenFECLI(CLI):
# COMMAND_SECTIONS = ["Setup", "Simulation", "Orchestration", "Analysis"]
COMMAND_SECTIONS = ["Network Planning", "Quickrun Executor", "Miscellaneous"]
def get_loaders(self):
commands = str(pathlib.Path(__file__).parent.resolve() / "commands")
loader = FilePluginLoader(commands, OFECommandPlugin)
return [loader]
def get_installed_plugins(self):
loader = self.get_loaders()[0]
return list(loader())
_MAIN_HELP = """
A command line interface to provide access to basic
functionality of the openfe Python library.
"""
@click.command(cls=OpenFECLI, name="openfe", help=_MAIN_HELP, context_settings=CONTEXT_SETTINGS)
@click.version_option(version=openfecli.__version__)
@click.option(
"--log",
type=click.Path(exists=True, readable=True),
help="logging configuration file",
)
def main(log):
# Subcommand runs after this is processed.
# set logging if provided
if log:
logging.config.fileConfig(log, disable_existing_loggers=False)
if __name__ == "__main__": # -no-cov- (useful in debugging)
main()