Skip to content

Commit

Permalink
Added python and numpy version tags
Browse files Browse the repository at this point in the history
  • Loading branch information
RabiyaF committed Nov 6, 2024
1 parent d169dc8 commit dccf968
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fitbenchmarking/cli/checkpoint_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def generate_report(options_file="", additional_options=None, debug=False):
)

checkpoint = Checkpoint(options=options)
results, unselected_minimizers, failed_problems = checkpoint.load()
results, unselected_minimizers, failed_problems, config = checkpoint.load()

all_dirs = []
pp_dfs_all_prob_sets = {}
Expand All @@ -164,6 +164,7 @@ def generate_report(options_file="", additional_options=None, debug=False):
options=options,
failed_problems=failed_problems[label],
unselected_minimizers=unselected_minimizers[label],
config=config,
)

pp_dfs_all_prob_sets[label] = pp_dfs
Expand Down
11 changes: 11 additions & 0 deletions fitbenchmarking/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import sys
from tempfile import NamedTemporaryFile

import numpy as np

import fitbenchmarking
from fitbenchmarking.cli.checkpoint_handler import generate_report
from fitbenchmarking.cli.exception_handler import exception_handler
Expand Down Expand Up @@ -382,6 +384,14 @@ def run(problem_sets, additional_options=None, options_file="", debug=False):
group_labels = []
result_dir = []
pp_dfs_all_prob_sets = {}
config = {
"python_version": (
f"{sys.version_info.major}."
f"{sys.version_info.minor}."
f"{sys.version_info.micro}"
),
"numpy_version": np.__version__,
}
cp = Checkpoint(options=options)

for sub_dir in problem_sets:
Expand Down Expand Up @@ -441,6 +451,7 @@ def run(problem_sets, additional_options=None, options_file="", debug=False):
options=options,
failed_problems=failed_problems,
unselected_minimizers=unselected_minimizers,
config=config,
)

pp_dfs_all_prob_sets[label] = pp_dfs
Expand Down
12 changes: 10 additions & 2 deletions fitbenchmarking/core/results_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@

@write_file
def save_results(
options, results, group_name, failed_problems, unselected_minimizers
options,
results,
group_name,
failed_problems,
unselected_minimizers,
config,
):
"""
Create all results files and store them.
Expand All @@ -61,8 +66,10 @@ def save_results(
html output
:type failed_problems: list
:params unselected_minimizers: Dictionary containing unselected minimizers
based on the algorithm_type option
based on the algorithm_type option
:type unselected_minimizers: dict
:params config: Dictionary containing env config
:type config: dict
:return: Path to directory of group results, data for building the
performance profile plots
Expand Down Expand Up @@ -102,6 +109,7 @@ def save_results(
pp_locations=pp_locations,
failed_problems=failed_problems,
unselected_minimzers=unselected_minimizers,
config=config,
)

create_problem_level_index(
Expand Down
10 changes: 10 additions & 0 deletions fitbenchmarking/results_processing/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def create_results_tables(
pp_locations,
failed_problems,
unselected_minimzers,
config,
):
"""
Saves the results of the fitting to html/csv tables.
Expand All @@ -66,6 +67,8 @@ def create_results_tables(
:params unselected_minimzers: Dictionary containing unselected minimizers
based on the algorithm_type option
:type unselected_minimzers: dict
:params config: Dictionary containing env config.
:type config: dict
:return: filepaths to each table
e.g {'acc': <acc-table-filename>, 'runtime': ...}
Expand Down Expand Up @@ -108,6 +111,13 @@ def create_results_tables(
options.runtime_metric
)

config_str = (
"\nThe results were generated using python"
f" {config['python_version']} and numpy "
f"{config['numpy_version']}."
)
description[suffix] = description[suffix] + config_str

root = os.path.dirname(getfile(fitbenchmarking))
template_dir = os.path.join(root, "templates")

Expand Down
14 changes: 13 additions & 1 deletion fitbenchmarking/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import json
import os
import pickle
import sys
from base64 import a85decode, a85encode
from tempfile import TemporaryDirectory
from typing import Dict

import numpy as np

from fitbenchmarking.utils.exceptions import CheckpointError
from fitbenchmarking.utils.fitbm_result import FittingResult
from fitbenchmarking.utils.options import Options
Expand Down Expand Up @@ -198,6 +201,14 @@ def finalise_group(
{
"failed_problems": failed_problems,
"unselected_minimizers": unselected_minimizers,
"config": {
"python_version": (
f"{sys.version_info.major}."
f"{sys.version_info.minor}."
f"{sys.version_info.micro}"
),
"numpy_version": np.__version__,
},
},
indent=4,
)[6:-1]
Expand Down Expand Up @@ -266,6 +277,7 @@ def load(self):
results = group["results"]
unselected_minimizers[label] = group["unselected_minimizers"]
failed_problems[label] = group["failed_problems"]
config = group["config"]

# Unpickle problems so that we use 1 shared object for all results
# per array
Expand Down Expand Up @@ -323,7 +335,7 @@ def load(self):

output[label].append(new_result)

return output, unselected_minimizers, failed_problems
return output, unselected_minimizers, failed_problems, config


def _compress(value):
Expand Down

0 comments on commit dccf968

Please sign in to comment.