Skip to content

Commit f955977

Browse files
authored
Merge pull request #9 from ISISNeutronMuon/8-plugin-api
Added a plugin API and refactored the plugins to use click rathrer than argparse at the top level, this lets us add subcommands rin run plugin etc. that make it clearer as to what we are doing.
2 parents a555063 + 74cd864 commit f955977

27 files changed

+6156
-329
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# make testall # run pytest in each venv
77
# make clean-venvs # remove created venv directories
88

9-
PYTHONS := 3.10 3.11 3.12 3.13
9+
PYTHONS := 3.10 3.11 3.12 3.13 # 3.14 in the near future
1010
VENV_PREFIX := .venv-
1111
CC ?= gcc
1212
export CC

poly_lithic/scripts/main.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1+
"""
2+
Main entry point for poly_lithic CLI.
3+
4+
Provides backward compatibility while supporting new Click-based commands.
5+
"""
6+
7+
18
def main():
2-
import asyncio
3-
import logging
4-
import os
5-
from poly_lithic.src.cli import model_main, setup
6-
from poly_lithic.src.logging_utils import make_logger, reset_logging
9+
"""
10+
Main entry point that supports both old and new CLI styles.
711
8-
logger = make_logger('model_manager')
9-
logger.info('Starting model manager')
12+
Old style (still works):
13+
python -m poly_lithic.scripts.main --config config.yaml --debug
1014
11-
(args, config, broker) = setup()
12-
print('resetting logging...')
13-
reset_logging()
15+
New style (recommended):
16+
poly-lithic --config config.yaml --debug
17+
poly-lithic run --config config.yaml
18+
poly-lithic plugin init --name my-plugin
19+
"""
20+
import sys
21+
from poly_lithic.src.cli import cli
1422

15-
if os.environ.get('DEBUG') == 'True':
16-
logger = make_logger('model_manager', level=logging.DEBUG)
17-
else:
18-
logger = make_logger('model_manager')
23+
# If no arguments, show help
24+
if len(sys.argv) == 1:
25+
sys.argv.append('--help')
1926

20-
asyncio.run(model_main(args, config, broker))
27+
# Run the Click CLI
28+
cli()
2129

2230

2331
if __name__ == '__main__':

0 commit comments

Comments
 (0)