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

Add dynamic loading of optimizer #34

Merged
merged 17 commits into from
Aug 22, 2022
Merged

Add dynamic loading of optimizer #34

merged 17 commits into from
Aug 22, 2022

Conversation

aramoto99
Copy link
Collaborator

@aramoto99 aramoto99 commented Aug 10, 2022

  1. Changed the way optimizers are specified in the Config file.This change eliminates the need for reinstallation when the optimzier code is changed.
  • grid -> aiaccel.optimizer.GridSearchOptimizer
  • random -> aiaccel.optimizer.RandomSearchOptimizer
  • sobol -> aiaccel.optimizer.SobolSearchOptimizer
  • nelder-mead -> aiaccel.optimizer.NelderMeadSearchOptimizer
  • tpe -> aiaccel.optimizer.TpeSearchoptimizer
    (e.g.)
    search_algorithm: "aiaccel.optimizer.NelderMeadOptimizer"

2. Optimizers not included in the aiaccel package can also be specified.In that case, must be added path.
export PYTHONPATH="/hoge:$PYTHONPATH"

@github-actions
Copy link

github-actions bot commented Aug 10, 2022

Unit Test Results

238 tests  ±0   238 ✔️ ±0   40s ⏱️ +7s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit 55fcab8. ± Comparison against base commit 8f6df87.

This pull request removes 23 and adds 23 tests. Note that renamed tests count towards both.
tests.unit.optimizer_test.test_grid_search.TestGridSearchOptimizer ‑ test_generate_parameter
tests.unit.optimizer_test.test_grid_search.TestGridSearchOptimizer ‑ test_get_parameter_index
tests.unit.optimizer_test.test_grid_search.TestGridSearchOptimizer ‑ test_pre_process
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_check_result
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_generate_parameter
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_generate_parameter2
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_get_ready_parameters
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_pre_process
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_set_maximize
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadSearchOptimizer ‑ test_set_minimize
…
tests.unit.optimizer_test.test_grid_search.TestGridOptimizer ‑ test_generate_parameter
tests.unit.optimizer_test.test_grid_search.TestGridOptimizer ‑ test_get_parameter_index
tests.unit.optimizer_test.test_grid_search.TestGridOptimizer ‑ test_pre_process
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_check_result
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_generate_parameter
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_generate_parameter2
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_get_ready_parameters
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_pre_process
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_set_maximize
tests.unit.optimizer_test.test_nelder_mead_search.TestNelderMeadOptimizer ‑ test_set_minimize
…

♻️ This comment has been updated with latest results.

@aramoto99 aramoto99 requested review from tkokada and yoshipon August 11, 2022 23:59
@yoshipon
Copy link
Collaborator

Thank you!
How about specifying the class name in the configuration to remain the original class name.
For example, aiaccel.optimizer.grid.GridOptimizer

"""
return self.opt.Optimizer

@singledispatchmethod
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to construct a generic function?

@aramoto99 aramoto99 requested a review from yoshipon August 17, 2022 06:55
@yoshipon
Copy link
Collaborator

Thank you for updating the PR.
It would be better to consider a simpler way to specify the standard optimizer (e.g., NelderMeadOptimizer).

@tkokada
Copy link
Collaborator

tkokada commented Aug 22, 2022

@aramoto99 What kinds of rules are defined for any user optimizers? I think you find them using following codes.

aiaccel/aiaccel/start.py

Lines 512 to 519 in 6b3963d

def get_pyfile_path(self, module_name: str) -> str:
path = (
module_name
.replace(".", "/")
.replace("//", "../")
.replace(" ", "")
) + ".py"
return path

Copy link
Collaborator

@yoshipon yoshipon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@yoshipon yoshipon merged commit 917fd7d into main Aug 22, 2022
@yoshipon yoshipon deleted the feature/optimizer branch August 22, 2022 09:12
yoshipon added a commit that referenced this pull request Aug 26, 2022
* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>
yoshipon added a commit that referenced this pull request Aug 26, 2022
* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>
yoshipon added a commit that referenced this pull request Aug 30, 2022
* Data management function by database is added.
By adding the `--fs` option argument to the startup command, data management functions by the conventional file system can be used.
Extensive refactoring was performed around the addition of this functionality.

* Update setup.py

* Delete tests/test_data/work/state/ as it is not used in develop/database.

* Develop/database fix test (#18)

* fix for tests

* delete space

* pInfoDict -> p_info

* Merge main into debelop/database (#31)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix resumption test for DB

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* Feature/database (#36)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* Fixed a problem in which Snapshot could not be saved during parallel execution.

* Add function of delete any data in DB/FS.

* Fix code style

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>

* Request to merge cumulative changes . (#37)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* The report generation function can now be called by command.

* Fix data inconsistency when excute resume. (#39)

* Fix resume

* Fixed problem with sirialize not working in fs mode

* Remove unused package imports

* Fixed a problem that the resume function did not work in fs mode.

* The name workspace/state is the name of the old specification, so it was changed to the appropriate name workspace/snapshot.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>

* Add dynamic loading of optimizer, And fix resumtion test. (#42)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix conflicts with main branch (#43)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix codestyle

Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>
aramoto99 added a commit that referenced this pull request Aug 30, 2022
* Data management function by database is added.
By adding the `--fs` option argument to the startup command, data management functions by the conventional file system can be used.
Extensive refactoring was performed around the addition of this functionality.

* Update setup.py

* Delete tests/test_data/work/state/ as it is not used in develop/database.

* Develop/database fix test (#18)

* fix for tests

* delete space

* pInfoDict -> p_info

* Merge main into debelop/database (#31)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix resumption test for DB

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* Feature/database (#36)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* Fixed a problem in which Snapshot could not be saved during parallel execution.

* Add function of delete any data in DB/FS.

* Fix code style

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>

* Request to merge cumulative changes . (#37)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* The report generation function can now be called by command.

* Fix data inconsistency when excute resume. (#39)

* Fix resume

* Fixed problem with sirialize not working in fs mode

* Remove unused package imports

* Fixed a problem that the resume function did not work in fs mode.

* The name workspace/state is the name of the old specification, so it was changed to the appropriate name workspace/snapshot.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

* Delete unnecessary directories in Workspace.

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>

* Add dynamic loading of optimizer, And fix resumtion test. (#42)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix conflicts with main branch (#43)

* Fix #19 (#20)

* Fix #21 (#22)

* fix README (#23)

* fix codestyle test (#26)

* fix for pycodestyle

* add flake8==4.0.1

* Feature/update readme (#25)

* update README

* add bash

Co-authored-by: Yoshiaki Bando <[email protected]>

* Fix TPE resumtion test (#29)

* Fix tpe resumption test

* fix tpe resumption test

* Fix tep resumption test

* add retry (#38)

* Add dynamic loading of optimizer (#34)

* (WIP) Add dynamic loading of optimizer by importlib.

* (WIP) Add dynamic loading of optimizer by importlib.

* Add dynamic loading of optimizer by importlib

* Add dynamic loading of optimizer by importlib

* Fix test code

* fix test

* Fix resumtioin test

* Add dynamic loading of optimizer

* Fix dynamic loading of optimizer

* Function names and comments were rolled back.

* Changed the standard optimizer specification method

* changed the specification method for importing the standard optimizer.

* change deserialize (#40)

Co-authored-by: aramoto99 <[email protected]>

* Merge branch 'main' of github:aistairc/aiaccel into feature/database

* Fix codestyle

* (WIP) Change TPE resume

* Fix resume test

* Feature/fix resume tpe (#41)

* fix resume tpe

* fix resume tpe

* add if len(running_trials) > 0

* fix about trial number

* Fix TPE resumption

Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: KanaiYuma-aist <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>

* change serialize timing

Co-authored-by: aramoto99 <[email protected]>
Co-authored-by: aramoto99 <[email protected]>
Co-authored-by: Takashi OKADA <[email protected]>
Co-authored-by: Yoshiaki Bando <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants