Skip to content

Conversation

@GioeleB00
Copy link
Collaborator

List of changes and new features

  • Added server runtime
  • Added Resource registry
  • Added client runtime
  • README update
  • Improved and update documentation
  • Folder refactor

@GioeleB00 GioeleB00 requested a review from Copilot July 24, 2025 15:44
Copy link
Contributor

Copilot AI left a 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 a major architecture refactor introducing client-server runtime capabilities with comprehensive folder reorganization. The changes establish a complete simulation runtime system with resource management, actor-based components, and improved test coverage.

  • Complete migration from old state management to new RequestState and Hop system
  • Introduction of runtime actors (Server, Client, Edge, RqsGenerator) with SimPy-based concurrency
  • Implementation of resource registry for CPU/RAM container management

Reviewed Changes

Copilot reviewed 38 out of 44 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/test_state.py Removed old RequestState tests (replaced by new runtime tests)
tests/unit/runtime/test_rqs_state.py Added comprehensive tests for new RequestState and Hop classes
tests/unit/runtime/engine/ Added test suite for all runtime actors (server, client, edge, generator)
tests/unit/resources/ Added tests for resource registry and server container management
src/app/runtime/ New runtime package with actors and state management
src/app/resources/ New resource management package for SimPy containers
src/app/schemas/ Updated import paths and added id field to RqsGeneratorInput
documentation/ Updated architecture documentation and added runtime guides
Comments suppressed due to low confidence (2)

tests/unit/schemas/test_requests_generator_input.py:32

  • Inconsistent spacing around assignment operator. Should be 'id="gen-1",' without the extra space before the equals sign.
    assert cfg.variance is None

src/app/runtime/actors/edge.py:28

  • [nitpick] The target_box parameter should be typed more specifically. Consider using simpy.Store[RequestState] for better type safety.
    def __init__(

self.server_config = server_config
self.out_edge = out_edge
self.server_box = server_box
self.rng = rng or np.random.default_rng()
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider making the RNG parameter required rather than optional with a default. This would make testing more deterministic and explicit about randomness sources.

Suggested change
self.rng = rng or np.random.default_rng()
self.rng = rng

Copilot uses AI. Check for mistakes.
# by checking the previous node (-2 the previous component is an edge)
# we are able to understand if the request should be elaborated
# when the type is Generator, or the request is completed, in this case
# the client is the target and the previous node type is not a rqs generator
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is fragile as noted in the documentation. Accessing history[-2] without bounds checking could raise IndexError if history has fewer than 2 elements.

Suggested change
# the client is the target and the previous node type is not a rqs generator
# the client is the target and the previous node type is not a rqs generator
if len(state.history) < 2:
# Skip processing if there are not enough history entries
continue

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +91
total_ram = sum(
step.step_operation[StepOperation.NECESSARY_RAM]
for step in selected_endpoint.steps
if isinstance(step.kind, EndpointStepRAM)
)
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Computing total RAM for every request could be inefficient. Consider caching this calculation per endpoint if endpoints are reused frequently.

Suggested change
total_ram = sum(
step.step_operation[StepOperation.NECESSARY_RAM]
for step in selected_endpoint.steps
if isinstance(step.kind, EndpointStepRAM)
)
# Retrieve precomputed RAM requirements from the cache
total_ram = self.ram_cache[selected_endpoint]

Copilot uses AI. Check for mistakes.
@GioeleB00 GioeleB00 merged commit 13d31d6 into develop Jul 24, 2025
2 checks passed
@GioeleB00 GioeleB00 deleted the features/client-server-runtime branch July 24, 2025 15:48
GioeleB00 added a commit that referenced this pull request Aug 17, 2025
* setting up the branch

* minor correction

* minor changes

* improved script for linux

* minor change

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* Features/event generator (#1)

* setting up the generator

* poisson-poisson requests sampling

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* changes

* refactor for event generator

* added gaussian truncated generator and unit tests for helpers

* imprved documentantion and simulation time handling

* simulation start with the vent generator

* small refactor + tests for the generation of events

* minor changes

* Update src/app/schemas/simulation_input.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/sampler/test_sampler_helper.py

Co-authored-by: Copilot <[email protected]>

* Update scripts/quality-check.sh

Co-authored-by: Copilot <[email protected]>

* Update tests/integration/db_initialization/test_init_models.py

Co-authored-by: Copilot <[email protected]>

* minor changes after PR review

---------

Co-authored-by: Copilot <[email protected]>

* minor changes

* Features/event generator documentation test improvements (#2)

* moving file to correct folder

* Documentation added

* Update requests_generator.md

* test Added, introduced constants for the sampling window

* Update tests/unit/sampler/test_poisson_posson.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* README update

* Improved constants management

* Clean and refactor

* Features/request handler endpoint input (#3)

* Introduction of the input structure for endpoints

* Documentation + foundation of topology input

* Improve Step validation, added unit test for the input

* improved documentation for the input

* Features/definition full payload simulation (#4)

* Improved input structure and pytest

* Improved pytest structure accordingly to the new schema

* definition of the metrics to be measured and update of the simulation input

* improved documentations added rationale behind metrics

* improved pytest logic and code coherence

* Update src/app/core/helpers.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/rqs generator runtime (#5)

* definition of state and RqsGeneratorRuntime

* defined edge runtime and more central logic for sampler

* minor changes

* minor changes

* minor bug fixed

* pytest adapted to the new structure, added pytest for rqs_state

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/runtime/test_requests_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* minor changes

---------

Co-authored-by: Copilot <[email protected]>

* Features/client server runtime (#6)

* defined client runtime + tests

* initiated the server runtime plus correction of tghe structure

* code refactor + test added for runtime + documentation

* Update tests/conftest.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/metric sampler and collection (#7)

* defined architecture for the central collector + documentation

* server modification to collect metrics and updated docs

* Completed metric collector for server plus test

* remove web app dependencies and added metrics for rqs latency

* improved docs and improved metric collection

* changes to make the code compatible with new changes

* improved ci against toml changes

* update lock file

* minor change

* Features/metrics elaboration (#8)

* introduction to the analyzer class + tests

* refactor of the analyzer

* Features/load balancer node (#9)

* Added LB structure in the input for the simulation + tests

* introduced LB runtime + documentation

* Added test for LB and small refactor to define the SimRunner

* Features/simulation runner (#10)

* added the first method to the simulation runner

* added methods to handle nodes

* completed simulation runtime + integration test

* Features/integration tests unit tests (#11)

* new integration test + bug fixing

* added integration and unit test

* first tests working

* minor change

* first working example, upgrade docs, upgrade docstrings

* improvements

* path bug fixed

* new readme and guide to build yaml

* Update README.md

* Added pybuilder and unit tests (#12)

* Refactor/change project name plus docs improvement (#13)

* Changed name from fastsim to asyncflow app folder renamed in asyncflow

* improved docs

* minor changes

* Refactor/pypi preparation (#14)

* Reafctor for the folder schemas + defined import for public api

* Defined public api, improved docs

* minor changes

* minor changes

* Features/lb example and docs tutorial (#15)

* minor docs changes

* improved pytoml

* improved docs + LB examples

* sanity ci check

* Ci for main (#16)

* Readme final, docs improved

* Docs improvement, refactor analyzer, example added

* Added scripts for setup, added pytest, improved readme

* Example LB improvements

* CI for main + system tests

* fixing a bug

* bug fixed

---------

Co-authored-by: Copilot <[email protected]>
GioeleB00 added a commit that referenced this pull request Aug 29, 2025
* setting up the branch

* minor correction

* minor changes

* improved script for linux

* minor change

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* Features/event generator (#1)

* setting up the generator

* poisson-poisson requests sampling

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* changes

* refactor for event generator

* added gaussian truncated generator and unit tests for helpers

* imprved documentantion and simulation time handling

* simulation start with the vent generator

* small refactor + tests for the generation of events

* minor changes

* Update src/app/schemas/simulation_input.py



* Update tests/unit/sampler/test_sampler_helper.py


* Update scripts/quality-check.sh


* Update tests/integration/db_initialization/test_init_models.py



* minor changes after PR review

---------



* minor changes

* Features/event generator documentation test improvements (#2)

* moving file to correct folder

* Documentation added

* Update requests_generator.md

* test Added, introduced constants for the sampling window

* Update tests/unit/sampler/test_poisson_posson.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* README update

* Improved constants management

* Clean and refactor

* Features/request handler endpoint input (#3)

* Introduction of the input structure for endpoints

* Documentation + foundation of topology input

* Improve Step validation, added unit test for the input

* improved documentation for the input

* Features/definition full payload simulation (#4)

* Improved input structure and pytest

* Improved pytest structure accordingly to the new schema

* definition of the metrics to be measured and update of the simulation input

* improved documentations added rationale behind metrics

* improved pytest logic and code coherence

* Update src/app/core/helpers.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/rqs generator runtime (#5)

* definition of state and RqsGeneratorRuntime

* defined edge runtime and more central logic for sampler

* minor changes

* minor changes

* minor bug fixed

* pytest adapted to the new structure, added pytest for rqs_state

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/runtime/test_requests_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* minor changes

---------

Co-authored-by: Copilot <[email protected]>

* Features/client server runtime (#6)

* defined client runtime + tests

* initiated the server runtime plus correction of tghe structure

* code refactor + test added for runtime + documentation

* Update tests/conftest.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/metric sampler and collection (#7)

* defined architecture for the central collector + documentation

* server modification to collect metrics and updated docs

* Completed metric collector for server plus test

* remove web app dependencies and added metrics for rqs latency

* improved docs and improved metric collection

* changes to make the code compatible with new changes

* improved ci against toml changes

* update lock file

* minor change

* Features/metrics elaboration (#8)

* introduction to the analyzer class + tests

* refactor of the analyzer

* Features/load balancer node (#9)

* Added LB structure in the input for the simulation + tests

* introduced LB runtime + documentation

* Added test for LB and small refactor to define the SimRunner

* Features/simulation runner (#10)

* added the first method to the simulation runner

* added methods to handle nodes

* completed simulation runtime + integration test

* Features/integration tests unit tests (#11)

* new integration test + bug fixing

* added integration and unit test

* first tests working

* minor change

* first working example, upgrade docs, upgrade docstrings

* improvements

* path bug fixed

* new readme and guide to build yaml

* Update README.md

* Added pybuilder and unit tests (#12)

* Refactor/change project name plus docs improvement (#13)

* Changed name from fastsim to asyncflow app folder renamed in asyncflow

* improved docs

* minor changes

* Refactor/pypi preparation (#14)

* Reafctor for the folder schemas + defined import for public api

* Defined public api, improved docs

* minor changes

* minor changes

* Features/lb example and docs tutorial (#15)

* minor docs changes

* improved pytoml

* improved docs + LB examples

* sanity ci check

* Ci for main (#16)

* Readme final, docs improved

* Docs improvement, refactor analyzer, example added

* Added scripts for setup, added pytest, improved readme

* Example LB improvements

* CI for main + system tests

* fixing a bug

* bug fixed

* version bump

* version bump

* Feature/event injection input (#19)

* Structure defined for the pydantic model representing Event to be injected

* Pydantic validation in the payload for events part 1

* Definition of the input for the events injection part 2

* minor fixes ruff and mypy compliant

* full tests and docs added for input event injection

* fixed minor bugs

* Feature/event injection runtime (#20)

* Events injection for edges part 1

* Logic + docs for the event injection to simulate a server down

* Added pydantic validation + unit + int tests for eventinjection

* added exaple for event inj yaml + builder added int tests

* improved server model + system tests for eventinjection

* ruff small fix

* Refactor/fixing readme small fixes (#21)

* new readme, ci to have pycov badge, comment on server runtime

* small changes

* small fix ci

* fixing ci

* small test fix

---------

Co-authored-by: Copilot <[email protected]>
GioeleB00 added a commit that referenced this pull request Sep 18, 2025
…q measurement, and metrics plumbing (#29)

* setting up the branch

* minor correction

* minor changes

* improved script for linux

* minor change

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* Features/event generator (#1)

* setting up the generator

* poisson-poisson requests sampling

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* changes

* refactor for event generator

* added gaussian truncated generator and unit tests for helpers

* imprved documentantion and simulation time handling

* simulation start with the vent generator

* small refactor + tests for the generation of events

* minor changes

* Update src/app/schemas/simulation_input.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/sampler/test_sampler_helper.py

Co-authored-by: Copilot <[email protected]>

* Update scripts/quality-check.sh

Co-authored-by: Copilot <[email protected]>

* Update tests/integration/db_initialization/test_init_models.py

Co-authored-by: Copilot <[email protected]>

* minor changes after PR review

---------

Co-authored-by: Copilot <[email protected]>

* minor changes

* Features/event generator documentation test improvements (#2)

* moving file to correct folder

* Documentation added

* Update requests_generator.md

* test Added, introduced constants for the sampling window

* Update tests/unit/sampler/test_poisson_posson.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* README update

* Improved constants management

* Clean and refactor

* Features/request handler endpoint input (#3)

* Introduction of the input structure for endpoints

* Documentation + foundation of topology input

* Improve Step validation, added unit test for the input

* improved documentation for the input

* Features/definition full payload simulation (#4)

* Improved input structure and pytest

* Improved pytest structure accordingly to the new schema

* definition of the metrics to be measured and update of the simulation input

* improved documentations added rationale behind metrics

* improved pytest logic and code coherence

* Update src/app/core/helpers.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/rqs generator runtime (#5)

* definition of state and RqsGeneratorRuntime

* defined edge runtime and more central logic for sampler

* minor changes

* minor changes

* minor bug fixed

* pytest adapted to the new structure, added pytest for rqs_state

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/runtime/test_requests_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* minor changes

---------

Co-authored-by: Copilot <[email protected]>

* Features/client server runtime (#6)

* defined client runtime + tests

* initiated the server runtime plus correction of tghe structure

* code refactor + test added for runtime + documentation

* Update tests/conftest.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* Features/metric sampler and collection (#7)

* defined architecture for the central collector + documentation

* server modification to collect metrics and updated docs

* Completed metric collector for server plus test

* remove web app dependencies and added metrics for rqs latency

* improved docs and improved metric collection

* changes to make the code compatible with new changes

* improved ci against toml changes

* update lock file

* minor change

* Features/metrics elaboration (#8)

* introduction to the analyzer class + tests

* refactor of the analyzer

* Features/load balancer node (#9)

* Added LB structure in the input for the simulation + tests

* introduced LB runtime + documentation

* Added test for LB and small refactor to define the SimRunner

* Features/simulation runner (#10)

* added the first method to the simulation runner

* added methods to handle nodes

* completed simulation runtime + integration test

* Features/integration tests unit tests (#11)

* new integration test + bug fixing

* added integration and unit test

* first tests working

* minor change

* first working example, upgrade docs, upgrade docstrings

* improvements

* path bug fixed

* new readme and guide to build yaml

* Update README.md

* Added pybuilder and unit tests (#12)

* Refactor/change project name plus docs improvement (#13)

* Changed name from fastsim to asyncflow app folder renamed in asyncflow

* improved docs

* minor changes

* Refactor/pypi preparation (#14)

* Reafctor for the folder schemas + defined import for public api

* Defined public api, improved docs

* minor changes

* minor changes

* Features/lb example and docs tutorial (#15)

* minor docs changes

* improved pytoml

* improved docs + LB examples

* sanity ci check

* Ci for main (#16)

* Readme final, docs improved

* Docs improvement, refactor analyzer, example added

* Added scripts for setup, added pytest, improved readme

* Example LB improvements

* CI for main + system tests

* fixing a bug

* bug fixed

* version bump

* version bump

* Feature/event injection input (#19)

* Structure defined for the pydantic model representing Event to be injected

* Pydantic validation in the payload for events part 1

* Definition of the input for the events injection part 2

* minor fixes ruff and mypy compliant

* full tests and docs added for input event injection

* fixed minor bugs

* Feature/event injection runtime (#20)

* Events injection for edges part 1

* Logic + docs for the event injection to simulate a server down

* Added pydantic validation + unit + int tests for eventinjection

* added exaple for event inj yaml + builder added int tests

* improved server model + system tests for eventinjection

* ruff small fix

* Refactor/fixing readme small fixes (#21)

* new readme, ci to have pycov badge, comment on server runtime

* small changes

* bump version

* Structure input for multiprocessing, improved tests, improved description (#23)

* better test coverage, edges deterministic, step server random (#24)

* new sim value

* Feature/multi processing event loop 3 (#25)

* added metric for server, added logic to collect them + tests

* add kpi to collect in settings default

* added metric plot for server and tests

* Sweep introduction + MM1 heory vs observation + tests

* analysis for sweep results + tests

* mm1 notebook complete + server latency

* Add M/M/c (split) queue-theory analyzer, RANDOM load-balancer policy, and end-to-end comparison reports (#26)

* mmc split + notebook mmc split + random lb algo

* tests for mmc

* New Api RqsGenerator ---> ArrivalsGenerator (#27)

* changing api per ArrivalsGenerator and implementing distrib for ArrivalRuntime

* Reafctoring API Arrival generator, tests integrations now working

* Api Arrival generator migration complete with tests

* Updated plots

* Added edges without network latency plus tests (#28)

* Implemented fcfs with tests

* Implemented fcfs algo and validation of mmc models Erlang C

* small changes

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants