gitronics 0.5.5__tar.gz → 0.5.7__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.
Files changed (55) hide show
  1. {gitronics-0.5.5 → gitronics-0.5.7}/Cargo.lock +34 -1
  2. {gitronics-0.5.5 → gitronics-0.5.7}/Cargo.toml +3 -1
  3. {gitronics-0.5.5 → gitronics-0.5.7}/PKG-INFO +1 -1
  4. {gitronics-0.5.5 → gitronics-0.5.7}/README.md +5 -5
  5. {gitronics-0.5.5 → gitronics-0.5.7}/mkdocs.yml +2 -2
  6. {gitronics-0.5.5 → gitronics-0.5.7}/src/build_model.rs +19 -0
  7. {gitronics-0.5.5 → gitronics-0.5.7}/src/project_manager.rs +7 -2
  8. {gitronics-0.5.5 → gitronics-0.5.7}/tests/test_example_project.rs +41 -0
  9. gitronics-0.5.5/python/gitronics/__main__.py +0 -3
  10. {gitronics-0.5.5 → gitronics-0.5.7}/.github/workflows/ci.yml +0 -0
  11. {gitronics-0.5.5 → gitronics-0.5.7}/.github/workflows/docs.yml +0 -0
  12. {gitronics-0.5.5 → gitronics-0.5.7}/.github/workflows/release.yml +0 -0
  13. {gitronics-0.5.5 → gitronics-0.5.7}/.gitignore +0 -0
  14. {gitronics-0.5.5 → gitronics-0.5.7}/LICENSE +0 -0
  15. {gitronics-0.5.5/docs → gitronics-0.5.7/docs/assets}/logo.png +0 -0
  16. {gitronics-0.5.5 → gitronics-0.5.7}/docs/best-practices.md +0 -0
  17. {gitronics-0.5.5 → gitronics-0.5.7}/docs/changelog.md +0 -0
  18. {gitronics-0.5.5 → gitronics-0.5.7}/docs/examples.md +0 -0
  19. {gitronics-0.5.5 → gitronics-0.5.7}/docs/getting-started.md +0 -0
  20. {gitronics-0.5.5 → gitronics-0.5.7}/docs/index.md +0 -0
  21. {gitronics-0.5.5 → gitronics-0.5.7}/docs/installation.md +0 -0
  22. {gitronics-0.5.5 → gitronics-0.5.7}/docs/requirements.txt +0 -0
  23. {gitronics-0.5.5 → gitronics-0.5.7}/docs/usage/build.md +0 -0
  24. {gitronics-0.5.5 → gitronics-0.5.7}/docs/usage/configuration.md +0 -0
  25. {gitronics-0.5.5 → gitronics-0.5.7}/docs/usage/migrate.md +0 -0
  26. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/assessment_specific/filler_model_3.mcnp +0 -0
  27. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/assessment_specific/filler_model_3.metadata +0 -0
  28. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/assessment_specific/small_override.yaml +0 -0
  29. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/configurations/valid_configuration.yaml +0 -0
  30. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/output/.gitignore +0 -0
  31. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/data_cards/fine_mesh.tally +0 -0
  32. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/data_cards/materials.mat +0 -0
  33. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/data_cards/my_transform.transform +0 -0
  34. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/data_cards/volumetric_source.source +0 -0
  35. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/envelope_structure.mcnp +0 -0
  36. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/envelope_structure.metadata +0 -0
  37. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/filler_models/filler_model_1.mcnp +0 -0
  38. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/filler_models/filler_model_1.metadata +0 -0
  39. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/filler_models/filler_model_2.mcnp +0 -0
  40. {gitronics-0.5.5 → gitronics-0.5.7}/example_project/reference_model/filler_models/filler_model_2.metadata +0 -0
  41. {gitronics-0.5.5 → gitronics-0.5.7}/pyproject.toml +0 -0
  42. {gitronics-0.5.5 → gitronics-0.5.7}/python/gitronics/__init__.py +0 -0
  43. {gitronics-0.5.5 → gitronics-0.5.7}/python/tests/test_cli_works.py +0 -0
  44. {gitronics-0.5.5 → gitronics-0.5.7}/resources/simple_model.mcnp +0 -0
  45. {gitronics-0.5.5 → gitronics-0.5.7}/src/cli.rs +0 -0
  46. {gitronics-0.5.5 → gitronics-0.5.7}/src/lib.rs +0 -0
  47. {gitronics-0.5.5 → gitronics-0.5.7}/src/main.rs +0 -0
  48. {gitronics-0.5.5 → gitronics-0.5.7}/src/migrate_model.rs +0 -0
  49. {gitronics-0.5.5 → gitronics-0.5.7}/src/model_config.rs +0 -0
  50. {gitronics-0.5.5 → gitronics-0.5.7}/src/project_manager/load_metadata.rs +0 -0
  51. {gitronics-0.5.5 → gitronics-0.5.7}/src/project_manager/load_model_config.rs +0 -0
  52. {gitronics-0.5.5 → gitronics-0.5.7}/src/project_manager/load_project_files.rs +0 -0
  53. {gitronics-0.5.5 → gitronics-0.5.7}/src/python.rs +0 -0
  54. {gitronics-0.5.5 → gitronics-0.5.7}/src/types.rs +0 -0
  55. {gitronics-0.5.5 → gitronics-0.5.7}/src/utils.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,14 +390,16 @@ dependencies = [
384
390
 
385
391
  [[package]]
386
392
  name = "gitronics"
387
- version = "0.5.5"
393
+ version = "0.5.7"
388
394
  dependencies = [
389
395
  "chrono",
390
396
  "clap",
397
+ "dunce",
391
398
  "env_logger",
392
399
  "git2",
393
400
  "indexmap",
394
401
  "log",
402
+ "logtest",
395
403
  "migjorn",
396
404
  "pyo3",
397
405
  "rayon",
@@ -543,6 +551,12 @@ dependencies = [
543
551
  "wasm-bindgen",
544
552
  ]
545
553
 
554
+ [[package]]
555
+ name = "lazy_static"
556
+ version = "1.5.0"
557
+ source = "registry+https://github.com/rust-lang/crates.io-index"
558
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
559
+
546
560
  [[package]]
547
561
  name = "leb128fmt"
548
562
  version = "0.1.0"
@@ -590,6 +604,19 @@ name = "log"
590
604
  version = "0.4.29"
591
605
  source = "registry+https://github.com/rust-lang/crates.io-index"
592
606
  checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
607
+ dependencies = [
608
+ "value-bag",
609
+ ]
610
+
611
+ [[package]]
612
+ name = "logtest"
613
+ version = "2.0.0"
614
+ source = "registry+https://github.com/rust-lang/crates.io-index"
615
+ checksum = "eb3e43a8657c1d64516dcc9db8ca03826a4aceaf89d5ce1b37b59f6ff0e43026"
616
+ dependencies = [
617
+ "lazy_static",
618
+ "log",
619
+ ]
593
620
 
594
621
  [[package]]
595
622
  name = "memchr"
@@ -1024,6 +1051,12 @@ version = "0.2.2"
1024
1051
  source = "registry+https://github.com/rust-lang/crates.io-index"
1025
1052
  checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
1026
1053
 
1054
+ [[package]]
1055
+ name = "value-bag"
1056
+ version = "1.12.0"
1057
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1058
+ checksum = "7ba6f5989077681266825251a52748b8c1d8a4ad098cc37e440103d0ea717fc0"
1059
+
1027
1060
  [[package]]
1028
1061
  name = "vcpkg"
1029
1062
  version = "0.2.15"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "gitronics"
3
- version = "0.5.5"
3
+ version = "0.5.7"
4
4
  edition = "2024"
5
5
  description = "Build MCNP neutronics models from modular components"
6
6
  license = "EUPL-1.2"
@@ -29,6 +29,8 @@ regex = "1.12.3"
29
29
  clap = { version = "4.6.1", features = ["derive"] }
30
30
  indexmap = { version = "2.14.0", features = ["serde"] }
31
31
  git2 = "0.21.0"
32
+ dunce = "1.0.5"
32
33
 
33
34
  [dev-dependencies]
34
35
  tempfile = "3.0"
36
+ logtest = "2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitronics
3
- Version: 0.5.5
3
+ Version: 0.5.7
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="docs/logo.png" alt="Gitronics logo" width="140"/>
2
+ <img src="docs/assets/logo.png" alt="Gitronics logo" width="140"/>
3
3
  <h1>Gitronics</h1>
4
4
  <p><strong>Build MCNP neutronics models from modular, version-controlled components.</strong></p>
5
5
 
@@ -11,7 +11,7 @@
11
11
 
12
12
  ---
13
13
 
14
- Gitronics lets you decompose a monolithic **MCNP** 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.
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
15
 
16
16
  **Full documentation: [fusion4energy.github.io/gitronics](https://fusion4energy.github.io/gitronics/latest/)**
17
17
 
@@ -60,7 +60,7 @@ gitronics migrate --help
60
60
  my_project/
61
61
  ├── configurations/
62
62
  │ ├── baseline.yaml ← declares which fillers go where
63
- │ └── variant_A.yaml ← inherits baseline, overrides selected envelopes
63
+ │ └── variant_A.yaml ← inherits baseline, overrides some fields
64
64
  ├── output/
65
65
  │ └── .gitignore
66
66
  └── reference_model/
@@ -77,7 +77,7 @@ my_project/
77
77
  ## Configuration example
78
78
 
79
79
  ```yaml
80
- project_roots: [..]
80
+ project_roots: [..] # Relative to this file's location
81
81
 
82
82
  envelope_structure: envelope_structure
83
83
  source: dt_plasma
@@ -87,7 +87,7 @@ tallies: [tritium_breeding_ratio]
87
87
  envelopes:
88
88
  blanket_inner: blanket_v3
89
89
  blanket_outer: blanket_reference
90
- divertor: null # void — no FILL card inserted
90
+ divertor: null # void — no FILL card inserted
91
91
  ```
92
92
 
93
93
  Configurations support inheritance: a variant config can set `overrides: baseline.yaml` and override only the fields that differ.
@@ -7,8 +7,8 @@ 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
@@ -6,6 +6,7 @@ use git2::Repository;
6
6
  use log::{info, warn};
7
7
  use migjorn::{Card, CellCard, CellParam, DataCard, Model, ParamType};
8
8
  use regex::Regex;
9
+ use std::collections::HashSet;
9
10
  use std::{collections::HashMap, path::Path, sync::LazyLock};
10
11
  use std::{env, fs};
11
12
 
@@ -82,6 +83,9 @@ fn add_fill_cards_to_envelopes(
82
83
  universe_ids: &HashMap<FillerName, UniverseId>,
83
84
  envelope_structure: &mut Model,
84
85
  ) -> Result<(), GitronicsError> {
86
+ let mut missing_envelopes_in_file: HashSet<EnvelopeName> =
87
+ project_manager.envelopes_in_config().cloned().collect();
88
+
85
89
  for cell in envelope_structure.cells.iter_mut() {
86
90
  let original_text = cell.original_text();
87
91
  let Some(caps) = ENVELOPE_RE.captures(original_text) else {
@@ -105,6 +109,9 @@ fn add_fill_cards_to_envelopes(
105
109
  continue;
106
110
  };
107
111
 
112
+ // Remove the envelope from the set of missing envelopes, as we have found it in the file
113
+ missing_envelopes_in_file.remove(&envelope_name);
114
+
108
115
  // Envelope explicitly set to null in config, so we skip it
109
116
  let Some(filler_name) = env_config.as_ref() else {
110
117
  continue;
@@ -129,6 +136,18 @@ fn add_fill_cards_to_envelopes(
129
136
  .map_err(|e| GitronicsError::InvalidFillCard(fill_card_text, e.to_string()))?,
130
137
  );
131
138
  }
139
+
140
+ if !missing_envelopes_in_file.is_empty() {
141
+ warn!(
142
+ "The following envelopes were defined in the configuration file but not found in the envelope structure file: {}. \
143
+ Please check that the `$ @env:envelope_name` pattern is satisfied.",
144
+ missing_envelopes_in_file
145
+ .into_iter()
146
+ .map(|e| e.to_string())
147
+ .collect::<Vec<_>>()
148
+ .join(", ")
149
+ );
150
+ }
132
151
  Ok(())
133
152
  }
134
153
 
@@ -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::{self, create_dir_all};
7
+ use std::fs::create_dir_all;
8
8
  use std::path::PathBuf;
9
9
 
10
10
  mod load_metadata;
@@ -85,6 +85,11 @@ impl ProjectManager {
85
85
  .get(envelope_name)
86
86
  .and_then(|opt| opt.as_deref()))
87
87
  }
88
+
89
+ /// Returns an iterator over the envelope names defined in the configuration.
90
+ pub fn envelopes_in_config(&self) -> impl Iterator<Item = &EnvelopeName> {
91
+ self.model_config.envelopes().keys()
92
+ }
88
93
  }
89
94
 
90
95
  /// Indexes project files using roots resolved from a loaded configuration.
@@ -102,7 +107,7 @@ fn index_project_files(
102
107
  return Err(GitronicsError::DuplicateFileName(entry.key().clone()));
103
108
  }
104
109
  Entry::Vacant(entry) => {
105
- entry.insert(fs::canonicalize(path)?);
110
+ entry.insert(dunce::canonicalize(path)?);
106
111
  }
107
112
  }
108
113
  }
@@ -1,4 +1,6 @@
1
1
  use gitronics::build_model;
2
+ use log::Level;
3
+ use logtest::Logger;
2
4
  use std::fs;
3
5
  use std::path::{Path, PathBuf};
4
6
  use tempfile::tempdir;
@@ -246,3 +248,42 @@ fn test_filler_first_cell_without_universe_id() {
246
248
  let msg = result.unwrap_err().to_string();
247
249
  assert!(msg.contains("No universe ID found in first cell of filler model"));
248
250
  }
251
+
252
+ #[test]
253
+ fn test_envelopes_in_config_that_dont_exist() {
254
+ let mut logger = Logger::start();
255
+ let dir = tempdir().unwrap();
256
+ let example_project_path = PathBuf::from("example_project/");
257
+ copy_dir(&example_project_path, dir.path()).unwrap();
258
+
259
+ fs::write(
260
+ dir.path().join("configurations/valid_configuration.yaml"),
261
+ "project_roots: [..]
262
+ overrides: null
263
+
264
+ envelope_structure: envelope_structure
265
+ source: volumetric_source
266
+ materials: [materials]
267
+ transformations: [my_transform]
268
+ tallies: [fine_mesh]
269
+ envelopes:
270
+ my_envelope_name_1: filler_model_1
271
+ wrong_envelope_name: filler_model_2
272
+ ",
273
+ )
274
+ .unwrap();
275
+
276
+ build_model(
277
+ &dir.path().join("configurations/valid_configuration.yaml"),
278
+ dir.path().join("out").as_path(),
279
+ )
280
+ .unwrap();
281
+
282
+ let warn_message = "The following envelopes were defined in the configuration file but not found in the envelope structure file";
283
+
284
+ assert!(
285
+ logger.any(|record| {
286
+ record.level() == Level::Warn && record.args().contains(warn_message)
287
+ })
288
+ );
289
+ }
@@ -1,3 +0,0 @@
1
- from gitronics import _cli_main
2
-
3
- _cli_main()
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