Skip to content

Commit 4e363ae

Browse files
committed
Refactor .gitignore for better organization and clarity; update CLI plugin initialization to handle prompts more effectively; enhance ModelObserver error handling; add Plugin API documentation and example usage; include image asset for plugin template.
1 parent 95dec52 commit 4e363ae

File tree

8 files changed

+318
-54
lines changed

8 files changed

+318
-54
lines changed

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV
2929
echo "version=${TAG_NAME}" >> $GITHUB_OUTPUT
3030
31-
- name: Determine if version is pure semver (e.g. v0.1.2)
31+
- name: Determine if version is pure semver
3232
id: semver_check
3333
run: |
3434
if echo "${{ steps.vars.outputs.version }}" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then

.gitignore

Lines changed: 144 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,157 @@
1-
main_local.py
2-
env
3-
cred.json
1+
# Python
42
__pycache__/
5-
*lcls-cu-inj-nn/*
6-
*lcls_cu_inj_nn/*
7-
kube
8-
old
9-
.pytest_cache
10-
*.egg-info
11-
mlruns
12-
generic_model
13-
torch_model
14-
model1.txt
15-
metric2.png
16-
local_test
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
*.egg
7+
*.egg-info/
8+
dist/
9+
build/
10+
*.prof
11+
*.profile
12+
13+
# Virtual Environments
14+
env/
15+
.env
16+
.venv*/
17+
test-env/
18+
.venv-*/
19+
20+
# IDE & Editors
21+
.vscode/
22+
*.code-workspace
23+
24+
# Testing & Coverage
25+
.pytest_cache/
1726
.coverage
18-
image.png
19-
output.log
20-
slack.py
21-
test.ipynb
22-
image_model
23-
test.h5
24-
.vscode
25-
/build
27+
test_files/
28+
29+
# Build Tools
30+
.ruff_cache/
31+
build-info*
32+
33+
# MLFlow & Models
34+
mlruns/
35+
*lcls-cu-inj-nn/
36+
*lcls_cu_inj_nn/
37+
generic_model/
38+
torch_model/
39+
image_model/
40+
astra_*/
41+
*-surrograte/
42+
43+
# Kubernetes & Deployment
44+
kube/
45+
configs/
46+
*-deployment/
47+
*-deployment-*/
48+
cookiecutter-*/
49+
lebt_*/
50+
waterfall*/
51+
52+
# Credentials & Secrets
2653
env.json
54+
cred.json
2755
creds.json
56+
57+
# Documentation
58+
graphs/
59+
60+
# Temporary & Local Files
61+
tmp*
62+
old/
63+
old_examples/
64+
local_test/
65+
*.log
66+
*.png
67+
*.txt
68+
*.h5
69+
test.ipynb
2870
test.py
29-
cookiecutter-*
30-
.ruff_cache
71+
test.yaml
72+
image.png
73+
main_local.py
74+
slack.py
75+
_version.py
76+
notify.profile
77+
</attachment>
78+
79+
This organizes the `.gitignore` into logical sections with comments, removes redundancy (like combining `env` and `.env`), and groups similar patterns together for easier maintenance.# filepath: /home/gbm96348/nfs_home/lume-deployment/.gitignore
80+
81+
# Python
82+
__pycache__/
83+
*.py[cod]
84+
*$py.class
85+
*.so
86+
*.egg
87+
*.egg-info/
88+
dist/
89+
build/
90+
*.prof
91+
*.profile
92+
93+
# Virtual Environments
94+
env/
95+
.env
96+
.venv*/
97+
test-env/
98+
.venv-*/
99+
100+
# IDE & Editors
101+
.vscode/
102+
*.code-workspace
103+
104+
# Testing & Coverage
105+
.pytest_cache/
106+
.coverage
107+
test_files/
108+
109+
# Build Tools
110+
.ruff_cache/
31111
build-info*
32-
*-deployment-*/
33-
*-deployment/
34-
cookiecutter-*/
112+
113+
# MLFlow & Models
114+
mlruns/
115+
*lcls-cu-inj-nn/
116+
*lcls_cu_inj_nn/
117+
generic_model/
118+
torch_model/
119+
image_model/
35120
astra_*/
121+
*-surrograte/
122+
123+
# Kubernetes & Deployment
124+
kube/
36125
configs/
126+
*-deployment/
127+
*-deployment-*/
128+
cookiecutter-*/
37129
lebt_*/
38-
*-surrograte/
39130
waterfall*/
40-
_version.py
41-
dist/
131+
132+
# Credentials & Secrets
133+
env.json
134+
cred.json
135+
creds.json
136+
137+
# Documentation
42138
graphs/
43-
.coverage
44-
.vscode
139+
140+
# Temporary & Local Files
45141
tmp*
46-
notify.profile
47-
test.yaml
48-
test_files/
142+
old/
49143
old_examples/
50-
*code-workspace
51-
test-env
52-
.venv*
144+
local_test/
145+
*.log
146+
*.png
147+
*.txt
148+
*.h5
149+
test.ipynb
150+
test.py
151+
test.yaml
152+
image.png
153+
main_local.py
154+
slack.py
155+
_version.py
156+
notify.profile
157+
!image.png

poly_lithic/src/cli.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def run_model(config, model_getter, debug, env, one_shot, publish, requirements)
202202
if requirements:
203203
click.echo('Requirements-only mode - exiting after installation')
204204
sys.exit(0)
205-
205+
# ugly but we needed to do some legacy support, this will eventially all be click handled
206206
import argparse
207207
args = argparse.Namespace(
208208
config=config,
@@ -242,21 +242,19 @@ def plugin():
242242

243243

244244
@plugin.command()
245-
@click.option('--name', '-n', prompt='Plugin name',
245+
@click.option('--name', '-n', default=None,
246246
help='Name of the plugin package')
247-
@click.option('--author', '-a', prompt='Author name', default='',
247+
@click.option('--author', '-a', default=None,
248248
help='Author name')
249-
@click.option('--email', prompt='Author email', default='example@email.com',
249+
@click.option('--email', default=None,
250250
help='Author email')
251-
@click.option('--description', '-d', prompt='Short description', default='',
251+
@click.option('--description', '-d', default=None,
252252
help='Plugin description')
253253
@click.option('--output-dir', '--dir', '-o', type=click.Path(), default='.',
254254
help='Output directory for the plugin project (default: current directory)')
255-
@click.option('--license', default='MIT',
256-
help='License type')
257255
@click.option('--no-prompt', is_flag=True,
258256
help='Skip interactive prompts (use defaults or provided values)')
259-
def init(name, author, email, description, output_dir, license, no_prompt):
257+
def init(name, author, email, description, output_dir, no_prompt):
260258
"""
261259
Initialize a new plugin project from template.
262260
@@ -274,6 +272,18 @@ def init(name, author, email, description, output_dir, license, no_prompt):
274272

275273
click.echo(click.style('\n🚀 Creating Plugin Project\n', fg='cyan', bold=True))
276274

275+
# Handle prompts manually based on no_prompt flag
276+
if no_prompt:
277+
name = name or 'my_plugin'
278+
author = author or 'Author Name'
279+
email = email or 'example@email.com'
280+
description = description or 'A poly_lithic plugin package'
281+
else:
282+
name = name or click.prompt('Plugin name')
283+
author = author or click.prompt('Author name', default='')
284+
email = email or click.prompt('Author email', default='example@email.com')
285+
description = description or click.prompt('Short description', default='')
286+
277287
output_path = Path(output_dir).expanduser().resolve()
278288
plugin_dir_name = PluginGenerator._normalize_package_name(name)
279289

@@ -285,13 +295,13 @@ def init(name, author, email, description, output_dir, license, no_prompt):
285295
sys.exit(1)
286296

287297
generator = PluginGenerator()
298+
288299
project_path = generator.generate(
289300
name=name,
290301
author=author,
291302
email=email,
292303
description=description,
293304
output_dir=str(output_path),
294-
license=license,
295305
)
296306

297307
click.echo(click.style(f"✓ Plugin project created: {project_path.name}", fg='green', bold=True))

poly_lithic/src/utils/messaging.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,17 @@ def __get_model(self):
435435
return model
436436

437437
else:
438-
raise ValueError(f'model type not recognised: {self.config["type"]}')
438+
# try the plugin then fail
439+
try:
440+
model_getter = registered_model_getters[self.config['type']](
441+
self.config['args']
442+
)
443+
model = model_getter.get_model()
444+
return model
445+
except KeyError:
446+
raise ValueError(f'model type not recognised: {self.config["type"]}')
447+
448+
# raise ValueError(f'model type not recognised: {self.config["type"]}')
439449

440450
def update(self, message: Message) -> list[Message]:
441451
messages = []

poly_lithic/src/utils/plugin_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def generate(
3030
email: str = '',
3131
description: str = '',
3232
output_dir: str = '.',
33-
license: str = 'MIT',
3433
) -> Path:
3534
"""
3635
Generate a plugin project from templates.

0 commit comments

Comments
 (0)