-
Notifications
You must be signed in to change notification settings - Fork 1
Add plugin import system with MORET and MCNP support #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Create plugin import script to automate Funz plugin integration - Parse .ioplugin files to extract model configuration - Convert Funz output patterns to shell extraction commands - Import MORET nuclear calculation plugin as first example - Add tests for MORET model variable extraction and output parsing - Add CI workflow to test plugin import and model validation - Update .gitignore to allow tests directory tracking The import script: - Clones Funz plugin repositories - Parses variable syntax (varprefix, delim, formulaprefix) - Extracts output parsing patterns - Creates model alias JSON files - Copies sample files for testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Update import script to handle MCNP output patterns - Parse MCNP keff output from "final estimated combined" line - Extract keff value and standard deviation using sed - Add MCNP plugin tests for variable extraction and output parsing - Update CI workflow to test both MORET and MCNP plugins - Rename workflow from plugin-moret.yml to plugin-imports.yml MCNP specifics: - Variable prefix: % (instead of $ for MORET) - Comment character: C (instead of * for MORET) - Output file: outp (instead of .listing for MORET) - Output format: "keff = X.XXXXX with an estimated standard deviation of X.XXXXX" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Copy calculator scripts from plugin repositories - Create calculator aliases in .fz/calculators/ - Support both .sh and .bat scripts from plugins - Add script name detection (lowercase, capitalized, uppercase) - Store scripts in scripts/calculators/ directory Created for MORET and MCNP: - .fz/calculators/moret.json - references Moret.sh - .fz/calculators/mcnp.json - references MCNP.sh - scripts/calculators/Moret.sh - calls /opt/MORET/scripts/moret.py - scripts/calculators/MCNP.sh - calls mcnp6 with proper env setup - scripts/calculators/MCNP.bat - Windows batch version Updated CI to verify calculator aliases are created Note: These scripts assume local installation of MORET and MCNP codes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Replace scripts/calculators/ with direct scripts/moret.sh and mcnp.sh - Calculator aliases now reference "sh://bash moret.sh" instead of full paths - Created self-contained wrapper scripts inspired by plugin originals - Added fallback logic to check multiple installation paths Changes: - moret.sh: Checks /opt/MORET/scripts/moret.py or moret in PATH - mcnp.sh: Checks MCNP_PATH env var, /Applications/MCNP6, or mcnp6 in PATH - Both scripts provide clear error messages if calculators not found Calculator aliases: - .fz/calculators/moret.json: "sh://bash moret.sh" - .fz/calculators/mcnp.json: "sh://bash mcnp.sh" This simplifies the structure and makes scripts easier to customize 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements an automated plugin import system that integrates Funz plugins (specifically MORET and MCNP nuclear calculation tools) by parsing their configurations, creating model aliases, and generating wrapper scripts for seamless execution.
- Automated plugin import script that clones Funz repositories and extracts configuration
- Integration of MORET and MCNP plugins with model aliases, calculator wrappers, and sample files
- CI/CD workflow for testing plugin imports across multiple platforms and Python versions
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
scripts/import_plugin.py | Core automation script that parses Funz .ioplugin files and generates fz-compatible aliases |
scripts/moret.sh | MORET calculator wrapper script with installation path detection |
scripts/mcnp.sh | MCNP calculator wrapper script with environment setup and process management |
tests/test_moret_plugin.py | Test suite for MORET plugin functionality including variable extraction and output parsing |
tests/test_mcnp_plugin.py | Test suite for MCNP plugin functionality including variable extraction and output parsing |
examples/moret/godiva.m5 | MORET sample input file for testing |
examples/mcnp/godiva | MCNP sample input file for testing |
.github/workflows/plugin-imports.yml | CI workflow for testing plugin imports across platforms |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
script_content = f"""#!/bin/bash | ||
# {plugin_name.upper()} calculator wrapper | ||
# TODO: Configure the path to {plugin_name.upper()} executable | ||
|
||
echo "ERROR: {plugin_name.upper()} calculator not configured yet." | ||
echo "Please edit this script to set the correct path to {plugin_name.upper()}." | ||
exit 1 | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generic error message includes unnecessary escape sequences. Consider using a triple-quoted string without f-string formatting or proper escaping to avoid potential issues with plugin names containing special characters.
script_content = f"""#!/bin/bash | |
# {plugin_name.upper()} calculator wrapper | |
# TODO: Configure the path to {plugin_name.upper()} executable | |
echo "ERROR: {plugin_name.upper()} calculator not configured yet." | |
echo "Please edit this script to set the correct path to {plugin_name.upper()}." | |
exit 1 | |
""" | |
script_content = """#!/bin/bash | |
# {plugin} calculator wrapper | |
# TODO: Configure the path to {plugin} executable | |
echo "ERROR: {plugin} calculator not configured yet." | |
echo "Please edit this script to set the correct path to {plugin}." | |
exit 1 | |
""".format(plugin=plugin_name.upper()) |
Copilot uses AI. Check for mistakes.
$MCNP_PATH/MCNP_CODE/bin/mcnp6 inp="$@" & | ||
PID_MCNP=$! | ||
echo $PID_MCNP >> PID | ||
wait $PID_MCNP | ||
elif command -v mcnp6 &> /dev/null; then | ||
mcnp6 inp="$@" & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command line argument handling is incorrect. MCNP expects the input filename as a positional argument, not as 'inp="$@"'. This should be just '$MCNP_PATH/MCNP_CODE/bin/mcnp6 "$@"' or if the inp= syntax is required, it should be 'inp="$1"' for a single input file.
$MCNP_PATH/MCNP_CODE/bin/mcnp6 inp="$@" & | |
PID_MCNP=$! | |
echo $PID_MCNP >> PID | |
wait $PID_MCNP | |
elif command -v mcnp6 &> /dev/null; then | |
mcnp6 inp="$@" & | |
$MCNP_PATH/MCNP_CODE/bin/mcnp6 "$1" & | |
PID_MCNP=$! | |
echo $PID_MCNP >> PID | |
wait $PID_MCNP | |
elif command -v mcnp6 &> /dev/null; then | |
mcnp6 "$1" & |
Copilot uses AI. Check for mistakes.
$MCNP_PATH/MCNP_CODE/bin/mcnp6 inp="$@" & | ||
PID_MCNP=$! | ||
echo $PID_MCNP >> PID | ||
wait $PID_MCNP | ||
elif command -v mcnp6 &> /dev/null; then | ||
mcnp6 inp="$@" & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above - the command line argument handling is incorrect. This should be 'mcnp6 "$@"' or 'mcnp6 inp="$1"' if the inp= syntax is specifically required by MCNP.
$MCNP_PATH/MCNP_CODE/bin/mcnp6 inp="$@" & | |
PID_MCNP=$! | |
echo $PID_MCNP >> PID | |
wait $PID_MCNP | |
elif command -v mcnp6 &> /dev/null; then | |
mcnp6 inp="$@" & | |
$MCNP_PATH/MCNP_CODE/bin/mcnp6 inp="$1" & | |
PID_MCNP=$! | |
echo $PID_MCNP >> PID | |
wait $PID_MCNP | |
elif command -v mcnp6 &> /dev/null; then | |
mcnp6 inp="$1" & |
Copilot uses AI. Check for mistakes.
input_file.write_text("""MORET_BEGIN | ||
TITLE TEST | ||
|
||
TERM | ||
CYCL | ||
ACTI $(n_cycles) | ||
PASS 3 | ||
KEFF | ||
SIGM 0.001 | ||
ENDT | ||
|
||
* Geometry modelling | ||
GEOM | ||
MODU 0 | ||
TYPE 1 SPHE $(radius) | ||
VOLU Ext0 0 1 1 0.0 0.0 0.0 | ||
ENDM | ||
ENDG | ||
|
||
ENDD | ||
MORET_END | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The multi-line string contains inconsistent indentation. The MORET input format appears to require specific spacing, but the Python indentation makes this unclear. Consider using textwrap.dedent() or adjusting the string formatting to make the actual MORET input structure more apparent.
Copilot uses AI. Check for mistakes.
input_file.write_text("""Godiva-type critical reactor | ||
c kcode example with %(n_particles) neutrons | ||
1 1 -18.74 -1 imp:n=1 $ enriched uranium sphere | ||
2 0 1 imp:n=0 $ all space outside | ||
|
||
1 so %(radius) $ radius of sphere | ||
|
||
kcode %(n_particles) 1.0 10 110 | ||
ksrc 0 0 0 | ||
m1 92235 -93.71 92238 -5.27 92234 -1.02 | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the MORET test, the multi-line string has inconsistent indentation that may not reflect the actual MCNP input format requirements. Consider using textwrap.dedent() to clarify the intended structure.
Copilot uses AI. Check for mistakes.
Summary
Implements an automated plugin import system that generates model aliases, calculator aliases, and wrapper scripts from Funz plugin repositories. Successfully integrated MORET and MCNP nuclear calculation plugins as initial examples.
Features
Plugin Import Script (
scripts/import_plugin.py
).ioplugin
configuration files.fz/models/
scripts/
.fz/calculators/
examples/
for testingMORET Plugin Support
.fz/models/moret.json
$
()
*
.listing
filesmoret.sh
wrapper script/opt/MORET/scripts/moret.py
ormoret
in PATHexamples/moret/godiva.m5
tests/test_moret_plugin.py
MCNP Plugin Support
.fz/models/mcnp.json
%
()
C
outp
filesmcnp.sh
wrapper scriptMCNP_PATH
env var,/Applications/MCNP6
, ormcnp6
in PATHexamples/mcnp/godiva
tests/test_mcnp_plugin.py
CI/CD
Added
.github/workflows/plugin-imports.yml
workflow that:Test Results
✅ All 4 tests pass:
test_moret_model_extraction
- Variable extraction and output parsingtest_moret_sample_file
- Sample file validationtest_mcnp_model_extraction
- Variable extraction and output parsingtest_mcnp_sample_file
- Sample file validationUsage
Import a plugin:
Use in code:
Files Changed
New files:
scripts/import_plugin.py
- Plugin import automationscripts/moret.sh
- MORET calculator wrapperscripts/mcnp.sh
- MCNP calculator wrappertests/test_moret_plugin.py
- MORET teststests/test_mcnp_plugin.py
- MCNP testsexamples/moret/godiva.m5
- MORET sampleexamples/mcnp/godiva
- MCNP sample.github/workflows/plugin-imports.yml
- CI workflowModified:
.gitignore
- Allowtests/**
andscripts/**
Generated (not tracked):
.fz/models/moret.json
- MORET model alias.fz/models/mcnp.json
- MCNP model alias.fz/calculators/moret.json
- MORET calculator alias.fz/calculators/mcnp.json
- MCNP calculator aliasNotes
scripts/moret.sh
andscripts/mcnp.sh
🤖 Generated with Claude Code