Skip to content

Commit 7090ed9

Browse files
Remote assistant refactoring (new) (#2057)
* Full refactoring backported to remote_assistant.py * Backport controller refactoring Forgotten removed api * Fix unit tests by renaming apis and changing whats_up response * Refactored allowed_when and _state -> state Decorator was moved to top level of the module, state now has a non-private property (that logs transitions) and was changed accordingly Minor fix: use .state and not ._state in decorator * Renamed resume_session to prepare_resume_session Minor: forgotten 2 state comparison to str instead of new enum * Missing bootstrap_and_continue * Remove outdated resume machanism * Check that all states have a connection_strategy * Support optional parameters of interaction * Include test plan in session metadata * Move functions, rename functions that continue with _continue * Default value of resume_by_id should be empty dict * Propagate prepare_resume_session * Also update name in the test * Don't finalize the session until resume is decided This removes session finalization in all branches. It was added because the start_new_sesison function starts a new session, so it fails on the second iteration. The correct solution to this was not to spam finalize everywhere but to split that function up into start and select_test_plan (thanks me, I know you did this to me) * Port renames and new _continue process to tests * Also fix local changes to subcommands * Test test plan selection function Minor: use new continue session function * Disable fail-fast * Update checkbox-ng/checkbox_ng/launcher/controller.py Co-authored-by: Fernando Bravo <[email protected]> --------- Co-authored-by: Fernando Bravo <[email protected]>
1 parent 0c78444 commit 7090ed9

File tree

10 files changed

+575
-512
lines changed

10 files changed

+575
-512
lines changed

.github/workflows/tox-checkbox.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ permissions:
33
contents: read
44
on:
55
push:
6-
branches: [ main ]
76
paths:
87
- checkbox-ng/**
98
- checkbox-support/**
@@ -18,7 +17,6 @@ on:
1817
- providers/iiotg/**
1918
- .github/workflows/tox-checkbox.yaml
2019
pull_request:
21-
branches: [ main ]
2220
paths:
2321
- checkbox-ng/**
2422
- checkbox-support/**
@@ -95,6 +93,7 @@ jobs:
9593
tox_test_checkbox_component:
9694
needs: get_path_matrix
9795
strategy:
96+
fail-fast: false
9897
matrix:
9998
path_flag: ${{ fromJson(needs.get_path_matrix.outputs.path_flag) }}
10099
python: ["3.5", "3.6", "3.8", "3.10", "3.12"]

checkbox-ng/checkbox_ng/launcher/agent.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,6 @@ def invoked(self, ctx):
146146
lambda x: None
147147
)
148148

149-
# the agent is meant to be run only as a service,
150-
# and we always resume if the session was automated,
151-
# so we don't need to encode check whether we should resume
152-
153-
sessions = list(ctx.sa.get_resumable_sessions())
154-
if sessions:
155-
# the sessions are ordered by time, so the first one is the most
156-
# recent one
157-
if is_the_session_noninteractive(sessions[0]):
158-
SessionAssistantAgent.session_assistant.resume_by_id(
159-
sessions[0].id
160-
)
161-
162149
self._server = ThreadedServer(
163150
SessionAssistantAgent,
164151
port=agent_port,
@@ -184,25 +171,6 @@ def register_arguments(self, parser):
184171
)
185172

186173

187-
def is_the_session_noninteractive(
188-
resumable_session: "ResumeCandidate",
189-
) -> bool:
190-
"""
191-
Check if given session is non-interactive.
192-
193-
To determine that we need to take the original launcher that had been used
194-
when the session was started, recreate it as a proper Launcher object, and
195-
check if it's in fact non-interactive.
196-
"""
197-
# app blob is a bytes string with a utf-8 encoded json
198-
# let's decode it and parse it as json
199-
app_blob = json.loads(resumable_session.metadata.app_blob.decode("utf-8"))
200-
launcher = Configuration.from_text(
201-
app_blob.get("launcher", ""), "resumed session"
202-
)
203-
return launcher.sections["ui"].get("type") == "silent"
204-
205-
206174
def exit_if_port_unavailable(port: int) -> None:
207175
"""
208176
Check if the port is available and exit if it's not.

0 commit comments

Comments
 (0)