gitronics 0.5.4__tar.gz → 0.5.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitronics-0.5.4 → gitronics-0.5.6}/Cargo.lock +8 -1
- {gitronics-0.5.4 → gitronics-0.5.6}/Cargo.toml +3 -1
- {gitronics-0.5.4 → gitronics-0.5.6}/PKG-INFO +1 -1
- gitronics-0.5.6/README.md +103 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/mkdocs.yml +5 -5
- {gitronics-0.5.4 → gitronics-0.5.6}/src/build_model.rs +28 -16
- {gitronics-0.5.4 → gitronics-0.5.6}/src/project_manager.rs +2 -2
- {gitronics-0.5.4 → gitronics-0.5.6}/src/types.rs +0 -9
- {gitronics-0.5.4 → gitronics-0.5.6}/.github/workflows/ci.yml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/.github/workflows/docs.yml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/.github/workflows/release.yml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/.gitignore +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/LICENSE +0 -0
- {gitronics-0.5.4/docs → gitronics-0.5.6/docs/assets}/logo.png +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/best-practices.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/changelog.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/examples.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/getting-started.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/index.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/installation.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/requirements.txt +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/usage/build.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/usage/configuration.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/docs/usage/migrate.md +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/assessment_specific/filler_model_3.mcnp +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/assessment_specific/filler_model_3.metadata +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/assessment_specific/small_override.yaml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/configurations/valid_configuration.yaml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/output/.gitignore +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/fine_mesh.tally +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/materials.mat +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/my_transform.transform +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/volumetric_source.source +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/envelope_structure.mcnp +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/envelope_structure.metadata +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/filler_models/filler_model_1.mcnp +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/filler_models/filler_model_1.metadata +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/filler_models/filler_model_2.mcnp +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/filler_models/filler_model_2.metadata +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/pyproject.toml +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/python/gitronics/__init__.py +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/python/tests/test_cli_works.py +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/resources/simple_model.mcnp +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/cli.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/lib.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/main.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/migrate_model.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/model_config.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/project_manager/load_metadata.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/project_manager/load_model_config.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/project_manager/load_project_files.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/python.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/src/utils.rs +0 -0
- {gitronics-0.5.4 → gitronics-0.5.6}/tests/test_example_project.rs +0 -0
|
@@ -238,6 +238,12 @@ version = "0.8.21"
|
|
|
238
238
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
239
239
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
240
240
|
|
|
241
|
+
[[package]]
|
|
242
|
+
name = "dunce"
|
|
243
|
+
version = "1.0.5"
|
|
244
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
245
|
+
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
|
246
|
+
|
|
241
247
|
[[package]]
|
|
242
248
|
name = "either"
|
|
243
249
|
version = "1.15.0"
|
|
@@ -384,10 +390,11 @@ dependencies = [
|
|
|
384
390
|
|
|
385
391
|
[[package]]
|
|
386
392
|
name = "gitronics"
|
|
387
|
-
version = "0.5.
|
|
393
|
+
version = "0.5.6"
|
|
388
394
|
dependencies = [
|
|
389
395
|
"chrono",
|
|
390
396
|
"clap",
|
|
397
|
+
"dunce",
|
|
391
398
|
"env_logger",
|
|
392
399
|
"git2",
|
|
393
400
|
"indexmap",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "gitronics"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.6"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
description = "Build MCNP neutronics models from modular components"
|
|
6
6
|
license = "EUPL-1.2"
|
|
7
|
+
readme = "README.md"
|
|
7
8
|
|
|
8
9
|
[[bin]]
|
|
9
10
|
name = "gitronics"
|
|
@@ -28,6 +29,7 @@ regex = "1.12.3"
|
|
|
28
29
|
clap = { version = "4.6.1", features = ["derive"] }
|
|
29
30
|
indexmap = { version = "2.14.0", features = ["serde"] }
|
|
30
31
|
git2 = "0.21.0"
|
|
32
|
+
dunce = "1.0.5"
|
|
31
33
|
|
|
32
34
|
[dev-dependencies]
|
|
33
35
|
tempfile = "3.0"
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="docs/assets/logo.png" alt="Gitronics logo" width="140"/>
|
|
3
|
+
<h1>Gitronics</h1>
|
|
4
|
+
<p><strong>Build MCNP neutronics models from modular, version-controlled components.</strong></p>
|
|
5
|
+
|
|
6
|
+
[](https://github.com/Fusion4Energy/gitronics/actions/workflows/ci.yml)
|
|
7
|
+
[](https://fusion4energy.github.io/gitronics/latest/)
|
|
8
|
+
[](https://pypi.org/project/gitronics/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Gitronics lets you decompose a monolithic [MCNP](https://mcnp.lanl.gov/) input file into independent, version-controllable components — universe filler models, an envelope structure, and separate data cards — and reassemble them at build time via a YAML configuration.
|
|
15
|
+
|
|
16
|
+
**Full documentation: [fusion4energy.github.io/gitronics](https://fusion4energy.github.io/gitronics/latest/)**
|
|
17
|
+
|
|
18
|
+
## Why?
|
|
19
|
+
|
|
20
|
+
| Problem with monolithic models | Gitronics solution |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `git diff` is unreadable | Each component is a separate file |
|
|
23
|
+
| Running variants means copying the whole file | Override only the fields that change |
|
|
24
|
+
| Teams can't work on sub-models in parallel | Each filler model is independent |
|
|
25
|
+
| Hard to know exactly what was run | Commit hash and timestamp written into every assembled file |
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install gitronics
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Requires Python 3.9+. Pre-built wheels for Linux, macOS, and Windows are published to PyPI — no Rust toolchain needed.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
**Migrate an existing model:**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
gitronics migrate path/to/my_model.mcnp --output-path ./my_project
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Build a model:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gitronics build my_project/configurations/baseline.yaml --output-path my_project/output/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Get help:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
gitronics --help
|
|
53
|
+
gitronics build --help
|
|
54
|
+
gitronics migrate --help
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Project layout
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
my_project/
|
|
61
|
+
├── configurations/
|
|
62
|
+
│ ├── baseline.yaml ← declares which fillers go where
|
|
63
|
+
│ └── variant_A.yaml ← inherits baseline, overrides some fields
|
|
64
|
+
├── output/
|
|
65
|
+
│ └── .gitignore
|
|
66
|
+
└── reference_model/
|
|
67
|
+
├── envelope_structure.mcnp
|
|
68
|
+
├── filler_models/
|
|
69
|
+
│ ├── component_A.mcnp
|
|
70
|
+
│ └── component_B.mcnp
|
|
71
|
+
└── data_cards/
|
|
72
|
+
├── materials/
|
|
73
|
+
├── sources/
|
|
74
|
+
└── tallies/
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Configuration example
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
project_roots: [..] # Relative to this file's location
|
|
81
|
+
|
|
82
|
+
envelope_structure: envelope_structure
|
|
83
|
+
source: dt_plasma
|
|
84
|
+
materials: [all_materials]
|
|
85
|
+
tallies: [tritium_breeding_ratio]
|
|
86
|
+
|
|
87
|
+
envelopes:
|
|
88
|
+
blanket_inner: blanket_v3
|
|
89
|
+
blanket_outer: blanket_reference
|
|
90
|
+
divertor: null # void — no FILL card inserted
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Configurations support inheritance: a variant config can set `overrides: baseline.yaml` and override only the fields that differ.
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
The full documentation covers installation, CLI reference, configuration options, best practices, and worked examples:
|
|
98
|
+
|
|
99
|
+
**[fusion4energy.github.io/gitronics](https://fusion4energy.github.io/gitronics/latest/)**
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[EUPL-1.2](LICENSE)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
site_name: Gitronics
|
|
2
2
|
site_description: Build MCNP neutronics models from modular components
|
|
3
|
-
site_url: https://
|
|
4
|
-
repo_url: https://github.com/
|
|
5
|
-
repo_name:
|
|
3
|
+
site_url: https://fusion4energy.github.io/gitronics/latest/
|
|
4
|
+
repo_url: https://github.com/Fusion4Energy/gitronics
|
|
5
|
+
repo_name: Fusion4Energy/gitronics
|
|
6
6
|
edit_uri: edit/main/docs/
|
|
7
7
|
|
|
8
8
|
theme:
|
|
9
9
|
name: material
|
|
10
|
-
logo: logo.png
|
|
11
|
-
favicon: logo.png
|
|
10
|
+
logo: assets/logo.png
|
|
11
|
+
favicon: assets/logo.png
|
|
12
12
|
palette:
|
|
13
13
|
- scheme: default
|
|
14
14
|
primary: deep purple
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
use crate::project_manager::ProjectManager;
|
|
2
|
-
use crate::types::{
|
|
2
|
+
use crate::types::{CellId, EnvelopeName, FillerName, UniverseId};
|
|
3
3
|
use crate::utils::GitronicsError;
|
|
4
4
|
|
|
5
5
|
use git2::Repository;
|
|
6
6
|
use log::{info, warn};
|
|
7
|
-
use migjorn::{Card, CellParam, DataCard, Model, ParamType};
|
|
7
|
+
use migjorn::{Card, CellCard, CellParam, DataCard, Model, ParamType};
|
|
8
8
|
use regex::Regex;
|
|
9
9
|
use std::{collections::HashMap, path::Path, sync::LazyLock};
|
|
10
10
|
use std::{env, fs};
|
|
@@ -63,8 +63,8 @@ pub fn build_model(config_path: &Path, output_path: &Path) -> Result<(), Gitroni
|
|
|
63
63
|
|
|
64
64
|
// Write model
|
|
65
65
|
let assembled_path = project_manager.output_path().join("assembled.mcnp");
|
|
66
|
+
write_assembled_header(&mut envelope_structure, config_path)?;
|
|
66
67
|
envelope_structure.write_to_file(&assembled_path)?;
|
|
67
|
-
write_assembled_metadata(&project_manager, config_path)?;
|
|
68
68
|
fs::write(output_path.join(".gitignore"), "*\n")?;
|
|
69
69
|
|
|
70
70
|
info!(
|
|
@@ -168,25 +168,37 @@ fn get_universe_id_of_model(model: &Model) -> Result<UniverseId, GitronicsError>
|
|
|
168
168
|
.ok_or_else(|| GitronicsError::FirstCellWithoutUniverseID(FillerName::from(model)))
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
fn
|
|
172
|
-
|
|
171
|
+
fn write_assembled_header(
|
|
172
|
+
assembled_model: &mut Model,
|
|
173
173
|
config_path: &Path,
|
|
174
174
|
) -> Result<(), GitronicsError> {
|
|
175
175
|
let configuration = config_path.display().to_string();
|
|
176
176
|
let date_time = chrono::Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
|
|
177
177
|
let gitronics_version = env!("CARGO_PKG_VERSION");
|
|
178
178
|
let commit_hash = get_hash_of_project();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
179
|
+
|
|
180
|
+
let banner = format!(
|
|
181
|
+
"C ============================================================
|
|
182
|
+
C Built by gitronics v{gitronics_version}
|
|
183
|
+
C Configuration : {configuration}
|
|
184
|
+
C Git commit : {commit_hash}
|
|
185
|
+
C Date / time : {date_time}
|
|
186
|
+
C ============================================================"
|
|
187
|
+
);
|
|
188
|
+
let new_card_text = format!(
|
|
189
|
+
"{banner}\n{}",
|
|
190
|
+
assembled_model
|
|
191
|
+
.cells
|
|
192
|
+
.first()
|
|
193
|
+
.map(|c| c.original_text())
|
|
194
|
+
.unwrap_or_default()
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
let banner_card = CellCard::try_from(new_card_text.as_str())
|
|
198
|
+
.expect("Adding comments as header should not fail");
|
|
199
|
+
|
|
200
|
+
// Replace the first cell (previously a comment placeholder) with the banner card
|
|
201
|
+
assembled_model.cells[0] = banner_card;
|
|
190
202
|
Ok(())
|
|
191
203
|
}
|
|
192
204
|
|
|
@@ -4,7 +4,7 @@ use crate::types::{EnvelopeName, FileName, FillerName};
|
|
|
4
4
|
use crate::utils::{GitronicsError, get_file_paths};
|
|
5
5
|
use std::collections::HashMap;
|
|
6
6
|
use std::collections::hash_map::Entry;
|
|
7
|
-
use std::fs::
|
|
7
|
+
use std::fs::create_dir_all;
|
|
8
8
|
use std::path::PathBuf;
|
|
9
9
|
|
|
10
10
|
mod load_metadata;
|
|
@@ -102,7 +102,7 @@ fn index_project_files(
|
|
|
102
102
|
return Err(GitronicsError::DuplicateFileName(entry.key().clone()));
|
|
103
103
|
}
|
|
104
104
|
Entry::Vacant(entry) => {
|
|
105
|
-
entry.insert(
|
|
105
|
+
entry.insert(dunce::canonicalize(path)?);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -11,15 +11,6 @@ use indexmap::IndexMap;
|
|
|
11
11
|
use migjorn::Model;
|
|
12
12
|
use serde::{Deserialize, Serialize};
|
|
13
13
|
|
|
14
|
-
/// Metadata associated with an assembled model
|
|
15
|
-
#[derive(Debug, Serialize, Deserialize)]
|
|
16
|
-
pub struct AssembledMetadata {
|
|
17
|
-
pub configuration: String,
|
|
18
|
-
pub date_time: String,
|
|
19
|
-
pub gitronics_version: String,
|
|
20
|
-
pub git_commit_hash: String,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
/// Metadata associated with a filler model, describing how it should be placed.
|
|
24
15
|
#[derive(Debug, Serialize, Deserialize)]
|
|
25
16
|
pub struct FillerMetadata {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gitronics-0.5.4 → gitronics-0.5.6}/example_project/assessment_specific/filler_model_3.metadata
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/fine_mesh.tally
RENAMED
|
File without changes
|
{gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/data_cards/materials.mat
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gitronics-0.5.4 → gitronics-0.5.6}/example_project/reference_model/envelope_structure.metadata
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|