Граф коммитов

486 Коммитов

Автор SHA1 Сообщение Дата
Sergiy Matusevych 30dd2e8da2
bugfix: MySQL can round microseconds into the future causing scheduler to skip trials (#775)
Solution: truncate microseconds of the current timestamp when scheduling
new trials to be executed ASAP

Closes #756
2024-07-10 21:27:10 +00:00
Sergiy Matusevych 5a062865be
bugfix: is_defaults() is a method, not property (#782)
Closes #781

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-07-10 16:01:22 -05:00
Brian Kroth a989d895e8
CI fixups (#783)
1. Temporarily avoid recent asyncssh version that breaks the tests
2. Workaround pylance issue with pyproject.toml related changes and pip
editable modules install format (#768)
   See Also: 
   - https://github.com/microsoft/pylance-release/issues/3473
   May also affect `mypy`:
   - https://github.com/python/mypy/issues/16988
   - https://github.com/python/mypy/issues/12313
2024-07-10 20:07:13 +00:00
Sergiy Matusevych 62d7efb484
Make sure One Shot Optimizer always returns the same suggestion (#759)
Make sure the `OneShotOptimizer.suggest()` call always returns the same
configuration.

Changes related to `MockEnv` determinism moved to #769 

Closes #755

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-07-03 21:14:44 +00:00
Brian Kroth cef476c4c4
Prepare isort black formatters and checks (#766)
Builds off of #762, #763, and #764.

Prepares rules and configs to enable isort and black formatters and
checks but doesn't enable them yet.

After these are enabled (next PR) we will reformat all files and ignore
that revision in git blame configs.

Then, we can convert configs stored in `setup.cfg` and `.pylintrc` to
the top level `pyproject.toml` and remove the older configs.
2024-07-03 15:57:49 -05:00
Johannes Freischuetz 1be2f0b51b
Fix Linting Error in os_environ.py (#772)
There is a linting issue for the os specific variables
This should fix it
2024-07-02 20:25:54 -05:00
Brian Kroth d428ce70fd
Introduce pyproject.toml build changes (#764)
This PR builds off of #762 and #763 

These are in part 
1. followup fixups for #746 (e.g., to allow setuptools-scm to be pulled
in at build time as a build dependency only when conda an pip have
mismatched version issues), and
2. Modernization improvements to allow us to make better use of other
tools (e.g., `black` that only accept `pyproject.toml` files as their
configuration files).

To do so, we move some configs from `setup.py` to `pyproject.toml` for
each module.
However, to retain the ability to rewrite URLs in published README.md
files on PyPi as well as consistent version dependencies across modules
without the need to manually specify version numbers (e.g., using
`setuptools-scm`) we mark a few dependencies as dynamic and leave our
existing logic inside the `setup.py` file.

Finally, we reorganize the `version.py` file to be inside the module and
fix a few previous omissions for `mlos_viz`.
2024-07-02 17:31:31 -05:00
Sergiy Matusevych 6bf3862ae1
Better naming and values for MockEnv parameters + unit tests (#769)
* Use `mock_env_range`, `mock_env_seed`, and `mock_env_metrics` instead
of just `range`, `seed`, and `metrics` to avoid naming conflicts.
* Use integer `mocl_env_seed` values to distinguish between
deterministic behavior, random seed, and user-specified seed for
`MockEnv`.
* Update unit tests and configs to validate the seed behavior.
* Add new unit tests for different initializations of the tunable values

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-07-02 20:47:32 +00:00
Johannes Freischuetz d1a4658250
Add Metadata to optimizers (#770)
Adds metadata to respond from suggest, and be passable into register.

This is in support of adding multi-fidelity support (#751)

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
Co-authored-by: Brian Kroth <bpkroth@microsoft.com>
2024-07-01 17:13:58 -05:00
Brian Kroth 5338631883
Remove a few under used vscode extensions (#765)
Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-07-01 13:35:38 -05:00
Brian Kroth 7daf3faa77
Staged Makefile Improvements (#762)
- Introduce a new `make format` target that currently only calls
`licenseheaders` but will call `isort` and `black` in the future
- Introduce new variables to help make dependency tracking easier
- Simplify `pytest` rules and allow running only a single module at a
time.

This PR is a precursor to pyproject.toml related build changes as well.

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-07-01 10:57:17 -05:00
Brian Kroth 6ca1dba8b3
Cleanup a warning issued by the SmacOptimizer cleanup code (#767)
Minor tweak to address this warning in pytest output:

```
mlos_core/mlos_core/tests/optimizers/optimizer_multiobj_test.py::test_multi_target_opt_wrong_weights[SmacOptimizer-kwargs2]
  C:\Users\bpkroth\.conda\envs\mlos\Lib\site-packages\_pytest\unraisableexception.py:80: PytestUnraisableExceptionWarning: Exception ignored in: <function SmacOptimizer.__del__ at 0x0000021F5FDC42C0>

  Traceback (most recent call last):
    File "C:\Users\bpkroth\src\MLOS\mlos_core\mlos_core\optimizers\bayesian_optimizers\smac_optimizer.py", line 208, in __del__
      self.cleanup()
    File "C:\Users\bpkroth\src\MLOS\mlos_core\mlos_core\optimizers\bayesian_optimizers\smac_optimizer.py", line 339, in cleanup
      if self._temp_output_directory is not None:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AttributeError: 'SmacOptimizer' object has no attribute '_temp_output_directory'

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

mlos_core/mlos_core/tests/optimizers/optimizer_test.py: 135 warnings
```

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-06-28 16:48:49 -07:00
Brian Kroth fb65d024ed
Add some dev notes on contributing to the MLOS project (#761) 2024-06-28 16:18:12 -07:00
Johannes Freischuetz bb6c6f2187
Require explicit arguments for mlos_core optimizers (#760)
This is a simple PR that makes all arguments explicit for
optimizer-related function calls in preparation to add additional
arguments in #751 and make it easier to review.

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
Co-authored-by: Brian Kroth <bpkroth@microsoft.com>
2024-06-28 16:43:22 -05:00
Brian Kroth c7a4823b22
Temporarily avoid broken numpy dependency (#757)
See Also: https://github.com/numpy/numpy/issues/26710
2024-06-25 22:51:30 +00:00
Kelly Kostopoulou ecfb5befae
Added missing 'shell_env_params' in redis.jsonc (#754)
These missing environment variables were causing the Redis benchmark to
fail.
2024-06-12 17:01:50 +00:00
Brian Kroth 723efbe4c6
Limit CI concurrency (#753)
Saves some resources and should speed up PRs that push frequently.

https://docs.github.com/en/actions/using-jobs/using-concurrency

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-06-06 12:55:51 -05:00
Sergiy Matusevych 0b010293ee
Pass optional weights for optimization targets in mlos_core; implement multi-target optimization for FLAML. (#738)
Summary of changes:
* Pass optional weights for optimization targets in mlos_core
* Implement weighted average for multi-objective optimization in FLAML
* Add more unit tests for multi-objective optimization on mlos_core side

Merge after ~#730~

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-06-03 17:24:15 -05:00
Brian Kroth a9cf8ca40e
Cascading series of CI dependency problems (#746)
A new git version outputs a different date format that older versions of
python's datetime module don't recognize.
https://github.com/pypa/setuptools_scm/issues/1038

setuptools-scm cut a new version to address that, but it's not available
in conda main channel yet, which is required, since without that the
conda pip phase can't execute in a single transaction

For now, we install things via conda-forge and adjust the channel
priority order so that the full set of dependencies could be resolved.

That of course brought in additional changes (e.g., `python=3.12` by
default, new `pylint`, `pycodestyle`, etc.), so this now also includes
some additional linting changes.

However, longer term, we need to switch to a pyproject.toml file to fix
this properly.
There we can specify prereqs for even loading the setup.py as well as
fix some other config complexities, though that is a broader change.

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-05-21 12:15:01 -07:00
Sergiy Matusevych e2b819f735
Update mlos_core API to support with multi-factor optimization (#730)
* [x] Pass multi-column DataFrame instead of Sequence to
`BaseOptimizer.register()` and other methods that deal with scores
* [x] Update mlos_bench `MlosCoreOptimizer` to support the new mlos_core
API
* [x] Update unit tests to work with the new API
* [x] Add unit tests for end-to-end multi-target optimization 

Merge after ~#726~

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-05-20 21:33:34 +00:00
Brian Kroth 6d8854bd2e
Pin a lower version of matplotlib while we wait for dabl to get fixed (#743)
https://github.com/dabl/dabl/pull/341
2024-05-20 10:41:06 -05:00
Sergiy Matusevych e1a0cdd3cd
make optimizer a fixture for 1-hot encoding/decoding tests (#737)
another PR to reduce the size of #730
2024-05-13 16:56:22 -05:00
Sergiy Matusevych 9e78019095
Issue a warning on non-null optimization context (#735)
Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-05-13 21:08:11 +00:00
Sergiy Matusevych 198ee1ee54
Fix docstrings for mlos_core SMAC and FLAML optimizers (#736)
another PR to reduce the size of #730
2024-05-13 20:50:26 +00:00
Brian Kroth 338b143541
CI fixups: changes in package naming via upstream libs (dash to underscore) (#733) 2024-05-10 15:31:37 -07:00
Sergiy Matusevych ff5a9c40c0
Implement multi-objective optimization in mlos_bench base classes (#726)
* [x] Store multiple optimization targets and directions in base
`Optimizer` class
* [x] Support multiple optimization targets in mock and grid search
optimizers
* [x] Check for single objective in `MlosCoreOptimizer` class (will add
support for multiple objectives after implementing that feature in
`mlos_core` in subsequent PRs)
* [x] Update unit tests in mlos_bench

Merge after ~#723~ and ~#725~

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-05-09 15:45:34 -07:00
Sergiy Matusevych fbdc116ddf
Allow multiple objectives in the optimizer config (#725)
* [x] Update JSON schema to use `"optimizer_target": {"score": "min"}`
format
* [x] Update base Optimizer class to use the new config format (throw
`NotImplementedError` if > 1 target)
* [x] Modify all unit tests to use the new format

Part of #692

Merge after #723

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-04-30 19:44:08 +00:00
Sergiy Matusevych 01f360b95a
use Python 3.11 in Windows conda env (#728)
a workaround for #727
2024-04-30 14:27:36 -05:00
Sergiy Matusevych 58464b926d
Pass multiple metrics into the optimizer (#723)
We will need this for multi-objective optimization as well as for
training the optimizers that can take muti-dimensional input

* [x] Make `Storage.Experiment.load()` return multiple scores
* [x] Fix unit tests to check for loading multi-dimensional scores from
the DB
* [x] Make `Optimizer.register()` and `.bulk_register()` take
multi-dimensional trial scores
* [x] Fix the Optimizer unit tests to check for registering
multi-dimensional scores
* [x] Check the Scheduler and optimization loop unit tests to see if we
need to adjust the types etc.

**NOTE:** In this PR, we _do not_ change mlos_core: we will still pass a
single scalar into it and do not change the API on mlos_core side. We
will change mlos_core in the subsequent PR to minimize the diff.

Part of #692
2024-04-29 12:27:53 -05:00
Sergiy Matusevych a7a28ef98e
bugfix: handle `-Inf` in `try_parse_val()` function (#724) 2024-03-25 13:27:03 -05:00
Sergiy Matusevych f25e09f237
Add `max_trials` scheduler config parameter (#719)
maybe merge after #713 (they might conflict)

Part of issue #715

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-03-19 15:57:28 -07:00
Sergiy Matusevych d2e7f056aa
Rename `max_iterations` to `max_suggestions` and track in Optimizer `.suggest()` instead of `.register()` (#713)
makes optimizers and schedulers a bit simpler. Part of issue #715 

Closes #711 

Note: the move from `--max_iterations` to `--max_suggestions` is a
breaking change, so we will need to cut a new release for this.

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-03-19 21:32:12 +00:00
Sergiy Matusevych 647e3a2f3c
UTC datetime handling improvements (#716)
Addresses some deprecation warnings about use of `datetime.utcnow()`.

Additionally, sqlite does not store timezone info even if provided, so
retrieving the data may be interpreted according to the host machine's
*local* timezone, which may or may not be UTC.

To mitigate this, this change ensures that all timestamps are 
1. first converted to UTC before storing into the DB,
2. converted (or augmented with zoneinfo) to UTC on retrieval

Additionally, we expand the tests to check for this behavior, first with
some additional conversion matrixes when telemetry or status data is
received in implicit local vs. explicit timezone data as well as
executions where the implicit local timezone has be overridden with a
`TZ` environment variable, to simulate different default timezone hosts.

Closes #718

---------

Co-authored-by: Brian Kroth <bpkroth@microsoft.com>
Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-03-19 20:51:59 +00:00
Sergiy Matusevych 020add2c2b
Add more tests for Scheduler configurations (CLI and JSON) (#717) 2024-03-18 10:14:21 -05:00
Sergiy Matusevych 4166e96db4
Pluggable Scheduler (#710)
* [x] Make Scheduler class loadable from JSON configs
* [x] Update the Launcher and `run.py` to instantiate Scheduler from
JSON
* [x] Create JSON schema for the Scheduler config
* [x] Add unit tests for the new Scheduler JSON configs

Closes #700

---------

Co-authored-by: Brian Kroth <bpkroth@microsoft.com>
Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2024-03-15 14:36:41 -07:00
Brian Kroth 2a09a072b8
Tweak Storage schema related tests (#712)
Adds some additional checks for consistency with other schema tests.
2024-03-15 15:02:24 -05:00
Sergiy Matusevych 6e3aea36bf
A function for a popular `None if value is None else func(value)` code pattern (#707)
basically, a poor man's Maybe monad
2024-03-14 16:51:22 +00:00
Sergiy Matusevych d7c4334991
Roll back forceful assignment of PATH when invoking a local process (#708)
Roll back one of the updates from #705 
It breaks tests on both Windows and WSL DevContainer on my PC.
* On Windows, `environ` may not have `PATH` at all
* On my WSL DevContainer, passing non-null `env` to `subprocess.run`
prevents it from finding the right python interpreter
2024-03-13 21:23:32 +00:00
Sergiy Matusevych 808bce3359
Factor out the functionality of best config tracking into a separate abstract Optimizer class (#709) 2024-03-13 14:04:35 -07:00
Brian Kroth e881987866
Add GridSearch Optimizer support (#690)
Closes #688

- Introduces `GridSearchOptimizer` to `mlos_bench`
- Generates and stores a set of `tuple(dict.values())` from
`ConfigSpace` to track elements of the config grid to search
- If `max_iterations` > `len(grid)` can refill the grid if desired
(e.g., by calling `suggest()` after `not_converged()` returns `False`.
- If `max_iterations` < `len(grid)` (i.e., we don't have enough
iterations to complete the grid) will issue a warning.

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
Co-authored-by: Sergiy Matusevych <sergiy.matusevych@gmail.com>
2024-03-07 15:32:18 -08:00
Brian Kroth 28b07b192f
Conda Updates (#705)
- Update the base image and make sure related dependencies are
consistently from either pip or conda, but not both (follow on fixes to
#699)
- Minor tweak to include the PATH in the local script exec environment
variables
- Another fix to the CI issue in #703
2024-03-07 21:57:51 +00:00
Sergiy Matusevych dd2547c3dc
Pluggable Scheduler implementation (#691)
Initial implementation of a separate `Scheduler` class from the core
`run` loop.

---------

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
Co-authored-by: Brian Kroth <bpkroth@microsoft.com>
2024-03-07 21:26:22 +00:00
Brian Kroth 917d9edace
Disable flaky logging line in CI workflow (#703)
Follow up to #702
2024-03-06 23:30:56 +00:00
Brian Kroth 3d5802784a
Don't shell interpret commit messages (#702)
Fixup following the commit message from #699 which includes a backtick
command.
2024-03-06 23:11:18 +00:00
Brian Kroth 3ae9ec0f27
Add cardinality and size related properties to Tunables (#698)
Adds support for introspecting the values from a quantized or otherwise
discrete Tunable.

Split out from #690.
2024-03-06 21:48:19 +00:00
Brian Kroth 5d83f55d23
Typing tweaks (#696)
Some type hint and alias tweaks for Tunables and a few others.

Split off from #690.
2024-03-06 21:31:25 +00:00
Brian Kroth de9e35d52a
Pin a devcontainer version to workaround library search path issue (#699)
A new base devcontainer image was
[released](https://github.com/devcontainers/images/blob/main/src/miniconda/history/0.203.7.md)
recently that introduces the following error in our environment when
running `make test`:

```
 import pandas._libs.window.aggregations as window_aggregations\n'
 'ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version '
 "`GLIBCXX_3.4.29' not found (required by "
 '/opt/conda/envs/mlos/lib/python3.11/site-packages/pandas/_libs/window/aggregations.cpython-311-x86_64-linux-gnu.so)\n')
```

A simplified reproduction involves running `conda run -n mlos pytest
mlos_bench/mlos_bench/launcher_run_test.ph`.

Unfortunately, it appears that under the latest version somewhere
between `conda` and `pytest` the `libc.so.6` library found is the one
under `/usr/lib` instead of `/opt/conda/envs/mlos/lib`.

I haven't quite seen where that's happening, but I've confirmed that
rolling back to the previous release for the base devcontainer image
fixes it.

Note that even then, we update `conda` to the latest and no-cache update
our own dependencies nightly, so we are getting the latest conda at
least, if not the latest Debian base packages.

This will be somewhat of a security issue eventually, but for now it
frees up our CI pipeline to get moving again.
2024-03-06 12:23:46 -08:00
Brian Kroth cc0d7e10b3
Move config_space to base Optimizer property (#697)
Also fix some missing conversion issues.

Split out from #690.
2024-03-05 11:07:51 -08:00
Sergiy Matusevych dc11f71a66
Bump version: 0.5.0 → 0.5.1 to mark a stable version before the big changes (async Environment etc.) (#695) 2024-03-04 12:36:52 -06:00
Sergiy Matusevych 0127775a0d
Separate the scheduler and the optimizer (no async yet) (#684) 2024-02-27 00:31:39 +00:00