From 7aa9d28e5d115f5cad6a3aa68c7e38f77d0604fa Mon Sep 17 00:00:00 2001 From: h-aze Date: Thu, 5 Oct 2023 12:12:21 +0100 Subject: [PATCH] Fixed some bugs --- README.md | 5 ++++- slune/savers.py | 5 ++++- slune/slune.py | 4 ++-- tests/test_savers.py | 6 +++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4149259..a45ffb7 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,10 @@ So early I haven't even written the docs yet! Will be adding a quick example her ## Coming soon Currently very much in early stages, first things still to do: -- Get Searcher to check which tunings have been done and which haven't and only submit the ones that haven't been done yet. Depending on a flag, ie. if you want to re-run a tuning you can set a flag to re-run all tunings. +- What happens if multiple results files? reading from them and not rerunning jobs already done. + - Refine package structure and sort out github actions like test coverage, running tests etc. +- Get Searcher to check which tunings have been done and which haven't and only submit the ones that haven't been done yet. Depending on a flag, ie. if you want to re-run a tuning you can set a flag to re-run all tunings. - Add more tests and documentation. - Auto sbatch job naming and job output naming. - Auto save when finished a tuning run. @@ -25,6 +27,7 @@ To install latest dev version use: ```bash # With https pip install "git+https://github.com/h-aze/slune.git#egg=slune-lib" +# TODO: don't think this is working, need to put working version of this # or with SSH pip install "git+ssh://@github.com:h-aze/slune.git#egg=slune-lib" ``` \ No newline at end of file diff --git a/slune/savers.py b/slune/savers.py index 6ff42ac..8115e17 100644 --- a/slune/savers.py +++ b/slune/savers.py @@ -81,7 +81,7 @@ def get_path(self, params: List[str]): csv_file_path = os.path.join(dir_path, f'results_{csv_file_number}.csv') return csv_file_path - def save_collated(self, results: pd.DataFrame): + def save_collated_from_results(self, results: pd.DataFrame): """ We add results onto the end of the current results in the csv file if it already exists, if not then we create a new csv file and save the results there @@ -99,6 +99,9 @@ def save_collated(self, results: pd.DataFrame): # If csv file does not exist, create it else: results.to_csv(self.current_path, index=False) + + def save_collated(self): + return self.save_collated_from_results(self.logger.results) def read(self, params: List[str], metric_name: str, min_max: str ='max'): """ diff --git a/slune/slune.py b/slune/slune.py index 2683bb5..72f86ab 100644 --- a/slune/slune.py +++ b/slune/slune.py @@ -70,7 +70,7 @@ def single_garg(arg_name): else: return single_garg(arg_names) -def get_csv_slog(params, root_directory='.'): - return SaverCsv(LoggerDefault(), params, root_directory=root_directory) +def get_csv_slog(params, root_dir='.'): + return SaverCsv(LoggerDefault(), params, root_dir=root_dir) # TODO: add functions for reading results \ No newline at end of file diff --git a/tests/test_savers.py b/tests/test_savers.py index 40cd0e2..e30d71e 100644 --- a/tests/test_savers.py +++ b/tests/test_savers.py @@ -93,7 +93,7 @@ def test_save_collated(self): # Create a data frame with some results results = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}) # Save the results - saver.save_collated(results) + saver.save_collated_from_results(results) # Check if the results were saved correctly read_results = pd.read_csv(os.path.join(self.test_dir, "--folder1=0.1/--folder2=0.2/--folder3=0.3/results_1.csv")) self.assertEqual(read_results.shape, (3,2)) @@ -104,7 +104,7 @@ def test_save_collated(self): # Create another data frame with more results results = pd.DataFrame({'a': [7,8,9], 'd': [10,11,12]}) # Save the results - saver.save_collated(results) + saver.save_collated_from_results(results) # Check if the results were saved correctly read_results = pd.read_csv(os.path.join(self.test_dir, "--folder1=0.1/--folder2=0.2/--folder3=0.3/results_1.csv")) results = pd.concat([pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}), results], ignore_index=True) @@ -122,7 +122,7 @@ def test_creates_path_if_no_full_match(self): # Create a data frame with some results results = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]}) # Save the results - saver.save_collated(results) + saver.save_collated_from_results(results) # Check if the results were saved correctly read_results = pd.read_csv(os.path.join(self.test_dir, "--folder1=0.01/--folder2=0.02/--folder3=0.03/results_0.csv")) self.assertEqual(read_results.shape, (3,2))