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

feat(api, robot-server): get historical and current command errors #16697

Merged
merged 63 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
282c99c
WIP intial schema and orchestrator changes
TamarZanzouri Nov 1, 2024
1bb8d7c
changed schema and imports to 8
TamarZanzouri Nov 1, 2024
77902c6
insert the errors to the DB
TamarZanzouri Nov 4, 2024
15db246
refactor into commands table
TamarZanzouri Nov 4, 2024
b88e722
select from commands
TamarZanzouri Nov 4, 2024
b6d33b6
linting and command error slice done
TamarZanzouri Nov 5, 2024
85eda17
added tests and fixed bugs
TamarZanzouri Nov 5, 2024
5bc0500
changed logic for current command errors
TamarZanzouri Nov 5, 2024
e423f37
removed failed_command_errors from state
TamarZanzouri Nov 5, 2024
e29d95f
refactor get command errors
TamarZanzouri Nov 5, 2024
c275c35
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 6, 2024
a950cb8
migration and initialization fixes
TamarZanzouri Nov 6, 2024
55a809a
Update robot-server/robot_server/runs/run_store.py
TamarZanzouri Nov 6, 2024
1ccaba3
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 6, 2024
9fa97ba
change get_run_errors to get count
TamarZanzouri Nov 6, 2024
f5fe016
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 6, 2024
13c5b87
tables tests fixed
TamarZanzouri Nov 6, 2024
a88e95d
added test for historical run
TamarZanzouri Nov 6, 2024
6fea08a
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 6, 2024
1bea28e
fixed persistance path
TamarZanzouri Nov 6, 2024
8f73bc1
fixed import from schema 7
TamarZanzouri Nov 7, 2024
c87dc65
rollback add_column change
TamarZanzouri Nov 7, 2024
5405ef3
append_failed_command_id when setting a failed command
TamarZanzouri Nov 7, 2024
f888364
append_failed_command_id when setting a failed command
TamarZanzouri Nov 7, 2024
e6aa375
moved test to command state
TamarZanzouri Nov 8, 2024
66856ac
changed index and lint
TamarZanzouri Nov 8, 2024
02e6806
WIP - command status
TamarZanzouri Nov 8, 2024
37a4aff
fixed failing tests
TamarZanzouri Nov 8, 2024
6c6257f
insert and get with command_status
TamarZanzouri Nov 8, 2024
56d12c4
translate to CommandStatusSQLEnum
TamarZanzouri Nov 8, 2024
c33745b
nips
TamarZanzouri Nov 12, 2024
635a5af
Update robot-server/tests/runs/test_run_store.py
TamarZanzouri Nov 12, 2024
a16636b
nits
TamarZanzouri Nov 12, 2024
a873369
batch edit
TamarZanzouri Nov 13, 2024
67b6d53
batch update without binding
TamarZanzouri Nov 13, 2024
4d00c99
test table with new index and migration bulk fix
TamarZanzouri Nov 13, 2024
38cd6ea
conditional update
TamarZanzouri Nov 13, 2024
1160174
map command status to sql command status
TamarZanzouri Nov 13, 2024
18ce80c
map command status to sql command status in migration
TamarZanzouri Nov 13, 2024
964fddc
map command status to sql command status in migration
TamarZanzouri Nov 13, 2024
5ad4d0d
add missing indexes
TamarZanzouri Nov 13, 2024
de02268
lint
TamarZanzouri Nov 13, 2024
085d4bb
change conversion into enum
TamarZanzouri Nov 13, 2024
378eec1
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 13, 2024
ec64c12
fixing merge conflicts - WIP
TamarZanzouri Nov 14, 2024
b285c99
WIP - fix test_tables failing
TamarZanzouri Nov 14, 2024
3a29bfd
update test table
TamarZanzouri Nov 20, 2024
dca8269
Revert "update test table"
TamarZanzouri Nov 20, 2024
4d91d6f
Fix schema_8.py after merge.
SyntaxColoring Nov 14, 2024
fd78ad3
Fix up test_tables.py after merge.
SyntaxColoring Nov 14, 2024
b59601e
Remove attempts to fix prior migrations, for now.
SyntaxColoring Nov 20, 2024
6496d3c
Make command_status column nullable to match what the migration does.
SyntaxColoring Nov 20, 2024
11aa280
Remove enum constraint, for now.
SyntaxColoring Nov 20, 2024
5af324e
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
SyntaxColoring Nov 20, 2024
6669e61
Update robot-server/robot_server/persistence/_migrations/v7_to_v8.py
TamarZanzouri Nov 21, 2024
ce3fbb3
Update robot-server/robot_server/runs/run_store.py
TamarZanzouri Nov 21, 2024
e0aacbd
select subquery and minor fixes
TamarZanzouri Nov 21, 2024
b10e8a2
fixed join logic and added logic to the tests
TamarZanzouri Nov 22, 2024
13fd3a8
fixed logic of cursor
TamarZanzouri Nov 22, 2024
55d190e
remove join
TamarZanzouri Nov 25, 2024
68cfdf7
Update robot-server/robot_server/runs/run_store.py
TamarZanzouri Nov 25, 2024
70733de
Merge branch 'edge' into EXEC-655-store-commands-error-list-in-db
TamarZanzouri Nov 25, 2024
86510ec
import from schema_7
TamarZanzouri Nov 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _migrate_command_table_with_new_command_error_col_and_command_status(
for row in dest_transaction.execute(select_commands).all():
TamarZanzouri marked this conversation as resolved.
Show resolved Hide resolved
data = json.loads(row.command)
new_command_error = (
# Account for old_row.command["error"] being NULL.
# Account for old_row.command["error"] being null.
None
if "error" not in row.command or data["error"] == None # noqa: E711
if "error" not in row.command or data["error"] is None
else json.dumps(data["error"])
)
# parse json as enum
Expand Down
2 changes: 2 additions & 0 deletions robot-server/robot_server/persistence/tables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ProtocolKindSQLEnum,
BooleanSettingKey,
DataFileSourceSQLEnum,
CommandStatusSQLEnum,
)


Expand All @@ -36,4 +37,5 @@
"ProtocolKindSQLEnum",
"BooleanSettingKey",
"DataFileSourceSQLEnum",
"CommandStatusSQLEnum",
]
19 changes: 13 additions & 6 deletions robot-server/robot_server/runs/run_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from .action_models import RunAction, RunActionType
from .run_models import RunNotFoundError
from ..persistence.tables.schema_8 import CommandStatusSQLEnum
from ..persistence.tables import CommandStatusSQLEnum

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -613,19 +613,26 @@ def get_commands_errors_slice(
actual_cursor = cursor if cursor is not None else count_result - length
# Clamp to [0, count_result).
SyntaxColoring marked this conversation as resolved.
Show resolved Hide resolved
actual_cursor = max(0, min(actual_cursor, count_result - 1))
select_command_errors = (
sqlalchemy.select(run_command_table)
.where(run_command_table.c.command_error is not None)
.subquery()
TamarZanzouri marked this conversation as resolved.
Show resolved Hide resolved
)
TamarZanzouri marked this conversation as resolved.
Show resolved Hide resolved
select_slice = (
sqlalchemy.select(
run_command_table.c.index_in_run,
run_command_table.c.command_error,
)
sqlalchemy.select(run_command_table.c.command_error)
.where(
and_(
run_command_table.c.run_id == run_id,
run_command_table.c.index_in_run >= actual_cursor,
run_command_table.c.index_in_run < actual_cursor + length,
run_command_table.c.command_error is not None,
)
)
.join_from(
run_command_table,
select_command_errors,
onclause=run_command_table.c.index_in_run
== select_command_errors.c.index_in_run,
)
.order_by(run_command_table.c.index_in_run)
)
slice_result = transaction.execute(select_slice).all()
Expand Down
2 changes: 2 additions & 0 deletions robot-server/tests/runs/test_run_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ async def test_update_run_state_command_with_errors(
cursor=0,
)

print(command_errors_result)
TamarZanzouri marked this conversation as resolved.
Show resolved Hide resolved

assert command_errors_result.commands_errors == [
item.error for item in protocol_commands_errors
]
Expand Down
Loading