2100 Commits

Author SHA1 Message Date
Sybren A. Stüvel
9d46822657 Add-on: Job submission: always call self._quit() before stopping
In the job submission operator, always call `self._quit()` before it stops.
It's just good practice to clean up.
2024-06-25 17:50:51 +02:00
Sybren A. Stüvel
1056699e4a Add-on: prevent potentially crashing Blender
Prevent a potential crash of Blender. Calling
`context.window_manager.modal_handler_add(self)` from an operator that does
not actually run modally can cause problems. So now that's called only
when running modally.
2024-06-25 17:49:06 +02:00
Sybren A. Stüvel
f7a1e92e82 Manager: fix panic on task timeout
Fix an issue where a timed-out task would cause a panic, as it wasn't
fetching its Job UUID.

I see this as working around a limitation of GORM, which should get
replaced with sqlc soon-ish anyway.
2024-06-25 12:24:30 +02:00
Sybren A. Stüvel
de6aecfe81 Add-on: fix mypy errors
Ensure the job settings label is a string, even when the value in the
custom job type's `JOB_INFO` dictionary is of a different type.
2024-06-25 12:13:17 +02:00
Sybren A. Stüvel
963133bd59 Add-on: allow scripted job submissions from Blender
The `bpy.ops.flamenco.submit_job(job_name="jobname")` operator can now be
executed from Python. In that case, it will block the main thread until
the job submission is complete.
2024-06-25 12:11:20 +02:00
Sybren A. Stüvel
152adcb777 Add-on: document timeout parameter of PackThread.poll()
The timeout should be specified in seconds, which wasn't documented before.

No functional changes.
2024-06-25 12:10:28 +02:00
Sybren A. Stüvel
c41eda4a09 Add-on: refactor job submission in preparation for 'execute' support
Refactor the job submission operator, to make it easier to allow executing
the operator (that is, running in the foreground, blocking execution until
submission is done).

No functional changes.
2024-06-25 12:01:18 +02:00
Sybren A. Stüvel
2b3cb307bd Website: publish 3.6-alpha1 as latest experimental version 2024-06-25 11:27:53 +02:00
Sybren A. Stüvel
d3a3178300 Bumped version to 3.6-alpha1 2024-06-25 11:26:12 +02:00
Sybren A. Stüvel
7ffbd72dce Manager: normalise slashes when expanding two-way variables
When expanding the `{shared}` variable in a path like
`{shared}\shot\file.blend`, all slashes will be normalised to the target
platform, so for example result in:

- Windows: `Y:\shared\flamenco\shot\file.blend`
- Linux  : `/shared/flamenco/shot/file.blend`

Due to this normalisation, the same paths will be served to these
platforms when the path was `{shared}/shot/file.blend`.
2024-06-25 11:24:27 +02:00
Sybren A. Stüvel
5249744d0a Manager: variable replacement, remove warning when no variables exist
It's perfectly fine to run Flamenco without any variables, so do not log
a warning when this situation occurs.
2024-06-25 11:24:15 +02:00
Sybren A. Stüvel
374a8c0a6f Manager: remove introduction comments from the query SQL
Remove the introductionary comments from `query_jobs.sql` and
`query_workers.sql`. Sqlc got confused by this, and placed them in the
wrong (well, not-intended-by-me) place in the generated Go code.

No functional changes.
2024-06-08 21:35:41 +02:00
Sybren A. Stüvel
5a31336efb Manager: Convert 'last-rendered' to sqlc
Convert 'last-rendered' to sqlc. The query is slightly suboptimal.
There's a bug in sqlc: the `ON CONFLICT DO UPDATE` clause is generated
incorrectly. See https://github.com/sqlc-dev/sqlc/issues/3334 for more
info.
2024-06-08 21:30:00 +02:00
Sybren A. Stüvel
1ec65e8c29 Cleanup: fix comment
Fix a comment in a unit test. No functional changes.
2024-06-08 20:55:54 +02:00
Sybren A. Stüvel
f05e87860c Bump Go version to 1.22.4 2024-06-08 20:55:54 +02:00
Sybren A. Stüvel
7c8a700187 Webapp: only emit 'activeJobDeleted' event when the active job was deleted
Only emit the `activeJobDeleted` event when the active job was deleted.
Previously this was emitted on _any_ job deletion, which would make working
with the web interface quite confusing when mass deletion was happening,
as it would always deselect the job, even when showing an unrelated job.
2024-06-06 16:46:51 +02:00
Sybren A. Stüvel
8b01012539 Website: document more of the sqlc workflow
Document installation & use of sqlc.

Installing sqlc is only necessary to regenerate the database code. Once
generated, the code is independent of sqlc.
2024-05-30 09:50:17 +02:00
Sybren A. Stüvel
7a9f809c43 Manager: convert more worker functions to sqlc
No functional changes.
2024-05-28 18:20:15 +02:00
Sybren A. Stüvel
9a229a7b8f Manager: Convert CreateWorker to sqlc
No functional changes.
2024-05-28 18:20:07 +02:00
Sybren A. Stüvel
0c4240ec3a Manager: make some db fields boolean instead of smallint
Turn `workers.lazy_status_request` and `workers.can_restart` into a
`boolean`. They were `smallint` before.

Having these explicitly modeled as `boolean` will make sqlc generate the
right type for them.

No functional changes.
2024-05-28 18:15:21 +02:00
Sybren A. Stüvel
ee31316d9d Manager: more gracefully log context cancellation errors in database layer
The context passed to the database layer will auto-close when the HTTP
client disconnects. This will cancel any running query, which is the
expected behaviour. Now this no longer results in an error being logged
in the database layer. Instead, a message is logged at debug level.

The API layer is also adjusted to silence logging of `context.Canceled`
for certain operations, most notably getting all jobs and getting all
tasks of a job. These calls occur when the webapp reconnects after a
restart of the Manager. That may trigger a refresh of the page, which
immediately aborts any pending API calls. This is normal and should not
cause errors to be logged.
2024-05-28 17:27:27 +02:00
Sybren A. Stüvel
ee4e41329a Manager: properly set task.JobUUID and task.WorkerUUID when using GORM
Add a GORM hook that sets `task.JobUUID` and `.WorkerUUID`. These were
only set by the sqlc code; this change ensures that they are now always
set, so that the caller doesn't have to worry about which function is
already ported to sqlc and which one is still GORM.
2024-05-28 16:34:09 +02:00
Sybren A. Stüvel
7fd8eca8d9 Manager: more gracefull handle SQLite "interrupted (9)" error
Wrap the SQLite error "interrupted (9)". That error is (as far as I
could figure out) caused by the context being closed. Unfortunately
there is no wrapping of the underlying context error, so it's not
possible to determine whether it was due to a 'deadline exceeded' error
or another cancellation cause (like upstream HTTP connection closing).

Primarily this makes a rather unreliable unit test properly reliable.
The code under test could return either `context.DeadlineExceeded` or
the "interrupted (9)" error (GORM + SQLite doesn't reliably chose one or
the other), and now this is cleanly tested for.
2024-05-28 16:07:23 +02:00
Sybren A. Stüvel
572089f13b Manager: speed up sequential job deletion by checking db when queue empty
Job deletions are placed in an in-memory queue in batches of 100 jobs.
Between batches the Manager's job deleter would idle for 1 minute. Now,
once the in-memory queue has been emptied, the job deleter will wait
only 100ms before checking the database again.

This 100ms might not be necessary either, but I think it's nice to give
the Manager a bit of a breather before diving into another batch of
deletions.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
286d0efa2d Manager: speed up job deletion by skipping the DB integrity check
Speed up the deletion of multiple jobs by skipping the database integrity
check. It is now clear what was causing the integrity issues (disabled
foreign key constraints), and this is now checked for before deleting
anything. This reduces the deletion time from ~500ms per job to ~150ms
(on my computer, with my database, of course).
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
390cb9445c Manager: log duration of job deletion
When a job has been deleted, log how long it took to delete.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
5ec479a983 Manager: remove testing.T parameter from some test setup functions
Replace the use of the `t *testing.T` parameter with just plain `panic()`
when test setup fails. This makes it easier to call the same functions
from other situations, like benchmark functions.

No functional changes to Flamenco itself.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
88f90ef0a5 Manager: properly close database at end of test
Instead of closing the sqlite database connection, tell GORM to close the
connection. Only that properly closes the DB, so that testing with a file
on disk doesn't fail when trying to delete that file.

No functional changes to the Manager itself.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
98cbe6a67d Manager: lightly polish job deletion
Tweak the logging a little bit so it's less noisy, properly warns when the
Shaman checkout dir cannot be removed, and optimise the database query
a bit (by just fetching the one field that's needed, instead of the entire
job).

Deletion still works the same.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
79076be91b Manager: Convert task failure persistence to SQLC
No functional changes.
2024-05-28 16:07:22 +02:00
Sybren A. Stüvel
a99e68ec99 Manager: Convert TaskTouchedByWorker to sqlc
No functional changes.
2024-05-28 16:07:21 +02:00
Sybren A. Stüvel
7175bb469b Manager: Convert UpdateJobsTaskStatuses(Conditional) to sqlc
No functional changes.
2024-05-28 16:07:21 +02:00
Sybren A. Stüvel
4435633756 Manager: Convert FetchTasksOfJob() and FetchTasksOfJobInStatus() to sqlc
No functional changes.
2024-05-28 16:07:21 +02:00
Sybren A. Stüvel
4ab853da40 Manager: Convert JobHasTasksInStatus and CountTasksOfJobInStatus to sqlc
No functional changes.
2024-05-28 16:07:21 +02:00
Sybren A. Stüvel
b66490831c Manager: fetch jobs of tasks in FetchTasksOfWorkerInStatus()
The task state machine expects that `task.Job` is set correctly. Since
SQLC does not automatically fill this field (and rightfully so), I've added
a bit of Go code that fetches the job in a separate query.

A TODO is added as a reminder that it would be better for the task state
machine itself to fetch the job when needed.
2024-05-28 16:07:17 +02:00
Sybren A. Stüvel
1e327c510e Manager: Convert FetchTasksOfWorkerInStatusOfJob to sqlc
No functional changes.
2024-05-28 14:46:43 +02:00
Sybren A. Stüvel
950d661377 Manager: convert TaskAssignToWorker and FetchTasksOfWorkerInStatus to sqlc
No functional changes.
2024-05-28 14:46:43 +02:00
Sybren A. Stüvel
dcca9aef03 Manager: convert db.SaveTaskActivity() to SQLC
No functional changes.
2024-05-28 14:46:42 +02:00
Sybren A. Stüvel
a9be729e59 Manager: Convert db.SaveTaskStatus() to SQLC
No functional changes.
2024-05-28 14:46:42 +02:00
Sybren A. Stüvel
a54972ddd0 Manager: Convert db.SaveTask() to SQLC
No functional changes.
2024-05-28 14:46:42 +02:00
Sybren A. Stüvel
f632f2dbb6 SQLC: upgrade to 1.26.0
Doesn't change anything function in the generated code, just the version
numbers & handling of empty comments in the query file.
2024-05-28 14:46:42 +02:00
Sybren A. Stüvel
c1cdff567e Manager: Convert FetchTask to sqlc
This is a bit more work than other queries, as it also breaks apart the
fetching of the job and the worker into separate ones. In other words,
internally the persistence layer API changes.
2024-05-28 14:46:42 +02:00
Sybren A. Stüvel
dc893dcad4 Manager: regenerate Go mock after removal of SaveTask
Regenerate the Go mock implementation after the removal of the SaveTask
function from the mocked interface.

See 097d5abb7c13e6eff1facea12f89f24c144194c0
2024-05-28 14:45:34 +02:00
Sybren A. Stüvel
eba340cedc Bump Go version to 1.22.3
Update Go from 1.22.2 to 1.22.3 (released 2024-05-07)

It includes security fixes to the go command and the net package, as
well as bug fixes to the compiler, the runtime, and the net/http
package.
2024-05-28 08:59:59 +02:00
Sybren A. Stüvel
94923c628d Manager: increase wait time in worker timeout test
Instead of waiting for 1ns, wait for 1ms. That's more stable on my laptop,
and still short enough to not really slow down the test.
2024-05-28 08:53:15 +02:00
Sybren A. Stüvel
097d5abb7c Manager: Remove SaveTask function from interface
Remove `SaveTask(...)` from the persistence layer interface as defined
by the `api_impl` package. It's not used.
2024-05-28 08:53:15 +02:00
Sybren A. Stüvel
2d5de525d0 Website: add FAQ entry about doubling of backslashes in paths 2024-05-27 13:03:01 +02:00
Sybren A. Stüvel
1ac1deaead Document useful git config in gitattributes 2024-05-21 00:57:43 +02:00
Sybren A. Stüvel
422708fffc .gitattributes: mark .sql files as text 2024-05-21 00:57:43 +02:00
Sybren A. Stüvel
c307342f9d OAPI: regenerate code 2024-05-20 10:09:22 +02:00