Skip to content

Commit

Permalink
Try with config file
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmig committed May 31, 2024
1 parent 9793868 commit b86a6b8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
35 changes: 26 additions & 9 deletions benchmarks/benchmarks/brainglobe_atlasapi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json
import os
from pathlib import Path

from brainglobe_workflows.brainglobe_atlasapi.create_mouse_atlas import (
create_mouse_atlas,
)
Expand All @@ -6,14 +10,27 @@
class TimeBenchmark:
# Timing attributes
timeout = 3600 # default: 60 s
version = (
None # benchmark version. Default:None (i.e. hash of source code)
)
warmup_time = 0.1 # seconds
rounds = 2
repeat = 0
sample_time = 0.01 # default: 10 ms = 0.01 s;
min_run_count = 2 # default:2

def setup(self):
# read input config: environment variable if it exists, else default
input_config_path = os.getenv(
"ATLAS_CONFIG_PATH",
default=str(
Path(__file__).parents[2]
/ "brainglobe_workflows"
/ "configs"
/ "brainglobe_atlasapi_small.json"
),
)

assert Path(input_config_path).exists()

# read as dict
with open(input_config_path) as cfg:
config_dict = json.load(cfg)

# pass dict to class
self.config = config_dict

def time_create_mouse_atlas(self):
create_mouse_atlas()
create_mouse_atlas(**self.config)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from brainglobe_atlasapi import BrainGlobeAtlas

Check warning on line 1 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L1

Added line #L1 was not covered by tests


def create_mouse_atlas():
atlas = BrainGlobeAtlas("allen_mouse_100um")
def create_mouse_atlas(atlas_name):
atlas = BrainGlobeAtlas(atlas_name)
print(atlas.atlas_name)

Check warning on line 6 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L4-L6

Added lines #L4 - L6 were not covered by tests


if __name__ == "__main__":
create_mouse_atlas()
create_mouse_atlas("allen_mouse_100um")

Check warning on line 10 in brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_workflows/brainglobe_atlasapi/create_mouse_atlas.py#L9-L10

Added lines #L9 - L10 were not covered by tests
3 changes: 3 additions & 0 deletions brainglobe_workflows/configs/brainglobe_atlasapi_large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"atlas_name": "allen_mouse_10um"
}
3 changes: 3 additions & 0 deletions brainglobe_workflows/configs/brainglobe_atlasapi_small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"atlas_name": "allen_mouse_100um"
}

0 comments on commit b86a6b8

Please sign in to comment.