Skip to content

Commit 70f5861

Browse files
committed
Api Arrival generator migration complete with tests
1 parent a17c528 commit 70f5861

52 files changed

Lines changed: 1333 additions & 1528 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

asyncflow_queue_limit/asyncflow_mm1.ipynb

Lines changed: 66 additions & 56 deletions
Large diffs are not rendered by default.

asyncflow_queue_limit/asyncflow_mmc_split.ipynb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 3,
23+
"execution_count": null,
2424
"id": "b8a94d93",
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
2828
"import sys, importlib\n",
2929
"\n",
30-
"# 1) Svuota tutto ciò che inizia con 'asyncflow' da sys.modules\n",
30+
"\n",
3131
"for m in list(sys.modules):\n",
3232
" if m.startswith(\"asyncflow\"):\n",
3333
" del sys.modules[m]\n",
3434
"\n",
35-
"# 2) Re-importa SOLO le facciate pubbliche (niente import profondi)\n",
35+
"\n",
3636
"from asyncflow import AsyncFlow, SimulationRunner\n",
3737
"from asyncflow.analysis import MMc, ResultsAnalyzer\n",
3838
"from asyncflow.components import (\n",
39-
" Client, Server, Edge, Endpoint, LoadBalancer\n",
39+
" Client, Server, Edge, Endpoint, LoadBalancer, ArrivalsGenerator\n",
4040
")\n",
4141
"from asyncflow.settings import SimulationSettings\n",
42-
"from asyncflow.workload import RqsGenerator\n",
42+
"\n",
4343
"import simpy\n",
4444
"\n"
4545
]
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": 4,
49+
"execution_count": null,
5050
"id": "d1b7ad7d",
5151
"metadata": {},
5252
"outputs": [
@@ -64,10 +64,10 @@
6464
"\n",
6565
"# Public AsyncFlow API\n",
6666
"from asyncflow import AsyncFlow, SimulationRunner, Sweep\n",
67-
"from asyncflow.components import Client, Server, Edge, Endpoint, LoadBalancer\n",
67+
"from asyncflow.components import Client, Server, Edge, Endpoint, LoadBalancer, ArrivalsGenerator\n",
6868
"from asyncflow.settings import SimulationSettings\n",
69-
"from asyncflow.workload import RqsGenerator\n",
70-
"from asyncflow.analysis import MM1, ResultsAnalyzer, SweepAnalyzer, MMc\n",
69+
"from asyncflow.analysis import ResultsAnalyzer, SweepAnalyzer, MMc\n",
70+
"from asyncflow.enums import Distribution\n",
7171
"\n",
7272
"print(\"Imports OK.\")"
7373
]
@@ -128,17 +128,16 @@
128128
},
129129
{
130130
"cell_type": "code",
131-
"execution_count": 5,
131+
"execution_count": null,
132132
"id": "ba93587a",
133133
"metadata": {},
134134
"outputs": [],
135135
"source": [
136136
"def build_payload():\n",
137-
" generator = RqsGenerator(\n",
137+
" generator = ArrivalsGenerator(\n",
138138
" id=\"rqs-1\",\n",
139-
" avg_active_users={\"mean\": 120},\n",
140-
" avg_request_per_minute_per_user={\"mean\": 20},\n",
141-
" user_sampling_window=60,\n",
139+
" lambda_rps=30,\n",
140+
" model=Distribution.POISSON\n",
142141
" )\n",
143142
"\n",
144143
" client = Client(id=\"client-1\")\n",
@@ -189,7 +188,7 @@
189188
"\n",
190189
" payload = (\n",
191190
" AsyncFlow()\n",
192-
" .add_generator(generator)\n",
191+
" .add_arrivals_generator(generator)\n",
193192
" .add_client(client)\n",
194193
" .add_servers(srv1, srv2)\n",
195194
" .add_load_balancer(lb)\n",

src/asyncflow/analysis/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from asyncflow.metrics.simulation_analyzer import ResultsAnalyzer
44
from asyncflow.metrics.sweep_analyzer import SweepAnalyzer
5-
from asyncflow.queue_theory_analysis.mm1 import MM1
65
from asyncflow.queue_theory_analysis.mmc import MMc
76

8-
__all__ = ["MM1", "MMc", "ResultsAnalyzer", "SweepAnalyzer"]
7+
__all__ = ["MMc", "ResultsAnalyzer", "SweepAnalyzer"]

src/asyncflow/builder/asyncflow_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def build_payload(self) -> SimulationPayload:
173173
)
174174

175175
return SimulationPayload.model_validate({
176-
"rqs_input": self._generator,
176+
"arrivals": self._arrivals,
177177
"topology_graph": graph,
178178
"sim_settings": self._sim_settings,
179179
"events": self._events or None,

src/asyncflow/components/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Public components: re-exports Pydantic schemas (topology)."""
22
from __future__ import annotations
33

4+
from asyncflow.schemas.arrivals.generator import ArrivalsGenerator
45
from asyncflow.schemas.events.injection import EventInjection
56
from asyncflow.schemas.topology.edges import Edge
67
from asyncflow.schemas.topology.endpoint import Endpoint
@@ -12,6 +13,7 @@
1213
)
1314

1415
__all__ = [
16+
"ArrivalsGenerator",
1517
"Client",
1618
"Edge",
1719
"Endpoint",

src/asyncflow/enums/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Public enums used in scenario definitions."""
22

3-
from asyncfow.config.enums import (
3+
from asyncflow.config.enums import (
44
Distribution,
55
EndpointStepCPU,
66
EndpointStepIO,

src/asyncflow/metrics/sweep_analyzer.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
SweepAnalyzer — build plots from a sweep over *mean concurrent users*.
2+
SweepAnalyzer — build plots from a sweep over *mean rps*.
33
44
Global
55
------
@@ -70,7 +70,7 @@ class ServerPoint:
7070

7171
class SweepAnalyzer:
7272
"""
73-
Build plots from a sweep over *mean concurrent users*.
73+
Build plots from a sweep over *mean rps*.
7474
7575
Input
7676
-----
@@ -246,39 +246,39 @@ def _collect_servers(self) -> None:
246246
# ──────────────────────────────────────────────────────────────────
247247

248248
def plot_global_throughput(self, ax: Axes) -> None:
249-
"""Plot mean throughput (RPS) vs. mean concurrent users."""
249+
"""Plot mean throughput (RPS) vs. mean rps."""
250250
self._ensure_global_collected()
251251
pts = self._global_points
252252
xs = [p.users for p in pts]
253253
ys = [p.lambda_rps for p in pts]
254254
ax.plot(xs, ys, marker="o")
255-
ax.set_title("Throughput (mean RPS) vs. concurrent users")
256-
ax.set_xlabel("Mean concurrent users")
255+
ax.set_title("Throughput (mean RPS) vs. mean Lambda_rps")
256+
ax.set_xlabel("mean rps")
257257
ax.set_ylabel("RPS")
258258
ax.grid(visible=True, alpha=0.3)
259259

260260
def plot_global_latency(self, ax: Axes) -> None:
261-
"""Plot mean system time (W) vs. mean concurrent users."""
261+
"""Plot mean system time (W) vs. mean rps."""
262262
self._ensure_global_collected()
263263
pts = self._global_points
264264
xs = [p.users for p in pts]
265265
ys = [p.W for p in pts]
266266
ax.plot(xs, ys, marker="o")
267-
ax.set_title("Mean system time (W) vs. concurrent users")
268-
ax.set_xlabel("Mean concurrent users")
267+
ax.set_title("Mean system time (W) vs. mean Lambda_rps")
268+
ax.set_xlabel("mean rps")
269269
ax.set_ylabel("W (seconds)")
270270
ax.grid(visible=True, alpha=0.3)
271271

272272
def plot_global_latency_percentiles(self, ax: Axes) -> None:
273-
"""Plot P50, P95, P99 latency vs. mean concurrent users."""
273+
"""Plot P50, P95, P99 latency vs. mean rps."""
274274
self._ensure_global_collected()
275275
pts = self._global_points
276276
xs = [p.users for p in pts]
277277
ax.plot(xs, [p.p50 for p in pts], marker="o", label="P50")
278278
ax.plot(xs, [p.p95 for p in pts], marker="o", label="P95")
279279
ax.plot(xs, [p.p99 for p in pts], marker="o", label="P99")
280-
ax.set_title("Latency percentiles vs. concurrent users")
281-
ax.set_xlabel("Mean concurrent users")
280+
ax.set_title("Latency percentiles vs. mean Lambda_rps")
281+
ax.set_xlabel("mean rps")
282282
ax.set_ylabel("Latency (seconds)")
283283
ax.legend()
284284
ax.grid(visible=True, alpha=0.3)
@@ -344,8 +344,8 @@ def plot_server_utilization_overlay(
344344
xs = [p.users for p in pts]
345345
ys = [p.rho for p in pts]
346346
ax.plot(xs, ys, marker="o", label=sid)
347-
ax.set_title("Server utilization (rho) vs. concurrent users")
348-
ax.set_xlabel("Mean concurrent users")
347+
ax.set_title("Server utilization (rho) vs. mean Lambda_rps")
348+
ax.set_xlabel("mean rps")
349349
ax.set_ylabel("rho")
350350
if ids:
351351
ax.legend()
@@ -366,8 +366,8 @@ def plot_server_waiting_time_overlay(
366366
xs = [p.users for p in pts]
367367
ys = [p.Wq for p in pts]
368368
ax.plot(xs, ys, marker="o", label=sid)
369-
ax.set_title("Server waiting time (Wq) vs. concurrent users")
370-
ax.set_xlabel("Mean concurrent users")
369+
ax.set_title("Server waiting time (Wq) vs. mean Lambda_rps")
370+
ax.set_xlabel("mean rps")
371371
ax.set_ylabel("Wq (seconds)")
372372
if ids:
373373
ax.legend()
@@ -388,8 +388,8 @@ def plot_server_service_rate_overlay(
388388
xs = [p.users for p in pts]
389389
ys = [p.mu_rps for p in pts]
390390
ax.plot(xs, ys, marker="o", label=sid)
391-
ax.set_title("Server service rate (mu) vs. concurrent users")
392-
ax.set_xlabel("Mean concurrent users")
391+
ax.set_title("Server service rate (mu) vs. mean Lambda_rps")
392+
ax.set_xlabel("mean rps")
393393
ax.set_ylabel("mu (1/s)")
394394
if ids:
395395
ax.legend()
@@ -410,8 +410,8 @@ def plot_server_throughput_overlay(
410410
xs = [p.users for p in pts]
411411
ys = [p.lambda_rps for p in pts]
412412
ax.plot(xs, ys, marker="o", label=sid)
413-
ax.set_title("Server throughput (lambda) vs. concurrent users")
414-
ax.set_xlabel("Mean concurrent users")
413+
ax.set_title("Server throughput (lambda) vs. mean Lambda_rps")
414+
ax.set_xlabel("mean rps")
415415
ax.set_ylabel("lambda (1/s)")
416416
if ids:
417417
ax.legend()
@@ -428,8 +428,8 @@ def plot_server_latency_overlay(
428428
xs = [p.users for p in pts]
429429
ys = [p.server_latency_mean_s for p in pts]
430430
ax.plot(xs, ys, marker="o", label=sid)
431-
ax.set_title("Server latency (waiting+service) vs. concurrent users")
432-
ax.set_xlabel("Mean concurrent users")
431+
ax.set_title("Server latency (waiting+service) vs. mean Lambda_rps")
432+
ax.set_xlabel("mean rps")
433433
ax.set_ylabel("Server latency (s)")
434434
if ids:
435435
ax.legend()

0 commit comments

Comments
 (0)