Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always regenerate new asv machine file #38

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ Setup a completely fresh environment...
conda env create --file environments/nwb_benchmarks.yaml --no-default-packages
conda activate nwb_benchmarks

Setup initial machine configuration values with

.. code-block::

nwb_benchmarks setup

You will also need to install the custom network tracking software ``tshark`` using `their instructions <https://tshark.dev/setup/install>`_.
2 changes: 1 addition & 1 deletion environments/nwb_benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- pip
- pip:
- setuptools
- asv == 0.6.2
- asv == 0.6.1
- numba>=0.58.1 # Pin to specific version for cuda import
- psutil
- pynwb
Expand Down
20 changes: 3 additions & 17 deletions src/nwb_benchmarks/command_line_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import subprocess
import sys

from .setup import (
customize_asv_machine_file,
ensure_machine_info_current,
reduce_results,
)
from .setup import customize_asv_machine_file, reduce_results


def main() -> None:
Expand All @@ -29,22 +25,12 @@ def main() -> None:
specific_benchmark_pattern = flags_list[flags_list.index("--bench") + 1]

default_asv_machine_file_path = pathlib.Path.home() / ".asv-machine.json"
if command == "setup":
if default_asv_machine_file_path.exists():
ensure_machine_info_current(file_path=default_asv_machine_file_path)
return

if command == "run":
process = subprocess.Popen(["asv", "machine", "--yes"], stdout=subprocess.PIPE)
process.wait()

customize_asv_machine_file(file_path=default_asv_machine_file_path)
elif command == "run":
commit_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii").strip()

if default_asv_machine_file_path.exists():
ensure_machine_info_current(file_path=default_asv_machine_file_path)
else:
customize_asv_machine_file(file_path=default_asv_machine_file_path)
commit_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii").strip()

# Save latest environment list from conda (most thorough)
# subprocess tends to have issues inheriting `conda` entrypoint
Expand Down
8 changes: 2 additions & 6 deletions src/nwb_benchmarks/setup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""Exposed imports to the `setup` submodule."""

from ._configure_machine import (
collect_machine_info,
customize_asv_machine_file,
ensure_machine_info_current,
)
from ._configure_machine import collect_machine_info, customize_asv_machine_file
from ._reduce_results import reduce_results

__all__ = ["collect_machine_info", "customize_asv_machine_file", "ensure_machine_info_current", "reduce_results"]
__all__ = ["collect_machine_info", "customize_asv_machine_file", "reduce_results"]
36 changes: 0 additions & 36 deletions src/nwb_benchmarks/setup/_configure_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pathlib
import platform
import sys
import warnings
from typing import Any, Dict

import psutil
Expand Down Expand Up @@ -90,38 +89,3 @@ def customize_asv_machine_file(file_path: pathlib.Path, overwrite: bool = False)

with open(file=file_path, mode="w") as io:
json.dump(fp=io, obj=custom_file_info, indent=1)


def ensure_machine_info_current(file_path: pathlib.Path):
"""
Even something as simple as adjusting the disk partitions could affect performance.

If out of date, automatically trigger regeneration of machine info and hash.
Will also likely be affected by ipcfg.
"""
current_machine_info = collect_machine_info()

# Assume there's only one machine configured per installation
with open(file=file_path, mode="r") as io:
machine_file = json.load(fp=io)

default_machine_name = next(key for key in machine_file.keys() if key != "version")
machine_info_from_file = machine_file[default_machine_name]

# Only asserting agains the custom stuff we grab
machine_info_from_file.pop("defaults")
machine_info_from_file.pop("machine")
machine_info_from_file.pop("custom")

if machine_info_from_file == current_machine_info:
return

# If debugging is ever necessary in the future, best way I found to summarize differences was
# import unittest
#
# test = unittest.TestCase()
# test.maxDiff = None
# test.assertDictEqual(d1=machine_info_from_file, d2=current_machine_info)

warnings.warn("The current machine info is out of date! Automatically updating the file.", stacklevel=2)
customize_asv_machine_file(file_path=file_path, overwrite=True)
Loading