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 SSH Support #510

Merged
merged 333 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
333 commits
Select commit Hold shift + click to select a range
6a25b0d
fixups
bpkroth Apr 14, 2023
7f96894
just use docker compose to forward ports
bpkroth Apr 14, 2023
abceaf5
move nginx port to a random port
bpkroth Apr 14, 2023
52d0870
make it work for powershell too
bpkroth Apr 14, 2023
5f07178
need the .env file to be in a different directory
bpkroth Apr 14, 2023
a9af273
fixups for pwsh
bpkroth Apr 14, 2023
7767244
also stop running the docker pull
bpkroth Apr 14, 2023
e1314c4
whitespace reorg
bpkroth Apr 14, 2023
ad0db88
fixup
bpkroth Apr 14, 2023
c9abebd
Merge branch 'devcontainer-nginx-port-fixup' into mypy-typing-mlos_bench
bpkroth Apr 14, 2023
0581d55
make the cmd more verbose
bpkroth Apr 14, 2023
1bb5293
merge conflict
bpkroth Apr 14, 2023
70206f6
more debugging
bpkroth Apr 14, 2023
e2c8e5f
ignore ipv6
bpkroth Apr 14, 2023
2bd4352
Merge branch 'devcontainer-nginx-port-fixup' into mypy-typing-mlos_bench
bpkroth Apr 14, 2023
2b90005
type fixup
bpkroth Apr 14, 2023
6ca958b
use a newer mypy to avoid some issues
bpkroth Apr 14, 2023
84e022d
fixup
bpkroth Apr 14, 2023
55b704d
fix some circular import issues
bpkroth Apr 14, 2023
f4c916b
fixups
bpkroth Apr 14, 2023
5fe88a3
spelling
bpkroth Apr 14, 2023
60fb342
wip: protocols for type checking
bpkroth Apr 14, 2023
0a11322
be more specific about error type being ignored
bpkroth Apr 16, 2023
1738706
more specific type ignore errors
bpkroth Apr 16, 2023
3d320d4
wip: implement protocols for type checking for some service mixins
bpkroth Apr 16, 2023
79699d0
type fixups
bpkroth Apr 16, 2023
6304e8e
more type fixups
bpkroth Apr 16, 2023
88c24b3
fixup ignore
bpkroth Apr 16, 2023
0c44a33
extend config loader service for more use cases
bpkroth Apr 16, 2023
5c1f44a
more minor fixups
bpkroth Apr 16, 2023
0a487e9
more protocol tweaks
bpkroth Apr 16, 2023
579f429
more protocol tweaks
bpkroth Apr 16, 2023
07548f1
fileshare type checking
bpkroth Apr 16, 2023
63b8939
pycodestyle
bpkroth Apr 16, 2023
144f178
make dmypy start before the jobs for it
bpkroth Apr 16, 2023
b66fae4
wip: reorg service types
bpkroth Apr 16, 2023
c9d8cf3
wip: split out vm/os service types
bpkroth Apr 16, 2023
ac0b07f
vm ops typing
bpkroth Apr 16, 2023
77b6c45
fixups
bpkroth Apr 16, 2023
b396e66
more typing fixups, also avoid some circular imports by only importin…
bpkroth Apr 16, 2023
7ab41be
more typing (maybe the last?!)
bpkroth Apr 16, 2023
f422d41
add py.typed file
bpkroth Apr 16, 2023
c83d2f6
fixups
bpkroth Apr 16, 2023
8a078ee
fixup
bpkroth Apr 16, 2023
52142f9
update
bpkroth Apr 17, 2023
50fcfdc
fixups
bpkroth Apr 17, 2023
4d842b8
renamed method
bpkroth Apr 17, 2023
447aa6f
ignore some doc build errors
bpkroth Apr 17, 2023
60c4787
minor windows tweaks
bpkroth Apr 17, 2023
f603a49
correction
bpkroth Apr 17, 2023
bed054e
fixups for windows
bpkroth Apr 17, 2023
bcfab8a
minor tweak
bpkroth Apr 17, 2023
20349f1
unnecessary
bpkroth Apr 17, 2023
61afd3a
remove an unnecessary import
bpkroth Apr 17, 2023
503698e
Merge branch 'main' into mypy-typing-mlos_bench
bpkroth Apr 17, 2023
c56bd42
cleanup merge
bpkroth Apr 17, 2023
9ab5246
Merge branch 'mypy-typing-mlos_bench' into add-ssh-support
bpkroth Apr 18, 2023
95aa63d
wip: bringing ssh support up to speed with mypy changes, refactoring …
bpkroth Apr 18, 2023
220f218
wip: split host and os ops vs provisioning more
bpkroth Apr 18, 2023
a988fdb
remove old file
bpkroth Apr 18, 2023
ca6e65a
finish refactor
bpkroth Apr 18, 2023
8946ba4
adding ssh services
bpkroth Apr 18, 2023
5e434a2
Merge branch 'main' into add-ssh-support (with conflicts)
bpkroth Apr 19, 2023
62e608c
merge conflict fixups
bpkroth Apr 19, 2023
57010b2
Merge branch 'main' into add-ssh-support
bpkroth Apr 21, 2023
a86b5a7
wip: new client library
bpkroth Apr 21, 2023
152ae74
tweaks
bpkroth Apr 21, 2023
3147142
stub file for fileshare services
bpkroth Apr 21, 2023
61f3351
wip
bpkroth Apr 22, 2023
23dfdbf
Merge branch 'main' into add-ssh-support
bpkroth Aug 24, 2023
ab968bd
merge cleanup
bpkroth Aug 24, 2023
b98d399
cleanup
bpkroth Aug 24, 2023
b4ae58c
fixups
bpkroth Aug 24, 2023
744cddf
rename
bpkroth Aug 24, 2023
1fd22e2
fixups
bpkroth Aug 24, 2023
1a21795
remove other PR work
bpkroth Aug 24, 2023
792c62d
fixup tests and provide schemas
bpkroth Aug 24, 2023
67a81d6
remove other PR work
bpkroth Aug 24, 2023
c6b9413
Merge branch 'main' into reorg-prep-for-ssh-support
bpkroth Aug 24, 2023
45ef444
switch some params around for better readability of unnamed boolean args
bpkroth Aug 25, 2023
eff7b0b
restore previous behavior
bpkroth Aug 25, 2023
b6ad16e
log correct details
bpkroth Aug 25, 2023
6c86928
fixup
bpkroth Aug 25, 2023
c6fa91b
restore old style
bpkroth Aug 25, 2023
423639d
fixups
bpkroth Aug 25, 2023
b1b88fa
fixup
bpkroth Aug 25, 2023
5ff8b20
Merge branch 'main' into reorg-prep-for-ssh-support
bpkroth Aug 25, 2023
ad406c7
restore the files we removed in the staging branch
bpkroth Aug 28, 2023
038ab9a
cleanup the container more quickly by default
bpkroth Aug 28, 2023
c3fece5
test env fixups
bpkroth Aug 28, 2023
b5cc0fd
wip: attempting to get networking to work for testing across platforms
bpkroth Aug 28, 2023
f7ea4bb
Workaround an upstream conda vs. base devcontainer image dependency m…
bpkroth Aug 28, 2023
fc1c50d
Merge branch 'fixup-devcontainer-rebuilds' into add-ssh-support
bpkroth Aug 28, 2023
4c5b6d2
tweaks to test config
bpkroth Aug 29, 2023
bba9906
switch to docker compose
bpkroth Aug 29, 2023
6ac48cb
wip: test harness code for ssh service
bpkroth Aug 30, 2023
032be72
more ssh test infrastructure
bpkroth Aug 30, 2023
510bbb9
improvements
bpkroth Aug 30, 2023
b03766a
fixups
bpkroth Aug 30, 2023
cb0a68d
fixups for windows
bpkroth Aug 30, 2023
330c154
wip
bpkroth Aug 30, 2023
71eca2d
add pid
bpkroth Aug 30, 2023
365196a
ssh config schema support
bpkroth Aug 31, 2023
29be25e
rename
bpkroth Aug 31, 2023
51698e1
add more schema properties and test cases
bpkroth Aug 31, 2023
8bdca2a
more ssh work
bpkroth Aug 31, 2023
64dba8d
add ssh dependencies
bpkroth Sep 1, 2023
888987a
wip
bpkroth Sep 1, 2023
87b1d09
wip
bpkroth Sep 1, 2023
21a5a7f
reorg for debugging aid
bpkroth Sep 5, 2023
009139d
wip
bpkroth Sep 5, 2023
7f0b07c
test example implementation that uses a single background thread to r…
bpkroth Sep 6, 2023
2a18624
wip
bpkroth Sep 7, 2023
c5adf7b
revert and add timing to convince myself that these things do in fact…
bpkroth Sep 7, 2023
709038c
wip
bpkroth Sep 8, 2023
7bd5570
Merge branch 'main' into add-ssh-support
bpkroth Sep 12, 2023
78e82fc
reorg and fixups
bpkroth Sep 13, 2023
329291c
wip
bpkroth Sep 13, 2023
1380463
wip merging hacking into place
bpkroth Sep 13, 2023
aeed341
fixups
bpkroth Sep 14, 2023
14ea81b
implement basic event loop thread
bpkroth Sep 14, 2023
6c94be4
todo comments
bpkroth Sep 14, 2023
4a09f4d
wip
bpkroth Sep 14, 2023
b357868
adjust schemas to not require config if empty
bpkroth Sep 14, 2023
9cb4259
wip: initial ssh host service
bpkroth Sep 14, 2023
c1883ac
Merge branch 'main' into add-ssh-support
bpkroth Sep 18, 2023
42c1c59
change the signatures so we can use it with ssh
bpkroth Sep 18, 2023
f39c315
initial implementation of scp service
bpkroth Sep 18, 2023
b581210
Fixups to commit message checks to only happen during PR pushes (#509)
bpkroth Sep 18, 2023
8331423
wip: tests
bpkroth Sep 19, 2023
75d9d28
Merge branch 'main' into add-ssh-support
bpkroth Sep 21, 2023
f617635
fixup for ssh infra test
bpkroth Sep 22, 2023
0135b61
switch to random ports
bpkroth Sep 22, 2023
e80d08a
fixups
bpkroth Sep 22, 2023
7ae530c
start adding multiple server support
bpkroth Sep 22, 2023
94536a1
test both servers
bpkroth Sep 22, 2023
1e35cc0
fixups and initial remote execution test
bpkroth Sep 22, 2023
422eb0c
add tests for multiple servers
bpkroth Sep 22, 2023
f1e8ad5
comments
bpkroth Sep 22, 2023
b690835
imporved tests
bpkroth Sep 22, 2023
2c3248e
types
bpkroth Sep 22, 2023
be6897b
pylint tweaks
bpkroth Sep 22, 2023
0417fc3
skip some base class config tests
bpkroth Sep 22, 2023
3a7be1a
fixups
bpkroth Sep 23, 2023
9ab3c11
add reboot testing, handle dynamic port changes, make sure that thing…
bpkroth Sep 27, 2023
b1c269b
checks for non-graceful disconnects too
bpkroth Sep 27, 2023
1dae1c8
mark more tests as part of the same parallel group
bpkroth Sep 27, 2023
3e840c3
wip: file upload/download
bpkroth Sep 27, 2023
acfc137
fixups
bpkroth Sep 27, 2023
d22814a
check for error handling of non-existing files
bpkroth Sep 27, 2023
f1976d6
pylint
bpkroth Sep 27, 2023
d310169
recursive file copy tests
bpkroth Sep 27, 2023
129ff21
missing config test cases
bpkroth Sep 28, 2023
fa95a52
Merge remote-tracking branch 'upstream/main' into add-ssh-support
bpkroth Sep 28, 2023
0b3bf61
test group fixups
bpkroth Sep 28, 2023
48d4976
clear the client cache before starting that test
bpkroth Sep 28, 2023
497553e
Merge remote-tracking branch 'upstream/main' into add-ssh-support
bpkroth Sep 28, 2023
7a26b47
Add a README explaining how the testing infrastructure works
bpkroth Sep 28, 2023
4f4ec5d
pylint, mypy fixes
bpkroth Sep 28, 2023
0beecca
work around python 3.8 issues
bpkroth Sep 28, 2023
435bde4
remove hacking script
bpkroth Sep 28, 2023
bf1e77d
comments
bpkroth Sep 28, 2023
8fa4615
comments
bpkroth Sep 28, 2023
166c5ec
comments
bpkroth Sep 28, 2023
8fe4e02
Merge branch 'main' into add-ssh-support
bpkroth Sep 28, 2023
7c8ce8b
Merge branch 'main' into add-ssh-support
bpkroth Sep 29, 2023
87a3fcb
pylint
bpkroth Sep 29, 2023
bc89a63
refactor for windows support
bpkroth Sep 29, 2023
0f98006
prebuild the necessary docker services for windows
bpkroth Sep 29, 2023
cd990cc
prebuild the necessary docker services for windows
bpkroth Sep 29, 2023
42fab2c
split steps
bpkroth Sep 29, 2023
8f14360
move it sooner for debugging
bpkroth Sep 29, 2023
362ceca
Merge branch 'additional-remote-env-tests' into add-ssh-support
bpkroth Sep 29, 2023
d62a560
default to linux for containers
bpkroth Sep 29, 2023
4ebf335
workaround issues with windows ci by specifying the build platform
bpkroth Sep 29, 2023
e31a393
Add checks for Linux platform support from docker on host - Windows G…
bpkroth Sep 29, 2023
7662440
more
bpkroth Sep 29, 2023
51b67ff
restore
bpkroth Sep 29, 2023
b745f80
debugging
bpkroth Sep 29, 2023
540a386
remove platform spec
bpkroth Sep 29, 2023
2146d11
improvements for github windows action runner
bpkroth Sep 29, 2023
c22c518
builder or buildx support dne in windows
bpkroth Sep 29, 2023
370043c
allow nested run in container with cli args for testing
bpkroth Sep 29, 2023
ba07483
testing
bpkroth Sep 29, 2023
90d4558
add the host.docker.internal mapping to the devcontainer so we can re…
bpkroth Oct 2, 2023
8971541
tweaks for windows ci environment
bpkroth Oct 2, 2023
f973b09
unnecessary to split that out
bpkroth Oct 2, 2023
5ea9997
spelling
bpkroth Oct 2, 2023
09d3eec
Merge branch 'main' into add-ssh-support
motus Oct 5, 2023
3a3174e
Merge branch 'main' into add-ssh-support
bpkroth Oct 10, 2023
7b8f6a8
Merge branch 'main' into add-ssh-support
bpkroth Oct 11, 2023
109a324
Merge branch 'main' into add-ssh-support
motus Oct 17, 2023
430e2cb
disk space debugging
bpkroth Oct 18, 2023
bbcdde2
also list the docker images
bpkroth Oct 18, 2023
2a0f07a
fix a bug with mock responses not providing a method only called duri…
bpkroth Oct 18, 2023
5715a0c
allow optionally running in debug log level during nightly runs
bpkroth Oct 18, 2023
c0fe88e
Merge branch 'fix-magicmock-json-serialization-errors' into add-ssh-s…
bpkroth Oct 18, 2023
dfade61
more garbage collection
bpkroth Oct 18, 2023
7a6e562
more thorough gc
bpkroth Oct 18, 2023
98014e0
Merge branch 'main' into add-ssh-support
bpkroth Oct 18, 2023
aac2b9f
remove TODO comment
bpkroth Oct 19, 2023
9be45b2
ignore a known warning
bpkroth Oct 19, 2023
8bb4e96
Merge branch 'main' into add-ssh-support
motus Oct 19, 2023
9aba8a7
fixups
bpkroth Oct 19, 2023
3661bda
space debugging
bpkroth Oct 20, 2023
16ee957
timeout change
bpkroth Oct 20, 2023
05cabfe
addressing comments
bpkroth Oct 23, 2023
ee37493
revert NoneType change
bpkroth Oct 23, 2023
c54ea8a
implement force restart
bpkroth Oct 23, 2023
1b86d64
apply suggestions to support multiline commands
bpkroth Oct 23, 2023
f93b240
Merge branch 'main' into add-ssh-support
motus Oct 24, 2023
f406ac3
apply suggestions
bpkroth Oct 24, 2023
d07afc7
fixups post main merge
bpkroth Oct 24, 2023
acef755
fixup
bpkroth Oct 24, 2023
2d5cad2
backout some ci changes
bpkroth Oct 24, 2023
1c4a8ce
Merge branch 'main' into add-ssh-support
bpkroth Oct 24, 2023
06f7d76
remove comment
bpkroth Oct 24, 2023
b671732
Merge branch 'main' into add-ssh-support
bpkroth Oct 24, 2023
493e246
fixup method registering
bpkroth Oct 25, 2023
3d8f3a9
wip: convert to context manager
bpkroth Oct 25, 2023
0818633
fixups to tests to make mock_operations methods
bpkroth Oct 25, 2023
0cb41c1
enter contexts to use ssh services
bpkroth Oct 25, 2023
1dceae2
fixup method registering
bpkroth Oct 25, 2023
ed4eb40
wip: add context manager support to Services
bpkroth Oct 25, 2023
fa8cab9
fixups to tests to make mock_operations methods
bpkroth Oct 25, 2023
45a7ce8
add a basic sanity check
bpkroth Oct 25, 2023
ec250ce
more
bpkroth Oct 25, 2023
a8cc9eb
Merge branch 'main' into context-manager-support-for-services
bpkroth Oct 25, 2023
f2cdce8
remove Self annotation that I was playing with
bpkroth Oct 25, 2023
ff9f664
remove requirement that service methods be methods and not functions
bpkroth Oct 25, 2023
d73f29b
Revert "fixups to tests to make mock_operations methods"
bpkroth Oct 25, 2023
a60afae
make service context reentrant
bpkroth Oct 25, 2023
548b7b1
Merge branch 'context-manager-support-for-services' into add-ssh-supp…
bpkroth Oct 25, 2023
a4f8544
Merge branch 'add-ssh-support-with-context-manager' into add-ssh-support
bpkroth Oct 25, 2023
49bd826
fixu
bpkroth Oct 25, 2023
6727ebf
removed
bpkroth Oct 25, 2023
4d7b603
Merge branch 'main' into add-ssh-support
bpkroth Oct 25, 2023
4644b0a
Revert "fixups to tests to make mock_operations methods"
bpkroth Oct 25, 2023
1dbe71d
make service context reentrant
bpkroth Oct 25, 2023
6ccecad
Update mlos_bench/mlos_bench/services/remote/ssh/ssh_host_service.py
bpkroth Oct 26, 2023
73e70e2
Update mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py
bpkroth Oct 26, 2023
6d2132a
Update mlos_bench/mlos_bench/services/remote/ssh/ssh_service.py
bpkroth Oct 26, 2023
57f2266
revamp to separate out async event loop context helper
bpkroth Oct 26, 2023
eb76bfe
Extract event loop context manager from SSH PR
bpkroth Oct 26, 2023
6584b45
add a test for running coroutines in the background
bpkroth Oct 26, 2023
1a7d232
Merge branch 'add-asyncio-event-loop-context-manager' into add-ssh-su…
bpkroth Oct 26, 2023
02edc57
comments
bpkroth Oct 26, 2023
7c6008d
comment cleanup
bpkroth Oct 26, 2023
513e372
comment
bpkroth Oct 26, 2023
e2b06dd
Merge branch 'main' into add-ssh-support
bpkroth Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"abstractmethods",
"arange",
"astype",
"asyncssh",
"autotune",
"autotuning",
"bincount",
Expand All @@ -12,11 +13,13 @@
"commandline",
"conda",
"configspace",
"coro",
"dataframe",
"devcontainer",
"discretization",
"discretize",
"drivername",
"dstpath",
"dtype",
"duckdb",
"emukit",
Expand All @@ -31,6 +34,7 @@
"iterrows",
"jsonschema",
"jupyterlab",
"keepalive",
"kwargs",
"libmamba",
"linalg",
Expand All @@ -47,10 +51,12 @@
"obvs",
"perc",
"pinv",
"poweroff",
"pylint",
"pyplot",
"pytest",
"Quickstart",
"refcnt",
"rexec",
"rootfs",
"runhistory",
Expand All @@ -63,11 +69,13 @@
"skopt",
"smac",
"sqlalchemy",
"srcpaths",
"subcmd",
"subschema",
"subschemas",
"tolist",
"tunables",
"xdist",
"xlabel",
"ylabel"
]
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"postCreateCommand": "/opt/conda/bin/conda env update --solver=libmamba -v -n mlos -f ${containerWorkspaceFolder}/conda-envs/mlos.yml",
// Various mounting, run, post-create, and user settings
"containerEnv": {
"LOCAL_USER_NAME": "${localEnv:USER}${localEnv:USERNAME}",
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
"CONTAINER_WORKSPACE_FOLDER": "${containerWorkspaceFolder}",
"SSH_AUTH_SOCK": "${localEnv:SSH_AUTH_SOCK}",
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ services:

env_file: ../.env

extra_hosts:
- "host.docker.internal:host-gateway"

docs-www:
build:
context: ./tmp
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/scripts/run-devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ else
docker_gid=$(stat -c%g /var/run/docker.sock)
fi

set -x
mkdir -p "/tmp/$container_name/dc/shellhistory"
docker run -it --rm \
--name "$container_name" \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
--env LOCAL_WORKSPACE_FOLDER=$(pwd) \
--env PYTEST_EXTRA_OPTIONS=$PYTEST_EXTRA_OPTIONS \
--workdir /workspaces/MLOS \
--add-host host.docker.internal:host-gateway \
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
--name mlos-devcontainer mlos-devcontainer sleep 1800
- name: Fixup vscode uid/gid in the running container
timeout-minutes: 3
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
},
"python.testing.pytestArgs": [
"-n1", // don't run tests in parallel inside vscode - makes attaching the debugger more cumbersome
"--dist=no",
"--log-level=DEBUG",
"."
],
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
- types-colorama
- types-jsonschema
- types-pygments
- types-pytest-lazy-fixture
- types-requests
- types-setuptools
- "--editable ../mlos_core[full-tests]"
Expand Down
2 changes: 1 addition & 1 deletion mlos_bench/mlos_bench/config/schemas/config_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ def validate(self, config: dict) -> None:
else:
jsonschema.Draft202012Validator(
schema=self.schema,
registry=SCHEMA_STORE.registry, # type: ignore[call-arg]
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
registry=SCHEMA_STORE.registry,
).validate(config)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/services/remote/ssh/common-defs-subschemas.json",
"title": "mlos_bench SSH Service common defs config",
"description": "mlos_bench SSH Service common defs config",
"$defs": {
"ssh_service_config": {
"description": "SSH Service config.",
"type": "object",
"properties": {
"ssh_request_timeout": {
"description": "Request timeout in seconds, or null to disable timeout.",
"type": ["null", "number"],
"minimum": 1
},
"ssh_keepalive_interval": {
"description": "Whether to send keep alive packets to the remote machine(s).",
"type": ["null", "number"],
"minimum": 1
},
"ssh_port": {
"description": "Default port to use when connecting to the remote machine(s).",
"type": "integer",
"minimum": 1,
"maximum": 65535,
"examples": [22]
},
"ssh_username": {
"description": "Default username to use when connecting to the remote machine(s). If null or unspecified, will default to the value in ~/.ssh/config or the current user if not provided in another config.",
"type": ["null", "string"],
"examples": ["root"]
},
"ssh_priv_key_path": {
"$comment": "TODO: add support for multiple private keys or dynamically fetched private keys.",
"description": "Optional path to the private key to use when connecting to the remote machine(s). Keys are automatically searched for if not specified. Note: these should be passwordless or else an ssh-agent should be available via the SSH_AUTH_SOCK environment variable.",
"type": "string",
"examples": ["~/.ssh/id_rsa", "~/.ssh/id_ecdsa"]
},
"ssh_known_hosts_path": {
"description": "Path to known_hosts file. Set to null to disable host key checking.",
"type": ["null", "string"],
"examples": [null, "~/.ssh/known_hosts"]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/services/remote/ssh/ssh-fileshare-service-subschema.json",
"title": "mlos_bench SSH Fileshare Service config",
"description": "config for an mlos_bench SSH Fileshare Service",
"type": "object",
"properties": {
"class": {
"enum": [
"mlos_bench.services.remote.ssh.SshFileShareService",
"mlos_bench.services.remote.ssh.ssh_fileshare.SshFileShareService"
]
},
"config": {
"$ref": "./common-defs-subschemas.json#/$defs/ssh_service_config",
"minProperties": 1,
"unevaluatedProperties": false
}
},
"required": ["class"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/services/remote/ssh/ssh-host-service-subschema.json",
"title": "mlos_bench SSH Host Service config",
"description": "config for an mlos_bench SSH Host Service",
"type": "object",
"properties": {
"class": {
"enum": [
"mlos_bench.services.remote.ssh.SshHostService",
"mlos_bench.services.remote.ssh.ssh_host_service.SshHostService"
]
},
"config": {
"allOf": [
{
"$ref": "./common-defs-subschemas.json#/$defs/ssh_service_config"
},
{
"type": "object",
"properties": {
"ssh_shell": {
"type": "string",
"examples": [
"/bin/bash",
"/bin/sh"
]
}
}
}
],
"minProperties": 1,
"unevaluatedProperties": false
}
},
"required": ["class"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
{
"$ref": "./remote/mock/mock-auth-service-subschema.json"
},
{
"$ref": "./remote/ssh/ssh-host-service-subschema.json"
},
{
"$ref": "./remote/ssh/ssh-fileshare-service-subschema.json"
},
{
"$ref": "./remote/azure/azure-auth-service-subschema.json"
},
Expand Down
8 changes: 7 additions & 1 deletion mlos_bench/mlos_bench/services/remote/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
#
"""SSH remote service."""

# TODO
from mlos_bench.services.remote.ssh.ssh_host_service import SshHostService
from mlos_bench.services.remote.ssh.ssh_fileshare import SshFileShareService

__all__ = [
"SshHostService",
"SshFileShareService",
]
107 changes: 107 additions & 0 deletions mlos_bench/mlos_bench/services/remote/ssh/ssh_fileshare.py
bpkroth marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
"""
A collection functions for interacting with SSH servers as file shares.
"""

from enum import Enum
from typing import Tuple, Union

import logging

from asyncssh import scp, SFTPError, SSHClientConnection

from mlos_bench.services.base_fileshare import FileShareService
from mlos_bench.services.remote.ssh.ssh_service import SshService
from mlos_bench.util import merge_parameters

_LOG = logging.getLogger(__name__)


class CopyMode(Enum):
"""
Copy mode enum.
"""

DOWNLOAD = 1
UPLOAD = 2


class SshFileShareService(FileShareService, SshService):
"""A collection of functions for interacting with SSH servers as file shares."""

async def _start_file_copy(self, params: dict, mode: CopyMode,
local_path: str, remote_path: str,
recursive: bool = True) -> None:
# pylint: disable=too-many-arguments
"""
Starts a file copy operation

Parameters
----------
params : dict
Flat dictionary of (key, value) pairs of parameters (used for establishing the connection).
mode : CopyMode
Whether to download or upload the file.
local_path : str
Local path to the file/dir.
remote_path : str
Remote path to the file/dir.
recursive : bool, optional
_description_, by default True

Raises
------
OSError
If the local OS returns an error.
SFTPError
If the remote OS returns an error.
"""
connection, _ = await self._get_client_connection(params)
srcpaths: Union[str, Tuple[SSHClientConnection, str]]
dstpath: Union[str, Tuple[SSHClientConnection, str]]
if mode == CopyMode.DOWNLOAD:
srcpaths = (connection, remote_path)
dstpath = local_path
elif mode == CopyMode.UPLOAD:
srcpaths = local_path
dstpath = (connection, remote_path)
else:
raise ValueError(f"Unknown copy mode: {mode}")
return await scp(srcpaths=srcpaths, dstpath=dstpath, recurse=recursive, preserve=True)

def download(self, params: dict, remote_path: str, local_path: str, recursive: bool = True) -> None:
params = merge_parameters(
dest=self.config.copy(),
source=params,
required_keys=[
"ssh_hostname",
]
)
super().download(params, remote_path, local_path, recursive)
file_copy_future = self._run_coroutine(
self._start_file_copy(params, CopyMode.DOWNLOAD, local_path, remote_path, recursive))
try:
file_copy_future.result()
except (OSError, SFTPError) as ex:
_LOG.error("Failed to download %s to %s from %s: %s", remote_path, local_path, params, ex)
raise ex

def upload(self, params: dict, local_path: str, remote_path: str, recursive: bool = True) -> None:
params = merge_parameters(
dest=self.config.copy(),
source=params,
required_keys=[
"ssh_hostname",
]
)
super().upload(params, local_path, remote_path, recursive)
file_copy_future = self._run_coroutine(
self._start_file_copy(params, CopyMode.UPLOAD, local_path, remote_path, recursive))
try:
file_copy_future.result()
except (OSError, SFTPError) as ex:
_LOG.error("Failed to upload %s to %s on %s: %s", local_path, remote_path, params, ex)
raise ex
Loading