Skip to content

Commit 381fa75

Browse files
authored
Remove Simulate profile (to move to Vivarium profiling) (#669)
* remove simulate profile * add changelog * remove unused * Update CHANGELOG.rst
1 parent 4e1317d commit 381fa75

File tree

3 files changed

+5
-75
lines changed

3 files changed

+5
-75
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**3.6.0 - 10/27/25**
2+
3+
- Move simulate profile command to vivarium_profiling package
4+
15
**3.5.6 - 10/23/25**
26

37
- Split Interfaces and their respective Managers into different modules

docs/source/tutorials/running_a_simulation/cli.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Running from the Command Line
66

77
To run from the command line, we'll use the
88
:mod:`simulate <vivarium.interface.cli>` command. This command is actually a
9-
group containing three sub-commands: ``run``, ``test``, and ``profile``. We will
9+
group containing two sub-commands: ``run`` and ``test``. We will
1010
focus on ``run`` here.
1111

1212
The basic use of ``simulate run`` requires no more than a

src/vivarium/interface/cli.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
* - | **test**
1818
- | Runs an example simulation that comes packaged with ``vivarium``.
1919
| Useful as an installation test.
20-
* - | **profile**
21-
- | Produces a profile of a simulation using the python
22-
| :mod:`cProfile` module
2320
2421
For more information, see the :ref:`tutorial <cli_tutorial>` on running
2522
simulations from the command line.
@@ -30,10 +27,7 @@
3027
3128
"""
3229

33-
import cProfile
3430
import os
35-
import pstats
36-
from datetime import datetime as dt
3731
from pathlib import Path
3832
from time import time
3933

@@ -173,71 +167,3 @@ def test() -> None:
173167

174168
click.echo()
175169
click.secho("Installation test successful!", fg="green")
176-
177-
178-
@simulate.command()
179-
@click.argument(
180-
"model_specification",
181-
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
182-
)
183-
@click.option(
184-
"--results_directory",
185-
"-o",
186-
type=click.Path(resolve_path=True),
187-
default=Path("~/vivarium_results/").expanduser(),
188-
show_default=True,
189-
help=(
190-
"The directory to write results to. A folder will be created "
191-
"in this directory with the same name as the configuration file."
192-
),
193-
)
194-
@click.option(
195-
"--skip_writing",
196-
is_flag=True,
197-
help=(
198-
"Skip writing the simulation results to the output directory; the time spent "
199-
"normally writing simulation results to disk will not be included in the profiling "
200-
"statistics."
201-
),
202-
)
203-
@click.option(
204-
"--skip_processing",
205-
is_flag=True,
206-
help=(
207-
"Skip processing the resulting binary file to a human-readable .txt file "
208-
"sorted by cumulative runtime; the resulting .stats file can still be read "
209-
"and processed later using the pstats module."
210-
),
211-
)
212-
def profile(
213-
model_specification: Path,
214-
results_directory: Path,
215-
skip_writing: bool,
216-
skip_processing: bool,
217-
) -> None:
218-
"""Run a simulation based on the provided MODEL_SPECIFICATION and profile the run."""
219-
model_specification = Path(model_specification)
220-
results_directory = Path(results_directory)
221-
results_root = results_directory / f"{dt.now().strftime('%Y_%m_%d_%H_%M_%S')}"
222-
configure_logging_to_file(output_directory=results_root)
223-
224-
if skip_writing:
225-
configuration_override = {}
226-
else:
227-
output_data_root = results_root / "results"
228-
output_data_root.mkdir(parents=True, exist_ok=False)
229-
configuration_override = {
230-
"output_data": {"results_directory": str(output_data_root)},
231-
}
232-
233-
out_stats_file = results_root / f"{model_specification.name}".replace("yaml", "stats")
234-
sim = SimulationContext(model_specification, configuration=configuration_override)
235-
command = f"sim.run_simulation()"
236-
cProfile.runctx(command, globals=globals(), locals=locals(), filename=str(out_stats_file))
237-
238-
if not skip_processing:
239-
out_txt_file = Path(str(out_stats_file) + ".txt")
240-
with out_txt_file.open("w") as f:
241-
p = pstats.Stats(str(out_stats_file), stream=f)
242-
p.sort_stats("cumulative")
243-
p.print_stats()

0 commit comments

Comments
 (0)