Commit Graph

901 Commits

Author SHA1 Message Date
psychedelicious
1652143671 feat(batches): defer ges *and* batch session creation until execution time 2023-08-22 00:54:17 +10:00
psychedelicious
88ae19a768 feat(batches): defer ges creation until execution
This improves the overall responsiveness of the system substantially, but does make each iteration *slightly* slower, distributing the up-front cost across the batch.

Two main changes:

1. Create BatchSessions immediately, but do not create a whole graph execution state until the batch is executed.
BatchSessions are created with a `session_id` that does not exist in sessions database.
The default state is changed to `"uninitialized"` to better represent this.

Results: Time to create 5000 batches reduced from over 30s to 2.5s

2. Use `executemany()` to retrieve lists of created sessions.
Results: time to create 5000 batches reduced from 2.5s to under 0.5s

Other changes:

- set BatchSession state to `"in_progress"` just before `invoke()` is called
- rename a few methods to accomodate the new behaviour
- remove unused `BatchProcessStorage.get_created_sessions()` method
2023-08-21 22:22:19 +10:00
psychedelicious
50816432dc
Merge branch 'main' into feat/batch-graphs 2023-08-21 19:51:41 +10:00
psychedelicious
b98c9b516a feat: add batch docstrings 2023-08-21 19:51:16 +10:00
psychedelicious
a15a5bc3b8 fix(api): correct get_batch response model 2023-08-21 19:51:02 +10:00
psychedelicious
0909812c84 chore: black 2023-08-21 19:17:15 +10:00
psychedelicious
66c0aea9e7 fix(nodes): removed duplicate node 2023-08-21 19:17:15 +10:00
Damian Stewart
2bcded78e1 add BlendInvocation 2023-08-21 19:17:15 +10:00
Sergey Borisov
beb3e5aeb7 Report correctly to compel if we want get pooled in future(affects blend computation) 2023-08-21 19:05:40 +10:00
Brandon Rising
137fbacb92 Fix flake8 2023-08-18 15:47:27 -04:00
Brandon Rising
4b6d9a73ed Merge branch 'main' into feat/batch-graphs 2023-08-18 15:40:34 -04:00
Brandon Rising
3e26214b83 Add a few more endpoints for managing batches 2023-08-18 15:38:16 -04:00
Brandon Rising
0282f46c71 Add runs field for running the same batch multiple times 2023-08-18 13:41:07 -04:00
Brandon Rising
99e03fe92e Run unmodified graph if no batch data is provided 2023-08-18 13:33:09 -04:00
Martin Kristiansen
537ae2f901 Resolving merge conflicts for flake8 2023-08-18 15:52:04 +10:00
Brandon Rising
cb65526880 More session not found handling 2023-08-17 14:23:12 -04:00
psychedelicious
59bc9ed399 fix(backend): handle BatchSessionNotFoundException in BatchManager._process()
The internal `BatchProcessStorage.get_session()` method throws when it finds nothing, but we were not catching any exceptions.

This caused a exception when the batch manager handles a `graph_execution_state_complete` event that did not originate from a batch.

Fixed by handling the exception.
2023-08-17 13:58:11 +10:00
psychedelicious
e62d5478fd fix(backend): fix sqlite cannot commit - no transaction is active
The `commit()` was called even if we hadn't executed anything
2023-08-17 13:55:38 +10:00
psychedelicious
cc3c2756bd feat(backend): rename batch changes variable
`updateSession` -> `changes`
2023-08-17 13:32:32 +10:00
psychedelicious
67cf594bb3 feat(backend): add missing types to batch_manager_storage.py 2023-08-17 13:29:19 +10:00
psychedelicious
c5b963f1a6 fix(backend): typo
`relavent` -> `relevant`
2023-08-17 12:47:58 +10:00
psychedelicious
4d2dd6bb10 feat(backend): rename BatchManager.process to _process
Just to make it clear that this is not a method on the ABC.
2023-08-17 12:47:05 +10:00
psychedelicious
7e4beab4ff feat(backend): surface BatchSessionNodeFoundException
Catch this exception in the router and return an appropriate `HTTPException`.
2023-08-17 12:45:32 +10:00
psychedelicious
e16b5f7cdc feat(backend): deserialize batch session directly
If the values from the `session_dict` are invalid, the model instantiation will fail, or if we end up with an invalid `batch_id`, the app will not run. So I think just parsing the dict directly is equivalent.

Also the LSP analyser is pleased now - no red squigglies.
2023-08-17 12:37:03 +10:00
psychedelicious
1f355d5810 feat(backend): update batch_manager_storage.py docstrings 2023-08-17 12:31:51 +10:00
psychedelicious
df7370f9d9 chore(backend): remove unused code 2023-08-17 12:16:34 +10:00
psychedelicious
5bec64d65b fix(backend): fix typings in batch_manager.py
- `batch_indicies` is `tuple[int]` not `list[int]`
- explicit `None` return values
2023-08-17 12:07:20 +10:00
psychedelicious
8cf9bd47b2 chore(backend): remove unnecessary batch validation function
The `Batch` model is fully validated by pydantic on instantiation; we do not need any validation logic for it.
2023-08-17 11:59:47 +10:00
psychedelicious
c91621b46c fix(backend): BatchProcess.batch_id is required
Providing a `default_factory` is enough for pydantic to know to create the attribute on instantiation if it's not already provided. We can then make make the typing just `str`.
2023-08-17 11:58:29 +10:00
psychedelicious
f246b236dd fix(api): fix start_batch route responses 2023-08-17 11:51:14 +10:00
Lincoln Stein
daf75a1361 blackify 2023-08-16 21:47:29 -04:00
Lincoln Stein
c39f8b478b fix misplaced ram_used and ram_changed attributes 2023-08-16 21:39:18 -04:00
Lincoln Stein
2ca8611723 add +/- sign in front of RAM delta 2023-08-16 15:53:01 -04:00
Brandon Rising
f7277a8b21 Run python black 2023-08-16 15:44:52 -04:00
Brandon Rising
796ff34c8a Testing out Spencer's batch data structure 2023-08-16 15:21:11 -04:00
Brandon Rising
d6a5c2dbe3 Fix tests 2023-08-16 14:35:49 -04:00
Brandon
ef8dc2e8c5
Merge branch 'main' into feat/batch-graphs 2023-08-16 14:03:34 -04:00
Lincoln Stein
b12cf315a8
Merge branch 'main' into feat/collect-more-stats 2023-08-16 09:19:33 -04:00
psychedelicious
43b30355e4 feat: make primitive node titles consistent 2023-08-16 23:04:36 +10:00
Lincoln Stein
a93bd01353 fix bad merge 2023-08-16 08:53:07 -04:00
Lincoln Stein
be8edaf3fd
Merge branch 'main' into feat/collect-more-stats 2023-08-16 08:48:14 -04:00
Brandon
314891a125
Merge branch 'main' into feat/batch-graphs 2023-08-15 22:42:49 -04:00
Lincoln Stein
21e1c0a5f0 tweaked formatting 2023-08-15 22:25:30 -04:00
psychedelicious
8b1ec2685f chore: black 2023-08-16 12:07:34 +10:00
psychedelicious
60c2c877d7 fix: add response model for star/unstar routes
- also implement pessimistic updates for starring, only changing the images that were successfully updated by backend
- some autoformat changes crept in
2023-08-16 12:07:34 +10:00
maryhipp
80b0c5eab4 change from pin to star 2023-08-16 12:07:34 +10:00
maryhipp
ee6a26a97d update list images endpoint to sort by pinnedness and then created_at 2023-08-16 12:07:34 +10:00
maryhipp
04a9894e77 (api) add ability to pin and unpin images 2023-08-16 12:07:34 +10:00
Lincoln Stein
f9958de6be added memory used to load models 2023-08-15 21:56:19 -04:00
Brandon Rising
2d3094f988 Run python black 2023-08-15 21:51:45 -04:00