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

42 Коммитов

Автор SHA1 Сообщение Дата
Brian Kroth 72e10d1833
devcontainer build fixups for macOS clients (#874)
# Pull Request

## Title

Fixups to the devcontainer build for macOS clients.

---

## Description

- Use a more portalable random number generator
- Address some differences in docker.sock privileges.
- Address differences in `stat` arguments.
- Switch to wget mode for conda installation to workaround lack of arm64
apt repo.
- When pulling base images to prime cache, use the appropriate
architecture (for Windows we only support amd64 for now).
- Remove `:latest` from `cache-from` args for `podman` compliance.
- Address some differences in `sed` syntax.

- Fixes #873 

---

## Type of Change

- 🛠️ Bug fix

---

## Testing

- local MacBook testing
- CI testing for Linux

---

## Additional Notes

Doesn't currently do builds for arm64 platform in the pipeline.
Can work towards addressing that in the future.
2024-10-21 10:17:37 -05:00
Brian Kroth fcc49aab5e
Tweaks for some pylint warnings (#858)
Minor adjustments to both display in vscode and quiet some pylint
warnings.

Note: in the future I'd like to get some changes from #330 incorporated
to allow more self-contained config examples, with relative paths
support, added, which means changing a pile of APIs, in which case we
can probably make all of these require named position values and remove
those exceptions.
2024-09-24 15:11:56 -05:00
Brian Kroth e40ac28317
Enable black, isort, and doc formatters and checks (#774)
Follow on work to #766.

This enabled both formatters and applies their changes to the repo.

Additionally, since `black` does not make changes to comments nor
docstrings, we also enable `docformatter` to reformat docstrings which
better aligns with `pydocstyle` rules as well.
Without this additional change (and some manual fixups), `pycodestyle`
and `pylint` would still complain about line lengths, for instance.

Finally, we make a minor adjustment to the max line length setting it to
99 (which is also accepted and mentioned in pep8) instead of 88 to avoid
some comment (especially linter overrides) wrapping.
2024-07-12 19:56:14 +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
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
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
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 3415bcc93d
Cleanup some deprecated VSCode settings (#622)
Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2024-01-09 15:59:43 -06:00
Brian Kroth 28b377e275
Update schema docs to reflect new unified schema (#605)
Minor updates to docs following #596.

- [x] ~Pending https://github.com/SchemaStore/schemastore/pull/3402
approval for some of the content.~

See Also: #522
2023-11-21 11:12:07 -08:00
Sergiy Matusevych ceab0d26d1
Explicitly add the project root to pytest arguments (#603)
My VSCode adds `"."` to pytest arguments in config every time I rebuild
the container - and deletes the `--log-level=DEBUG` argument at teh same
time. With this small fix, vscode can accept the project config as we
have it in git without modifying it

Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
2023-11-20 21:30:09 +00:00
Brian Kroth 108f5ded3c
Tests for shell env var population (#578)
Follow up to #573
2023-11-03 16:32:12 -07:00
Brian Kroth e2b8564588
Parallelize ssh tests (#570)
Note: current includes changes from #557 as well.

Closes #563 

Removes reliance on `--dist=loadgroup` and
`@pytest.mark.xdist_group(...)` to run SSH tests in a single worker by
implementing a portable file-lock based serialization method for test
service setup/teardown and separating out services that might interact
between tests.

In my local testing, this seems to solve both the "successful but
non-reported tests" issue, limited discoverability of tests in vscode
upon failure, and lack of parallel execution in all dev environments
(Windows, WSL Devcontainer, Linux).

On occassion in Windows I have seen the following error, but it is after
tests have passed, so seems to be part of pytest cleanup:

```
...
[gw4] [100%] PASSED mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_host_service.py::test_ssh_service_reboot

=================================================================================================================================== warnings summary ==================================================================================================================================== 
mlos_bench/mlos_bench/tests/services/remote/ssh/test_ssh_fileshare.py::test_ssh_fileshare_upload_file_dne
  C:\Users\bpkroth\.conda\envs\mlos\lib\site-packages\_pytest\threadexception.py:73: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-9 (_run_event_loop)

  Traceback (most recent call last):
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 494, in finish_recv
      return ov.getresult()
  OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 826, in _poll
      value = callback(transferred, key, ov)
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 498, in finish_recv
      raise ConnectionResetError(*exc.args)
  ConnectionResetError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\threading.py", line 1016, in _bootstrap_inner
      self.run()
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\threading.py", line 953, in run
      self._target(*self._args, **self._kwargs)
    File "C:\Users\bpkroth\src\MLOS\mlos_bench\mlos_bench\event_loop_context.py", line 48, in _run_event_loop
      self._event_loop.run_forever()
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 321, in run_forever
      super().run_forever()
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\base_events.py", line 603, in run_forever
      self._run_once()
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\base_events.py", line 1871, in _run_once
      event_list = self._selector.select(timeout)
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 444, in select
      self._poll(timeout)
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 828, in _poll
      f.set_exception(e)
    File "C:\Users\bpkroth\.conda\envs\mlos\lib\asyncio\windows_events.py", line 88, in set_exception
      super().set_exception(exception)
  asyncio.exceptions.InvalidStateError: invalid state

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
```

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
Co-authored-by: Sergiy Matusevych <sergiy.matusevych@gmail.com>
2023-11-02 20:57:10 +00:00
Brian Kroth b4b5f9371b
Add RemoteEnv tests using SshService testing infrastructure (#557)
Adds tests for RemoteEnv `setup`, `run`, `teardown` using SshServices

Fixes some associated bugs:
- convert certain `SFTPError` exceptions to `FileNotFound` in
`SshFileShareService`
This is important for `LocalFileShareEnv` integration especially since
it always calls `download` during calls to `status`, but only handles
`FileNotFound` exceptions when `ignore_missing=True`
- Fixups to #517 for `download`, `upload` to connect via `self._params`
(loaded from the `required_args`) instead of `self.config`

Also included:
- basic configs for SshServices and LocalExec for easy inclusion

Closes #521

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
Co-authored-by: Sergiy Matusevych <sergiy.matusevych@gmail.com>
2023-11-01 23:25:24 +00:00
Brian Kroth 9c473a7740
Tweaks to debug vs. batch run testing in VSCode (#561)
This change makes it so that running tests via VSCode's pytest plugin by
default runs them in parallel (respecting the setup.cfg args for
pytest), but when using the "Debug Test" option, parallel workers are
disabled so we can more quickly trace through code in debug mode without
additional processes to attach to.
Unfortunately, there is a [bug with the pytest-xdist loadgroup output
processing in the
vscode](https://github.com/microsoft/vscode-python/issues/19374) that
prevents a few tests that use that (namely the recently added ssh test)
from displaying as "completed successfully", even though they did.
2023-10-27 11:11:05 -07:00
Brian Kroth 1f0f8ee441
Add SSH Support (#510)
- Adds SSH support for remote exec and file copy operations via
`asyncssy` library. Closes #379
- This requires an event loop thread to operate the async calls in the
background without blocking the rest of our main thread operations or
changing our APIs dramatically. Instead we interact with all operations
as futures after that.
- Add json schema config support for SSH

- Adds test infrastructure for running SSH servers inside containers via
`pytest-docker` which uses `docker compose` to start/stop them as
fixtures. This *should* work in all dev environments (Linux host, WSL
host, Windows host), but is quite sensitive to networking setups.

  - [x] test the background thread cleanup logic
  - [x] test error handling of a broken ssh endpoint
  - [x] test basic exec commands
  - [x] test host operations (e.g., reboot)
  - [x] test basic copy commands
  - [x] test for single connection reuse across services
  - [x] test multi-server support
  - [x] use random ports to avoid conflicts
  - provide some config examples for using this
  - add remote_env exec tests with this (increase code coverage)
    - Will do these in a future PR instead - #521

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
Co-authored-by: Sergiy Matusevych <sergiy.matusevych@gmail.com>
2023-10-26 18:49:53 +00:00
Brian Kroth 142271a80a
Fix intermittent MagickMock response unit test error (#545)
Fixes a bug with mock responses not providing a `json()` method which is
only called during debug logging.

This was somewhat randomly showing up based I think upon the order of
the tests running.
One of them, seemed to be enabling `_LOG.setLevel(logging.DEBUG)` so
that future tests (for that worker) would also have the level set.

Once done, additional paths would be followed inside the `AzureServices`
code that caused it to try and do something like the following
`_LOG.debug(response.json())` which would fail because the mocked
response object didn't provide a `json()` method response.

This fixes that error, but doesn't address the `debug` log ordering.
I'm not certain we should switch all of our unit tests over to running
in DEBUG mode by default since it might cause us to depend on that
behavior.
As a compromise, for now I've enabled it only inside
`.vscode/settings.json` so that when we run `pytest` interactively
(e.g., during dev cycle or while debugging a single unit test), then
those code paths will be followed.

We can also run the following on demand and incorporate it to our
`Makefile` or nightly runs to do it at least some of the time:

```sh
pytest --log-level=DEBUG
```

or

```sh
export PYTEST_EXTRA_OPTIONS=--log-level=DEBUG
make test
```
2023-10-18 15:44:49 -07:00
Brian Kroth 4bfc9cbb5f
CLI args testing and improvements (#493)
- Support multiple instances of `--globals` and other arguments to build
a list.
- Provide some common mistype aliases for CLI args.
- [x] Adds some tests (additional ones to be added later)
  See Also testing comments in #490

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2023-08-28 13:01:44 -07:00
Brian Kroth 0db80043da
Smac optimizer bugfixes (#486)
- Workaround a bug in SMAC that builds additional_configs across
instantiations.
- [ ] Look for more of these cases (maybe that's where the
non-determinism is coming from?)
  - [x] Report it upstream: https://github.com/automl/SMAC3/pull/1067
- Adds more assertions to help check for related issues
- Addresses a TODO sanity check
- Adds some test code for FLAML's surrogate model by increasing
iterations
- Updates tests for easier tracing

Note: This still doesn't address all of the non-determinism across
platforms/python versions we've noticed recently (#482), and there's
some question yet about how much runhistory and some other features are
being handled correctly, but this still handles a few small improvements
of other issues I've noticed.
For the rest I've filed issues: 
- #487  
- #488

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
Co-authored-by: Sergiy Matusevych <sergiy.matusevych@gmail.com>
2023-08-18 20:29:48 +00:00
Brian Kroth 67a7d0a9a3
Autopep8 devcontainer fixups (#472)
The recommended autopep8 extension doesn't seem to be working for us:
https://github.com/microsoft/vscode-autopep8/issues/16

So, for now I'm reverting to the old way of doing things.

Also, the previous extension relied on a newer version of autopep8 than
conda was installing anyways, so I switched to installing it from pip.
2023-08-03 22:35:57 +00:00
Brian Kroth 2015f54d42
experiment_id fixups and restrictions (#471)
Adds schema restrictions on experiment_id since we use (or plan to use)
it in path names.

Per #357, also renames for snake case consistency.
2023-08-03 17:21:20 -05:00
Sergiy Matusevych 16ddcda961
Dump the tunables' metdata to JSON file so that the `LocalEnv` scripts can use it (#445)
In the subsequent PRs, we will port the tunables' metadata and Linux
kernel configuration scripts that use it from our private repo.
A PR with unit tests will also follow (turns out, we don't have *any*
tests for `LocalEnv` atm).
2023-07-12 15:57:56 -07:00
Brian Kroth 334d39d89a
Nested composite env schema and dynamic const_args support (#382)
- Fixes #381 to add nested inline CompositeEnv config support
- Enforces uniqueness on some more arrays.
- Cleanup some old comments.
- Add support for dynamic `$param_name` substitution in `const_args`

- [x] Add additional tests
2023-06-27 20:31:53 +00:00
Brian Kroth f7348f1c23
mlos_bench config json schema validation - services (#368)
Extends #340, #346, #349, #352, #359 to Service configs.
See Also: #331 

- [x] main schema as a set of subschemas
- [x] connect schema validation in the mlos_bench code
- [x] test-cases

To do this we removed support for configs that were flat lists of service configs: `[ {"class": "service.class"} ]` and turned those into objects that have a single key `"services"` with the list instead. `{ "services": [ ... ] }`
This makes sure that all configs are dicts/objects that we can optionally put `"$schema"` attributes on but also simplifies some of the config loading logic.
2023-05-22 15:31:16 -05:00
Brian Kroth 0ff623bed4
mlos_bench config json schema validation - environments (#359)
Extends #340, #346, #349, #352 to Environment configs.
See Also: #331 

- [x] main schema as a set of subschemas
- [x] connect schema validation in the mlos_bench code
- [x] test-cases
2023-05-19 21:22:54 +00:00
Brian Kroth 98d378d7a9
stop using prettier to format json for now - it wraps two line arrays which is obnoxious (#364) 2023-05-18 15:45:31 -07:00
Brian Kroth 29c77c92f2
mlos_bench config json schema validation - cli (#352)
Extends #340, #346, #349 to cli configs.
See Also: #331 

Also updates `--log_level` to support named logging levels (e.g. `INFO`)

- [x] add tests
  - [x] also backfilling tests of loading cli config examples (similar to what #313 did)
- [x] global config handling
2023-05-17 13:10:26 -05:00
Brian Kroth 3824f8eba2
mlos_bench config json schema validation - storage (#349) 2023-05-16 13:47:33 -07:00
Brian Kroth fbec7d7183
mlos_bench config json schema validation - tunable params (#346)
Extends #340 to tunable params.
See Also: #331
2023-05-16 14:54:56 -05:00
Brian Kroth e5a8bde5a5
devcontainer style improvements (#358)
* Disable line buffering
* fail pylint checks on unused-import errors
* make sure pycodestyle checks for indentation
* increase code quality requirements
* add some new extensions
* bring pycodestyle checks inline with flake8
* add a prettier rc that instructs it to use our editorconfig

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
2023-05-15 22:19:20 +00:00
Brian Kroth db1a0e359f
mlos_bench config json schema validation: optimizers and tunable_values (#340)
This PR introduces initial json schemas for mlos_bench optimizer configs and tunable_values configs, their validation at load time, and tests for both.

Future PRs will handle other config types.
See Also: #331
2023-05-15 16:30:36 -05:00
Brian Kroth a8f84f170f
Rename the conda env (#319)
* rename the conda env, which serves mlos_bench as much as mlos_core now, to just "mlos"
* add rename to the docker container - pulled from #313
2023-04-28 19:13:41 +00:00
Brian Kroth 9fe180a9a5
mypy static type checking for mlos_bench (#306)
Adds static type checking via mypy for mlos_bench as well.

Builds on #305, #307

- [x] Add `Protocol`s for different `Service` types so `Environment`s can check that the appropriate `Service` mix-ins have been setup.
  - [x] Config Loader
  - [x] Local Exec
  - [x] Remote Exec
  - [x] Remote Fileshare
  - [x] VM Ops
    - [ ] Future PR: Split VM Ops to VM/Host and OS Ops (for local SSH support)
2023-04-19 18:28:38 +00:00
Brian Kroth cac5351b98
mypy type checking support for mlos_core (mlos_bench to follow later) (#301)
* mypy type checking support for mlos_core (mlos_bench to follow later)
2023-04-12 16:11:58 +00:00
Brian Kroth 60b13a0afc
Workaround upstream conda release issue (#287)
Attempts to workaround some upstream release version mismatch issues for now so we can build the devcontainer in the pipelines.

See Also: <https://github.com/conda/conda-libmamba-solver/issues/169#issuecomment-1490509810>

* fixups for missing extension id (github made it official)

* workaround an upstream conda release bug
2023-04-03 21:27:40 -07:00
Brian Kroth a0a76cfcf6
Switch to Github Actions for CI/CD runs (#274) 2023-03-18 15:52:26 -05:00
Brian Kroth 989931dbd5 Merged PR 1040: Separate Windows and Linux CI jobs into separate pipelines
Separating the Windows and Linux jobs into two different pipelines so we can make the Windows one optional since it takes a lot more time than the others and we don't care about it as much now that we have devcontainer support.

Note: once this is in, I will need to make a couple of changes on the Azure DevOps side to make use of it, so these checks won't run for this PR.
2023-03-16 18:09:32 +00:00
Brian Kroth 8f73ecae7f Merged PR 903: Combination of additional build and doc fixups
This PR was originally aimed at just fixing the intermittent documentation build errors.
That issue ultimately stems from conflicts between conda and pip installs of two different versions of `mistune` dependency.
Along the way I found a handful of other improvements for build, pipeline, and documentation generation things.

- Make sure we do the nightly build regardless of whether code has changed
- Don't build the docs in parallel by default (trying to avoid an intermittent build failure)
- Add basic support for testing devcontainer manually outside for vscode
- Stop doing parallel builds so it's easier to debug, and move doc build/publishing to the devcontainer
- Split windows conda env off, stop using gpy from conda-forge, and just build it locally with clang, gcc, or msvc
- Adjust the devcontainer build so that more dependencies are built upfront during the container build.
  This makes the process more cacheable so that we can just pull the upstream version and not have to build as much locally which could delay first launch.
- Import part of a fix from elsewhere
- Switch to docker-compose style devcontainer that automatically also starts an nginx container for viewing the generated docs
- Update some docs and doc building
- [X] pydocstyle fixups
- [X] Add some log filtering of the `make doc` output for easier debugging
  (e.g. don't care about missing examples for now)
- [X] doc link lint checks
- DONE
- [X] Split this out into multiple PRs
  - [X] SpaceAdapterFactory: !959
  - [X] docstyle fixups: !960
  - [ ] doc build fixups
  - [ ] devcontainer improvements
(leaving the last two as this PR)
2023-02-27 05:42:22 +00:00
Brian Kroth 4ba5b9cbcf Merged PR 960: pydocstyle fixups
pydocstyle fixups
2023-02-25 01:07:34 +00:00
Brian Kroth aec20e9dd0 Merged PR 862: Add devcontainer support and other dev environment improvements
This PR is about general dev environment improvements.

Adds devcontainer support to help automatically prepare a dev environment inside either vscode of github codespaces.

The container is build, tested, and published to an ACR in the MlosCore RG during the pipeline for easy reuse and quick dev env boot strapping and reproducible environments both locally and remotely.

It also
- Enables parallel Makefile builds
- Adds additional helpful extensions to the vscode (e.g. copilot)
- Moves some pip package installs to conda for better reproducibility
- Fixes some issues regarding PYTHONPATH adjustment requirements for pytest and pylint.
- And, since I noticed a config for it in vscode, I added pydocstyle checks, though they aren't configured for blocking atm since there's lots of complaints.  Can decide whether to fix/force those later.
2023-02-07 21:43:01 +00:00
Brian Kroth c862e10e62 Merged PR 597: Pylint fixups
- include all python files in pylint checks
- improve version handling for pylint and update scripts
- make autopep8 available for vscode to use as a python formatter
- add more cspell words
- address some pylint warnings
- more pylint fixups
2022-08-30 19:58:49 +00:00
Brian Kroth d9224875c5 Merged PR 560: Merging initial os_autotune_main work to main
We will do our OS autotuning related work on mlos-bench there.

Main prior to this has been tagged as v0.0.3 for servicing Spark autotune needs if need be.

Plan is to reorganize the source tree after this so we can generate separate `mlos-core` and `mlos-bench` packages.
2022-08-04 16:11:35 +00:00
Andreas Mueller 6b8f34e7d4 Merged PR 333: Initial MlosCore Implementation
Adds basic `register` and `suggest` APIs for a couple of optimizer backends: `Skopt`, `Emukit`, `Random`.
Includes example notebook for starters.
Limited unit testing.  Basic function documentation.
Azure DevOps CI pipelines for `pylint` and `pytest` via the `mlos_core` `conda` `environment.yml`.

Related work items: #274, #279
2022-03-14 19:37:52 +00:00