Skip to content

Commit 35e59d1

Browse files
authored
Albrja/mic-6483/Update log level (#663)
Albrja/mic-6483/Update log level Update log level to info for step log message - *Category*: Other - *JIRA issue*: https://jira.ihme.washington.edu/browse/MIC-6483
1 parent d5bbcaf commit 35e59d1

File tree

5 files changed

+63
-25
lines changed

5 files changed

+63
-25
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**3.5.5 - 10/14/25**
2+
3+
- Update simulation step log message to info level
4+
15
**3.5.4 - 10/8/25**
26

37
- Sphinx nitpick typing.Union

docs/source/tutorials/boids.rst

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ we can set up our simulation with the following code:
195195
sim = InteractiveContext(
196196
components=[Population()],
197197
configuration={'population': {'population_size': 500}},
198+
logging_verbosity=0,
198199
)
199200
200201
# Peek at the population table
@@ -210,6 +211,7 @@ we can set up our simulation with the following code:
210211
sim = InteractiveContext(
211212
components=[Population()],
212213
configuration={'population': {'population_size': 500}},
214+
logging_verbosity=0,
213215
)
214216

215217
::
@@ -316,6 +318,7 @@ Let's run the simulation with our new component and look again at the population
316318
sim = InteractiveContext(
317319
components=[Population(), Movement()],
318320
configuration={'population': {'population_size': 500}},
321+
logging_verbosity=0,
319322
)
320323
321324
# Peek at the population table
@@ -330,16 +333,21 @@ Let's run the simulation with our new component and look again at the population
330333
sim = InteractiveContext(
331334
components=[Population(), Movement()],
332335
configuration={'population': {'population_size': 500}},
336+
logging_verbosity=0,
333337
)
334338

335-
::
339+
# Peek at the population table
340+
print(sim.get_population().head()[["color", "x", "y", "vx", "vy"]])
341+
342+
.. testoutput::
343+
344+
color x y vx vy
345+
0 red 274.256447 907.889319 -0.396940 0.270696
346+
1 red 388.784077 82.116094 0.392572 -1.693871
347+
2 red 661.272905 303.481468 -0.102927 1.194465
348+
3 red 758.825839 806.284468 0.709814 0.932636
349+
4 blue 574.989313 159.504556 -1.487996 1.428098
336350

337-
tracked color entrance_time vy vx x y
338-
0 True red 2005-07-01 -1.492285 -1.546289 786.157545 686.064077
339-
1 True blue 2005-07-01 0.360843 1.662424 530.867936 545.621217
340-
2 True red 2005-07-01 -0.369045 -1.747372 779.830506 286.461394
341-
3 True red 2005-07-01 -1.479211 0.659691 373.141406 740.640070
342-
4 True red 2005-07-01 1.143885 0.258908 20.787001 878.792517
343351

344352
Our population now has initial position and velocity!
345353
Now, we can take a step forward with ``sim.step()`` and "see" our boids' positions change,
@@ -361,18 +369,22 @@ but their velocity stay the same.
361369
sim = InteractiveContext(
362370
components=[Population(), Movement()],
363371
configuration={'population': {'population_size': 500}},
372+
logging_verbosity=0,
364373
)
365374
sim.step()
366375

367-
::
376+
# Peek at the population table
377+
print(sim.get_population().head()[["color", "x", "y", "vx", "vy"]])
368378

369-
tracked color entrance_time vy vx x y
370-
0 True red 2005-07-01 -1.388859 -1.439121 784.718424 684.675217
371-
1 True blue 2005-07-01 0.360843 1.662424 532.530360 545.982060
372-
2 True red 2005-07-01 -0.369045 -1.747372 778.083134 286.092349
373-
3 True red 2005-07-01 -1.479211 0.659691 373.801097 739.160859
374-
4 True red 2005-07-01 1.143885 0.258908 21.045909 879.936402
379+
.. testoutput::
375380

381+
color x y vx vy
382+
0 red 273.859507 908.160016 -0.396940 0.270696
383+
1 red 389.176649 80.422223 0.392572 -1.693871
384+
2 red 661.169977 304.675933 -0.102927 1.194465
385+
3 red 759.535654 807.217104 0.709814 0.932636
386+
4 blue 573.546355 160.889428 -1.442958 1.384873
387+
376388

377389
Visualizing our population
378390
--------------------------
@@ -406,6 +418,7 @@ We can then visualize our flock with
406418
sim = InteractiveContext(
407419
components=[Population(), Movement()],
408420
configuration={'population': {'population_size': 500}},
421+
logging_verbosity=0,
409422
)
410423
411424
plot_boids(sim, plot_velocity=True)
@@ -418,6 +431,7 @@ We can then visualize our flock with
418431
sim = InteractiveContext(
419432
components=[Population(), Movement()],
420433
configuration={'population': {'population_size': 500}},
434+
logging_verbosity=0,
421435
)
422436
plot_boids(sim, plot_velocity=True)
423437

@@ -517,6 +531,7 @@ For a quick test of our swarming behavior, let's add in these forces and check i
517531
sim = InteractiveContext(
518532
components=[Population(), Movement(), Neighbors(), Separation(), Cohesion(), Alignment()],
519533
configuration={'population': {'population_size': 500}},
534+
logging_verbosity=0,
520535
)
521536
522537
sim.take_steps(100)
@@ -531,6 +546,7 @@ For a quick test of our swarming behavior, let's add in these forces and check i
531546
sim = InteractiveContext(
532547
components=[Population(), Movement(), Neighbors(), Separation(), Cohesion(), Alignment()],
533548
configuration={'population': {'population_size': 500}},
549+
logging_verbosity=0,
534550
)
535551
sim.take_steps(100)
536552
plot_boids(sim, plot_velocity=True)
@@ -562,6 +578,7 @@ Then, try it out like so:
562578
sim = InteractiveContext(
563579
components=[Population(), Movement(), Neighbors(), Separation(), Cohesion(), Alignment()],
564580
configuration={'population': {'population_size': 500}},
581+
logging_verbosity=0,
565582
)
566583
567584
anim = plot_boids_animated(sim)

src/vivarium/examples/boids/movement.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
from vivarium import Component
77
from vivarium.framework.engine import Builder
88
from vivarium.framework.population import SimulantData
9+
from vivarium.framework.resource.resource import Resource
910

1011

1112
class Movement(Component):
1213
##############
1314
# Properties #
1415
##############
15-
configuration_defaults = {
16+
CONFIGURATION_DEFAULTS = {
1617
"field": {
1718
"width": 1000,
1819
"height": 1000,
@@ -22,7 +23,14 @@ class Movement(Component):
2223
},
2324
}
2425

25-
columns_created = ["x", "vx", "y", "vy"]
26+
@property
27+
def columns_created(self) -> list[str]:
28+
return ["x", "y", "vx", "vy"]
29+
30+
@property
31+
def initialization_requirements(self) -> list[str | Resource]:
32+
return [self.randomness]
33+
2634

2735
#####################
2836
# Lifecycle methods #
@@ -34,6 +42,7 @@ def setup(self, builder: Builder) -> None:
3442
self.acceleration = builder.value.register_value_producer(
3543
"acceleration", source=self.base_acceleration
3644
)
45+
self.randomness = builder.randomness.get_stream(self.name)
3746

3847
##################################
3948
# Pipeline sources and modifiers #
@@ -47,14 +56,13 @@ def base_acceleration(self, index: pd.Index[int]) -> pd.DataFrame:
4756
########################
4857

4958
def on_initialize_simulants(self, pop_data: SimulantData) -> None:
50-
count = len(pop_data.index)
5159
# Start randomly distributed, with random velocities
5260
new_population = pd.DataFrame(
5361
{
54-
"x": self.config.field.width * np.random.random(count),
55-
"y": self.config.field.height * np.random.random(count),
56-
"vx": ((2 * np.random.random(count)) - 1) * self.config.movement.max_speed,
57-
"vy": ((2 * np.random.random(count)) - 1) * self.config.movement.max_speed,
62+
"x": self.config.field.width * self.randomness.get_draw(pop_data.index, "x"),
63+
"y": self.config.field.height * self.randomness.get_draw(pop_data.index, "y"),
64+
"vx": ((2 * self.randomness.get_draw(pop_data.index, "vx")) - 1) * self.config.movement.max_speed,
65+
"vy": ((2 * self.randomness.get_draw(pop_data.index, "vy")) - 1) * self.config.movement.max_speed,
5866
},
5967
index=pop_data.index,
6068
)

src/vivarium/examples/boids/population.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,34 @@
44
from vivarium import Component
55
from vivarium.framework.engine import Builder
66
from vivarium.framework.population import SimulantData
7+
from vivarium.framework.resource.resource import Resource
78

89

910
class Population(Component):
1011
##############
1112
# Properties #
1213
##############
13-
configuration_defaults = {
14+
CONFIGURATION_DEFAULTS = {
1415
"population": {
1516
"colors": ["red", "blue"],
1617
}
1718
}
18-
columns_created = ["color", "entrance_time"]
19+
20+
@property
21+
def columns_created(self) -> list[str]:
22+
return ["color", "entrance_time"]
23+
24+
@property
25+
def initialization_requirements(self) -> list[str | Resource]:
26+
return [self.randomness]
1927

2028
#####################
2129
# Lifecycle methods #
2230
#####################
2331

2432
def setup(self, builder: Builder) -> None:
2533
self.colors = builder.configuration.population.colors
34+
self.randomness = builder.randomness.get_stream(self.name)
2635

2736
########################
2837
# Event-driven methods #
@@ -31,7 +40,7 @@ def setup(self, builder: Builder) -> None:
3140
def on_initialize_simulants(self, pop_data: SimulantData) -> None:
3241
new_population = pd.DataFrame(
3342
{
34-
"color": np.random.choice(self.colors, len(pop_data.index)),
43+
"color": self.randomness.choice(pop_data.index, self.colors),
3544
"entrance_time": pop_data.creation_time,
3645
},
3746
index=pop_data.index,

src/vivarium/framework/engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def initialize_simulants(self) -> None:
281281
self._clock.step_forward(self.get_population().index)
282282

283283
def step(self) -> None:
284-
self._logger.debug(self.current_time)
284+
self._logger.info(self.current_time)
285285
for event in self.time_step_events:
286286
self._logger.debug(f"Event: {event}")
287287
self._lifecycle.set_state(event)

0 commit comments

Comments
 (0)