smolpy 1.8.2.dev10__tar.gz → 1.9.1.dev4__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 (145) hide show
  1. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/ci.yml +21 -0
  2. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/dev-build.yml +1 -0
  3. smolpy-1.9.1.dev4/.github/workflows/docker-image.yml +153 -0
  4. smolpy-1.9.1.dev4/.github/workflows/ns3-base.yml +86 -0
  5. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/publish.yml +15 -1
  6. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/release.yml +1 -0
  7. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/PKG-INFO +12 -1
  8. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/README.md +11 -0
  9. smolpy-1.9.1.dev4/docker/Dockerfile +36 -0
  10. smolpy-1.9.1.dev4/docker/Dockerfile.dockerignore +3 -0
  11. smolpy-1.9.1.dev4/docker/ns3-base/Dockerfile +50 -0
  12. smolpy-1.9.1.dev4/docker/ns3-base/smoke.cc +92 -0
  13. smolpy-1.9.1.dev4/docker/smoke.smol +30 -0
  14. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0004-execution-backends.md +43 -6
  15. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +1 -1
  16. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/dsl-reference.md +1 -0
  17. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/roadmap.md +10 -0
  18. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/backends.py +75 -1
  19. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/cli.py +1 -1
  20. smolpy-1.9.1.dev4/src/smolpy/ns3/__init__.py +302 -0
  21. smolpy-1.9.1.dev4/src/smolpy/ns3/cpp/smol-ns3.cc +982 -0
  22. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/equivalence/scenarios.py +40 -0
  23. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_backends.py +8 -4
  24. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_batch.py +1 -1
  25. smolpy-1.9.1.dev4/tests/test_ns3.py +127 -0
  26. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/docs.yml +0 -0
  27. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/github-release.yml +0 -0
  28. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.github/workflows/rust-wheels.yml +0 -0
  29. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/.gitignore +0 -0
  30. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/LICENSE +0 -0
  31. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/__init__.py +0 -0
  32. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/__main__.py +0 -0
  33. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  34. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  35. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  36. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  37. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  38. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  39. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  40. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/runner.py +0 -0
  41. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/scenarios.py +0 -0
  42. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/benchmarks/worker.py +0 -0
  43. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0001-protocol-package-structure.md +0 -0
  44. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  45. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0003-smol-external-dsl.md +0 -0
  46. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0005-profinet-rt.md +0 -0
  47. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  48. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  49. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  50. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  51. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/benchmarks.md +0 -0
  52. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/dashboard.md +0 -0
  53. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/examples.md +0 -0
  54. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/index.md +0 -0
  55. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/language-reference.md +0 -0
  56. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/modbus.md +0 -0
  57. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/model-semantics.md +0 -0
  58. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/mqtt.md +0 -0
  59. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/profinet.md +0 -0
  60. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/scenario-model.md +0 -0
  61. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/docs/simulation-engine.md +0 -0
  62. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/README.md +0 -0
  63. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example.py +0 -0
  64. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example.smol +0 -0
  65. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_10_clients.py +0 -0
  66. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_12_clients.py +0 -0
  67. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_20_clients.py +0 -0
  68. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_file_transfer.py +0 -0
  69. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_modbus.py +0 -0
  70. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_mqtt.py +0 -0
  71. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_profinet.py +0 -0
  72. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_profinet.smol +0 -0
  73. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_staggered_transfer.py +0 -0
  74. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/examples/example_two_tier.py +0 -0
  75. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/mkdocs.yml +0 -0
  76. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/pyproject.toml +0 -0
  77. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/Cargo.lock +0 -0
  78. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/Cargo.toml +0 -0
  79. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/Cargo.toml +0 -0
  80. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/frames.rs +0 -0
  81. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/lib.rs +0 -0
  82. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/rng.rs +0 -0
  83. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/scenario.rs +0 -0
  84. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/sim.rs +0 -0
  85. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smol-engine/src/timebase.rs +0 -0
  86. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  87. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/README.md +0 -0
  88. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  89. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  90. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  91. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/__init__.py +0 -0
  92. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/_worker.py +0 -0
  93. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/batch.py +0 -0
  94. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/__init__.py +0 -0
  95. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/adapter.py +0 -0
  96. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/batch.py +0 -0
  97. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/link.py +0 -0
  98. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/network.py +0 -0
  99. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/node.py +0 -0
  100. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/core/observation.py +0 -0
  101. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/ethernet/__init__.py +0 -0
  102. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/ethernet/switch.py +0 -0
  103. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/__init__.py +0 -0
  104. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/ast.py +0 -0
  105. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/errors.py +0 -0
  106. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/grammar.lark +0 -0
  107. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/interpreter.py +0 -0
  108. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/lang/transformer.py +0 -0
  109. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/modbus/__init__.py +0 -0
  110. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/modbus/slave.py +0 -0
  111. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/__init__.py +0 -0
  112. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/frames.py +0 -0
  113. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/scenario.py +0 -0
  114. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/streams.py +0 -0
  115. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/timebase.py +0 -0
  116. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/model/validate.py +0 -0
  117. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/mqtt/__init__.py +0 -0
  118. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/mqtt/broker.py +0 -0
  119. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/profinet/__init__.py +0 -0
  120. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/profinet/device.py +0 -0
  121. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/sim/__init__.py +0 -0
  122. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/sim/engine.py +0 -0
  123. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/stats.py +0 -0
  124. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/viz/__init__.py +0 -0
  125. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/viz/dashboard.py +0 -0
  126. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/src/smolpy/viz/text_dashboard.py +0 -0
  127. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/__init__.py +0 -0
  128. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/equivalence/__init__.py +0 -0
  129. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/equivalence/harness.py +0 -0
  130. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/equivalence/test_equivalence.py +0 -0
  131. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/equivalence/test_rust_timebase.py +0 -0
  132. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_benchmarks.py +0 -0
  133. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_cli.py +0 -0
  134. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_dsl.py +0 -0
  135. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_engine_ir.py +0 -0
  136. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_lang.py +0 -0
  137. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_model.py +0 -0
  138. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_profinet.py +0 -0
  139. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_semantics.py +0 -0
  140. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_simulation.py +0 -0
  141. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_stats.py +0 -0
  142. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_sweep.py +0 -0
  143. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_timebase.py +0 -0
  144. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/tests/test_validate.py +0 -0
  145. {smolpy-1.8.2.dev10 → smolpy-1.9.1.dev4}/uv.lock +0 -0
@@ -100,3 +100,24 @@ jobs:
100
100
 
101
101
  - name: Equivalence with SimPy (bit for bit)
102
102
  run: uv run --no-sync pytest tests/equivalence tests/test_backends.py -v --tb=short
103
+
104
+ ns3:
105
+ name: ns-3 backend
106
+ runs-on: ubuntu-latest
107
+ # the pinned ns-3 build (ns3-base.yml): NS3_HOME is set, g++ is there
108
+ container: ghcr.io/jwszolek/smolpy-ns3-base:3.49
109
+
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+ with:
113
+ fetch-depth: 0 # hatch-vcs reads the version from git
114
+
115
+ - name: Install smolpy
116
+ run: python -m pip install --quiet --root-user-action=ignore -e . pytest
117
+
118
+ # makes sure the tests below run the ns3 backend instead of skipping it
119
+ - name: Check that the ns3 backend is installed
120
+ run: python -c "from smolpy import backends; backends.get('ns3'); print(backends.installed())"
121
+
122
+ - name: Equivalence with SimPy
123
+ run: python -m pytest tests/equivalence tests/test_ns3.py -k ns3 -v --tb=short
@@ -28,3 +28,4 @@ jobs:
28
28
  permissions:
29
29
  id-token: write # PyPI trusted publishing
30
30
  contents: write # the GitHub pre-release
31
+ packages: write # granted because publish.yml's image job asks for it; it runs at releases only
@@ -0,0 +1,153 @@
1
+ name: Docker image
2
+
3
+ # The image without ns-3, ghcr.io/jwszolek/smolpy (ADR-0004, Container
4
+ # images): Python, smolpy and smolpy-engine-rs for linux/amd64 and
5
+ # linux/arm64, installed from the wheels of one version. Every image is tested
6
+ # before anything is pushed: the wheel smoke test (bit-exact with SimPy) and a
7
+ # .smol run through the CLI.
8
+ #
9
+ # - Called by publish.yml at a release, once both packages are on PyPI: uses
10
+ # the files of the same run and pushes <version> and latest.
11
+ # - On a pull request that touches the image: builds the wheels here, for
12
+ # linux/amd64 only, tests that image and pushes nothing.
13
+
14
+ on:
15
+ pull_request:
16
+ paths:
17
+ - "docker/Dockerfile*"
18
+ - "docker/smoke.smol"
19
+ - ".github/workflows/docker-image.yml"
20
+ workflow_call:
21
+ inputs:
22
+ version:
23
+ description: The release version, e.g. 1.9.0
24
+ required: true
25
+ type: string
26
+ ref:
27
+ description: The release tag, e.g. v1.9.0
28
+ required: true
29
+ type: string
30
+
31
+ jobs:
32
+ image:
33
+ name: ${{ inputs.version && format('Image {0}', inputs.version) || 'Image (test build)' }}
34
+ runs-on: ubuntu-latest
35
+ permissions:
36
+ contents: read
37
+ packages: write # push to ghcr.io
38
+
39
+ env:
40
+ IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy
41
+ RELEASE: ${{ inputs.version && 'true' || 'false' }} # no inputs on a pull request
42
+
43
+ steps:
44
+ - uses: actions/checkout@v4
45
+ with:
46
+ ref: ${{ inputs.ref }}
47
+ fetch-depth: 0 # hatch-vcs numbers a test build from git
48
+
49
+ # --- a release: the files the calling run has published ---
50
+
51
+ - name: Download smolpy
52
+ if: ${{ env.RELEASE == 'true' }}
53
+ uses: actions/download-artifact@v4
54
+ with:
55
+ name: dist
56
+ path: dist/
57
+
58
+ - name: Download smolpy-engine-rs
59
+ if: ${{ env.RELEASE == 'true' }}
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ pattern: engine-*
63
+ merge-multiple: true
64
+ path: dist/
65
+
66
+ # --- a pull request: both wheels built here, with one version ---
67
+
68
+ - name: Install uv
69
+ if: ${{ env.RELEASE != 'true' }}
70
+ uses: astral-sh/setup-uv@v4
71
+ with:
72
+ version: "latest"
73
+
74
+ - name: Build smolpy and number the engine alike
75
+ if: ${{ env.RELEASE != 'true' }}
76
+ run: |
77
+ uv build --wheel
78
+ wheels=(dist/smolpy-*.whl) # smolpy-<version>-py3-none-any.whl
79
+ VERSION=$(basename "${wheels[0]}" | cut -d- -f2)
80
+ CARGO_VERSION=$(echo "$VERSION" | sed -E 's/\.dev([0-9]+)$/-dev.\1/')
81
+ sed -i "s/^dynamic = \[\"version\"\]$/version = \"$VERSION\"/" rust/smolpy-engine-rs/pyproject.toml
82
+ sed -i "s/^version = \"[^\"]*\"$/version = \"$CARGO_VERSION\"/" rust/Cargo.toml
83
+ echo "Test build of version $VERSION"
84
+
85
+ - name: Build smolpy-engine-rs
86
+ if: ${{ env.RELEASE != 'true' }}
87
+ uses: PyO3/maturin-action@v1
88
+ with:
89
+ target: x86_64
90
+ manylinux: auto
91
+ args: --release --out dist -m rust/smolpy-engine-rs/Cargo.toml
92
+
93
+ # --- the image ---
94
+
95
+ - name: Version
96
+ id: v
97
+ env:
98
+ VERSION: ${{ inputs.version }}
99
+ run: |
100
+ if [ -z "$VERSION" ]; then
101
+ wheels=(dist/smolpy-*.whl)
102
+ VERSION=$(basename "${wheels[0]}" | cut -d- -f2)
103
+ fi
104
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
105
+ ls dist/
106
+
107
+ - name: Set up QEMU, for linux/arm64
108
+ if: ${{ env.RELEASE == 'true' }}
109
+ uses: docker/setup-qemu-action@v3
110
+
111
+ - uses: docker/setup-buildx-action@v3
112
+
113
+ - name: Build and test each platform
114
+ env:
115
+ VERSION: ${{ steps.v.outputs.version }}
116
+ PLATFORMS: ${{ env.RELEASE == 'true' && 'linux/amd64 linux/arm64' || 'linux/amd64' }}
117
+ run: |
118
+ for platform in $PLATFORMS; do
119
+ echo "::group::$platform"
120
+ docker buildx build --platform "$platform" --load \
121
+ --build-arg VERSION="$VERSION" -f docker/Dockerfile -t smolpy:test .
122
+ docker run --rm --platform "$platform" smolpy:test --help
123
+ # the wheel smoke test: bit-exact with SimPy on this platform
124
+ docker run --rm --platform "$platform" -v "$PWD/rust/smolpy-engine-rs:/test:ro" \
125
+ --entrypoint python smolpy:test /test/smoke_test.py
126
+ # the CLI, as a user runs it, writing to the mounted directory
127
+ mkdir -p out && chmod 777 out
128
+ cp docker/smoke.smol out/
129
+ docker run --rm --platform "$platform" -v "$PWD/out:/work" \
130
+ smolpy:test run smoke.smol --backend rust -o results.csv
131
+ grep -q "pn_latency:plc" out/results.csv
132
+ rm -rf out
133
+ echo "::endgroup::"
134
+ done
135
+
136
+ - name: Log in to ghcr.io
137
+ if: ${{ env.RELEASE == 'true' }}
138
+ uses: docker/login-action@v3
139
+ with:
140
+ registry: ghcr.io
141
+ username: ${{ github.actor }}
142
+ password: ${{ secrets.GITHUB_TOKEN }}
143
+
144
+ # the platforms tested above, rebuilt from the build cache
145
+ - name: Push
146
+ if: ${{ env.RELEASE == 'true' }}
147
+ env:
148
+ VERSION: ${{ steps.v.outputs.version }}
149
+ run: |
150
+ docker buildx build --platform linux/amd64,linux/arm64 --push \
151
+ --build-arg VERSION="$VERSION" -f docker/Dockerfile \
152
+ -t "$IMAGE:$VERSION" -t "$IMAGE:latest" .
153
+ echo "Pushed $IMAGE:$VERSION and $IMAGE:latest" >> "$GITHUB_STEP_SUMMARY"
@@ -0,0 +1,86 @@
1
+ name: ns-3 base image
2
+
3
+ # ghcr.io/jwszolek/smolpy-ns3-base:<ns-3 version> (ADR-0004, Container
4
+ # images): the pinned ns-3 release, built once. It is rebuilt only when its
5
+ # Dockerfile changes, which is how the pinned release changes, so releases
6
+ # never build ns-3. linux/amd64 for now; linux/arm64 is to follow on a native
7
+ # runner, as an emulated build of ns-3 would take hours.
8
+ #
9
+ # Every build is tested before it is pushed: a scratch program, as the ns-3
10
+ # backend's generated scenarios will be, built and run against it.
11
+ #
12
+ # - On a pull request that changes it: build and test, push nothing.
13
+ # - After the merge to main, or run by hand: build, test and push.
14
+
15
+ on:
16
+ push:
17
+ branches:
18
+ - main
19
+ paths:
20
+ - "docker/ns3-base/**"
21
+ - ".github/workflows/ns3-base.yml"
22
+ pull_request:
23
+ paths:
24
+ - "docker/ns3-base/**"
25
+ - ".github/workflows/ns3-base.yml"
26
+ workflow_dispatch:
27
+
28
+ jobs:
29
+ image:
30
+ name: ns-3 base image
31
+ runs-on: ubuntu-latest
32
+ timeout-minutes: 120
33
+ permissions:
34
+ contents: read
35
+ packages: write # push to ghcr.io
36
+
37
+ env:
38
+ IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy-ns3-base
39
+ PUSH: ${{ github.event_name != 'pull_request' }}
40
+
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: The pinned ns-3 release
45
+ id: v
46
+ run: |
47
+ VERSION=$(sed -nE 's/^ARG NS3_VERSION=(.+)$/\1/p' docker/ns3-base/Dockerfile)
48
+ test -n "$VERSION"
49
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
50
+ echo "ns-3 $VERSION"
51
+
52
+ - uses: docker/setup-buildx-action@v3
53
+
54
+ # the layers of an unchanged ns-3 build come from the cache
55
+ - name: Build
56
+ uses: docker/build-push-action@v6
57
+ with:
58
+ context: docker/ns3-base
59
+ platforms: linux/amd64
60
+ load: true
61
+ tags: ns3-base:test
62
+ cache-from: type=gha,scope=ns3-base
63
+ cache-to: type=gha,scope=ns3-base,mode=max
64
+
65
+ - name: Test with a scratch program
66
+ run: |
67
+ docker run --rm -v "$PWD/docker/ns3-base/smoke.cc:/opt/ns-3/scratch/smoke.cc:ro" \
68
+ ns3-base:test ./ns3 run smoke
69
+ docker image ls ns3-base:test
70
+
71
+ - name: Log in to ghcr.io
72
+ if: ${{ env.PUSH == 'true' }}
73
+ uses: docker/login-action@v3
74
+ with:
75
+ registry: ghcr.io
76
+ username: ${{ github.actor }}
77
+ password: ${{ secrets.GITHUB_TOKEN }}
78
+
79
+ - name: Push
80
+ if: ${{ env.PUSH == 'true' }}
81
+ env:
82
+ VERSION: ${{ steps.v.outputs.version }}
83
+ run: |
84
+ docker tag ns3-base:test "$IMAGE:$VERSION"
85
+ docker push "$IMAGE:$VERSION"
86
+ echo "Pushed $IMAGE:$VERSION" >> "$GITHUB_STEP_SUMMARY"
@@ -4,7 +4,8 @@ name: Publish to PyPI
4
4
  #
5
5
  # - Release (a pushed tag v*, or release.yml passing its tag): publishes
6
6
  # smolpy and the smolpy-engine-rs wheels and sdist to PyPI with the tag's
7
- # version, then the GitHub Release with every file.
7
+ # version, then the GitHub Release with every file and the Docker image
8
+ # ghcr.io/jwszolek/smolpy:<version> (docker-image.yml).
8
9
  # - Development build (dev-build.yml, dev: true, after a merge to main):
9
10
  # publishes both to PyPI as X.Y.(Z+1).devN, N commits after the latest tag,
10
11
  # a pre-release that pip installs only with --pre, and replaces the GitHub
@@ -192,6 +193,19 @@ jobs:
192
193
  tag: ${{ needs.version.outputs.tag }}
193
194
  engine: ${{ needs.publish-engine.result == 'success' }}
194
195
 
196
+ image:
197
+ name: Docker image
198
+ needs: [version, publish, publish-engine]
199
+ # from the files just published, so only once both packages are on PyPI
200
+ if: ${{ needs.version.outputs.mode == 'release' }}
201
+ permissions:
202
+ contents: read
203
+ packages: write # push to ghcr.io
204
+ uses: ./.github/workflows/docker-image.yml
205
+ with:
206
+ version: ${{ needs.version.outputs.version }}
207
+ ref: ${{ needs.version.outputs.tag }}
208
+
195
209
  dev-release:
196
210
  name: GitHub pre-release "Development build"
197
211
  needs: [version, publish, publish-engine]
@@ -64,3 +64,4 @@ jobs:
64
64
  permissions:
65
65
  id-token: write # PyPI trusted publishing
66
66
  contents: write # the GitHub Release
67
+ packages: write # the Docker image on ghcr.io
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.8.2.dev10
3
+ Version: 1.9.1.dev4
4
4
  Summary: Network simulation DSL and discrete-event simulator
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -89,6 +89,16 @@ pip install --pre "smolpy[rust]" # the latest development build of main
89
89
  - **Where it is on GitHub.** The [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) pre-release points to its commit.
90
90
  - **Releases proper** are made by hand.
91
91
 
92
+ **Without Python,** from the Docker image of each release, which has SMOLPy and the Rust engine for `linux/amd64` and `linux/arm64`:
93
+
94
+ ```bash
95
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend rust -o results.csv
96
+ ```
97
+
98
+ - The image runs headless: the live dashboard needs a display, so a `.smol` file needs `mode=headless` or `mode=text`.
99
+ - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
100
+ - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
101
+
92
102
  From a clone, for development:
93
103
 
94
104
  ```bash
@@ -472,6 +482,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
472
482
  |---|---|---|---|---|
473
483
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
474
484
  | `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
485
+ | `ns3` (in progress) | ns-3's IPv4/UDP stack, from C++ | Ethernet so far: adapters, switches, constant flows without priorities; bit-exact with SimPy there | slower: each run is an ns-3 process | an ns-3 3.49 build in `NS3_HOME`, e.g. the image `ghcr.io/jwszolek/smolpy-ns3-base:3.49` |
475
486
 
476
487
  ```python
477
488
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -61,6 +61,16 @@ pip install --pre "smolpy[rust]" # the latest development build of main
61
61
  - **Where it is on GitHub.** The [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) pre-release points to its commit.
62
62
  - **Releases proper** are made by hand.
63
63
 
64
+ **Without Python,** from the Docker image of each release, which has SMOLPy and the Rust engine for `linux/amd64` and `linux/arm64`:
65
+
66
+ ```bash
67
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend rust -o results.csv
68
+ ```
69
+
70
+ - The image runs headless: the live dashboard needs a display, so a `.smol` file needs `mode=headless` or `mode=text`.
71
+ - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
72
+ - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
73
+
64
74
  From a clone, for development:
65
75
 
66
76
  ```bash
@@ -444,6 +454,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
444
454
  |---|---|---|---|---|
445
455
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
446
456
  | `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
457
+ | `ns3` (in progress) | ns-3's IPv4/UDP stack, from C++ | Ethernet so far: adapters, switches, constant flows without priorities; bit-exact with SimPy there | slower: each run is an ns-3 process | an ns-3 3.49 build in `NS3_HOME`, e.g. the image `ghcr.io/jwszolek/smolpy-ns3-base:3.49` |
447
458
 
448
459
  ```python
449
460
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -0,0 +1,36 @@
1
+ # SMOLPy with the Rust engine, without ns-3: ghcr.io/jwszolek/smolpy
2
+ # (ADR-0004, Container images). Built by .github/workflows/docker-image.yml.
3
+ #
4
+ # The build context holds only dist/, with the wheels of one version of
5
+ # smolpy and smolpy-engine-rs: a release's own files, or a pull request's.
6
+ # pip picks the engine wheel of the platform being built.
7
+ #
8
+ # docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend rust
9
+
10
+ FROM python:3.12-slim-bookworm
11
+
12
+ ARG VERSION
13
+
14
+ LABEL org.opencontainers.image.title="SMOLPy" \
15
+ org.opencontainers.image.description="Network simulation DSL and discrete-event simulator, with the Rust engine (without ns-3)" \
16
+ org.opencontainers.image.source="https://github.com/jwszolek/SMOLPy" \
17
+ org.opencontainers.image.documentation="https://jwszolek.github.io/SMOLPy/" \
18
+ org.opencontainers.image.licenses="MIT" \
19
+ org.opencontainers.image.version="${VERSION}"
20
+
21
+ # both packages pinned to the version, so pip takes them from dist/; their
22
+ # dependencies come from PyPI
23
+ RUN --mount=type=bind,source=dist,target=/dist \
24
+ test -n "${VERSION}" \
25
+ && pip install --no-cache-dir --find-links /dist \
26
+ "smolpy[rust]==${VERSION}" "smolpy-engine-rs==${VERSION}" \
27
+ && python -c "import smolpy_engine_rs; assert smolpy_engine_rs.__version__ == '${VERSION}'"
28
+
29
+ # not root: files written to the mounted directory belong to uid 1000, or to
30
+ # whoever `docker run --user` names
31
+ RUN useradd --create-home --uid 1000 smolpy
32
+ USER 1000
33
+ WORKDIR /work
34
+
35
+ ENTRYPOINT ["smolpy"]
36
+ CMD ["--help"]
@@ -0,0 +1,3 @@
1
+ # The image is built from the repository root, but needs only the wheels.
2
+ *
3
+ !dist/
@@ -0,0 +1,50 @@
1
+ # The ns-3 base image: ghcr.io/jwszolek/smolpy-ns3-base:<ns-3 version>
2
+ # (ADR-0004, Container images). Built by .github/workflows/ns3-base.yml.
3
+ #
4
+ # It holds the pinned ns-3 release, built once: the release profile, without
5
+ # examples, tests or Python bindings, and only the modules SMOLPy's scenarios
6
+ # need. Not the optimized profile: it compiles with -march=native, for the CPU
7
+ # of the machine that builds the image, which another CPU may not run.
8
+ #
9
+ # The toolchain stays in the image, because the ns-3 backend builds each
10
+ # generated scenario as a scratch program against this build. The SMOLPy
11
+ # image with ns-3, <version>-ns3, is built on top of it at each release.
12
+ #
13
+ # ns-3 is licensed under GPLv2, so this image is distributed under its terms.
14
+
15
+ FROM python:3.12-slim-bookworm
16
+
17
+ # Changing the pinned release: a new version, its tag's commit
18
+ # (git ls-remote https://gitlab.com/nsnam/ns-3-dev.git refs/tags/ns-3.<n>^{})
19
+ # and the image tag in ns3-base.yml follow from these.
20
+ ARG NS3_VERSION=3.49
21
+ ARG NS3_COMMIT=418210e8914e9f6bcb5cddbcc94a2cecb7853b68
22
+ ARG NS3_MODULES="core;network;internet;applications;csma;bridge;traffic-control;stats"
23
+
24
+ LABEL org.opencontainers.image.title="ns-3 ${NS3_VERSION} for SMOLPy" \
25
+ org.opencontainers.image.description="The pinned ns-3 release, built for SMOLPy's ns-3 backend" \
26
+ org.opencontainers.image.source="https://github.com/jwszolek/SMOLPy" \
27
+ org.opencontainers.image.licenses="GPL-2.0-only" \
28
+ org.opencontainers.image.version="${NS3_VERSION}" \
29
+ org.nsnam.ns3.source="https://gitlab.com/nsnam/ns-3-dev/-/tree/ns-${NS3_VERSION}" \
30
+ org.nsnam.ns3.commit="${NS3_COMMIT}"
31
+
32
+ # g++ 12 and CMake 3.25 of Debian 12 meet ns-3.49's minimums (g++ 11.1, CMake 3.25)
33
+ # hadolint ignore=DL3008
34
+ RUN apt-get update \
35
+ && apt-get install -y --no-install-recommends g++ cmake ninja-build git ca-certificates \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ RUN git clone --quiet --depth 1 --branch "ns-${NS3_VERSION}" \
39
+ https://gitlab.com/nsnam/ns-3-dev.git /opt/ns-3 \
40
+ && test "$(git -C /opt/ns-3 rev-parse HEAD)" = "${NS3_COMMIT}" \
41
+ && rm -rf /opt/ns-3/.git
42
+
43
+ WORKDIR /opt/ns-3
44
+ RUN ./ns3 configure --build-profile=release -G Ninja \
45
+ --disable-examples --disable-tests --disable-python-bindings --disable-werror \
46
+ --enable-modules="${NS3_MODULES}" \
47
+ && ./ns3 build
48
+
49
+ ENV NS3_HOME=/opt/ns-3 \
50
+ NS3_VERSION=${NS3_VERSION}
@@ -0,0 +1,92 @@
1
+ // Smoke test of the ns-3 base image (ADR-0004, Container images).
2
+ //
3
+ // Built as a scratch program, as the ns-3 backend's generated scenarios will
4
+ // be: two hosts on CSMA links to a learning bridge, the SMOL wire model of a
5
+ // link (data rate, propagation delay, a 20 B inter-frame gap), neighbour
6
+ // caches filled before the run, and a UDP echo across the bridge. Exits
7
+ // non-zero unless every echo comes back.
8
+ //
9
+ // cp smoke.cc $NS3_HOME/scratch/ && $NS3_HOME/ns3 run smoke
10
+
11
+ #include "ns3/applications-module.h"
12
+ #include "ns3/bridge-module.h"
13
+ #include "ns3/core-module.h"
14
+ #include "ns3/csma-module.h"
15
+ #include "ns3/internet-module.h"
16
+ #include "ns3/network-module.h"
17
+
18
+ #include <iostream>
19
+
20
+ using namespace ns3;
21
+
22
+ static uint32_t g_echoes = 0;
23
+
24
+ static void
25
+ OnEcho(Ptr<const Packet>)
26
+ {
27
+ ++g_echoes;
28
+ }
29
+
30
+ int
31
+ main(int argc, char* argv[])
32
+ {
33
+ const uint32_t packets = 10;
34
+ Time::SetResolution(Time::NS); // the SMOL clock: integer nanoseconds
35
+
36
+ NodeContainer hosts;
37
+ hosts.Create(2);
38
+ Ptr<Node> sw = CreateObject<Node>();
39
+
40
+ // one CSMA channel per link: 100 Mb/s, 10 m at 2e8 m/s
41
+ CsmaHelper csma;
42
+ csma.SetChannelAttribute("DataRate", DataRateValue(DataRate("100Mbps")));
43
+ csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(50)));
44
+
45
+ NetDeviceContainer hostDevices;
46
+ NetDeviceContainer switchPorts;
47
+ for (uint32_t i = 0; i < hosts.GetN(); ++i)
48
+ {
49
+ NetDeviceContainer link = csma.Install(NodeContainer(hosts.Get(i), sw));
50
+ // CSMA attaches with a 12 B gap and no preamble: 20 B at 100 Mb/s
51
+ // stand for both (ADR-0010). The gap is not an attribute, so it is
52
+ // set on each device once it is attached.
53
+ for (uint32_t d = 0; d < link.GetN(); ++d)
54
+ {
55
+ DynamicCast<CsmaNetDevice>(link.Get(d))->SetInterframeGap(NanoSeconds(1600));
56
+ }
57
+ hostDevices.Add(link.Get(0));
58
+ switchPorts.Add(link.Get(1));
59
+ }
60
+ BridgeHelper bridge;
61
+ bridge.Install(sw, switchPorts);
62
+
63
+ InternetStackHelper internet;
64
+ internet.Install(hosts);
65
+ Ipv4AddressHelper ipv4;
66
+ ipv4.SetBase("10.0.0.0", "255.255.255.0");
67
+ Ipv4InterfaceContainer addresses = ipv4.Assign(hostDevices);
68
+ // SMOL models no ARP: the neighbour caches start full, or the first
69
+ // frames would wait up to 10 ms for a jittered request (RequestJitter)
70
+ NeighborCacheHelper neighbours;
71
+ neighbours.PopulateNeighborCache();
72
+
73
+ UdpEchoServerHelper server(9);
74
+ ApplicationContainer serverApp = server.Install(hosts.Get(1));
75
+ serverApp.Start(MilliSeconds(0));
76
+
77
+ UdpEchoClientHelper client(addresses.GetAddress(1), 9);
78
+ client.SetAttribute("MaxPackets", UintegerValue(packets));
79
+ client.SetAttribute("Interval", TimeValue(MilliSeconds(1)));
80
+ client.SetAttribute("PacketSize", UintegerValue(512));
81
+ ApplicationContainer clientApp = client.Install(hosts.Get(0));
82
+ clientApp.Start(MilliSeconds(1));
83
+ Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::UdpEchoClient/Rx",
84
+ MakeCallback(&OnEcho));
85
+
86
+ Simulator::Stop(MilliSeconds(100));
87
+ Simulator::Run();
88
+ Simulator::Destroy();
89
+
90
+ std::cout << "ns-3 smoke test: " << g_echoes << " of " << packets << " echoes" << std::endl;
91
+ return g_echoes == packets ? 0 : 1;
92
+ }
@@ -0,0 +1,30 @@
1
+ # Run by CI in every image it builds: the CLI, a .smol file and the Rust
2
+ # engine, with every protocol, writing its results to the mounted directory.
3
+
4
+ network "image-smoke" {
5
+
6
+ switch sw ports=6
7
+ adapter plc ip=10.0.0.1
8
+ adapter hmi ip=10.0.0.2
9
+ mqtt_broker broker ip=10.0.0.3
10
+ modbus_slave meter ip=10.0.0.4 unit_id=1
11
+ profinet_device io ip=10.0.0.5
12
+
13
+ link plc -- sw speed=100 length=10
14
+ link hmi -- sw speed=100 length=10
15
+ link broker -- sw speed=100 length=10
16
+ link meter -- sw speed=100 length=10
17
+ link io -- sw speed=100 length=10
18
+
19
+ flow plc -> hmi rate=2000 size=512
20
+ poll plc -> meter register=0 count=10 rate=100
21
+ route broker topic="plant/t" -> [hmi]
22
+ publish plc -> broker topic="plant/t" rate=100 qos=1
23
+ control plc -> io cycle=2 inputs=20 outputs=20
24
+
25
+ observe throughput on hmi every=10
26
+ observe modbus_latency on plc every=10
27
+ observe pn_latency on plc every=10
28
+
29
+ simulate duration=100 mode=headless
30
+ }