Commit Graph

2023 Commits

Author SHA1 Message Date
David Zhang
00848a3755 Manager: backend for submitting jobs in paused status
With a new `initial_status` field, the user could choose whether to submit a job in `paused` status.

Pull request: https://projects.blender.org/studio/flamenco/pulls/104322
2024-07-09 22:57:01 -04:00
David Zhang
376112b392 OAPI: regenerate code 2024-07-09 22:57:00 -04:00
David Zhang
6f3ba146de OAPI: add initial_status field in SubmittedJob
Pull request: https://projects.blender.org/studio/flamenco/pulls/104322
2024-07-09 22:56:59 -04:00
3b2b5c47f3 Manager: convert FetchWorkerTask() from gorm to sqlc
Ref: #104305

No functional changes
2024-07-02 10:16:41 +02:00
7db91294c2 Manager: fix unit test TestFetchWorkerTask reliability
The unit test was using the real clock, and depends on ordering by
last-updated timestamps. This means that sometimes two updates both fell
within the granularity of the timestamp in sqlite, which made the
ordering unreliable.

Switching to a mocked clock fixes this, as it moves forward with a hard-
coded pace, regardless of the execution speed of the test.

No functional changes to Flamenco itself.
2024-07-02 10:00:08 +02:00
David Zhang
aac55e7e3c Manager: Support pausing jobs
A job first goes to `pause-requested` status, during which any `active` task
gets a chance to be completed. Once there are no more active tasks, the job
goes to `paused` state (or `failed`, if that is applicable).

Pull request: https://projects.blender.org/studio/flamenco/pulls/104313
2024-07-01 10:59:37 -04:00
David Zhang
1330487078 OAPI: regenerate code 2024-07-01 10:46:57 -04:00
David Zhang
8a82b1ee0a OAPI: add pause-requested job status
Pull request: https://projects.blender.org/studio/flamenco/pulls/104313
2024-07-01 10:44:46 -04:00
46d56a7b49 Mark go.sum as 'generated'
The `go.sum` file is not directly managed, but just the result of running
`go get`, `go mod tidy`, etc.
2024-07-01 11:59:52 +02:00
7d8afb5be7 Worker: reduce log level of last-rendered-image processing
Reduce the log level from 'info' to 'debug' for the "output uploader:
processing file before uploading to Manager" message.
2024-07-01 11:34:22 +02:00
842d1ab9a4 Manager: convert storing authored jobs from gorm to sqlc
Convert the creation of new jobs & tasks in the database (which happens
by storing the 'authored job' + its tasks) from gorm to sqlc.
2024-06-30 23:31:28 +02:00
bfe47ea394 Manager: convert task scheduler from gorm to sqlc
Convert the task scheduler from gorm to sqlc. This makes the query
considerably easier to read.

No functional changes intended.
2024-06-30 21:18:08 +02:00
d86c97d06e Manager: Use require.XXX() functions in task scheduler test
Instead of explicitly checking errors / nil values and calling
`t.Fatal()`, just use `require.NoError()` or `require.NotNil()`.

No functional changes. The wording of test failures will be slightly
different though.
2024-06-30 21:18:00 +02:00
6e52d41968 Manager: more sqlc to gorm conversionfunctions for jobs & tasks
Some reorganisation to make it easier to convert a job & its tasks from
sqlc to gorm data structures.

The persistence layer is being converted to sqlc. Once that is done, the
remainder of the code can switch over from using gorm structs to sqlc
structs. Then this code will no longer be necessary.
2024-06-30 21:17:53 +02:00
6fb8ab92e2 Bumped version to 3.6-alpha3 2024-06-27 09:58:55 +02:00
a00c1daac6 Website: bump experimental version to 3.6-alpha2 2024-06-27 09:58:31 +02:00
38f41c096c Make clean after building release packages
To prevent non-native binaries from polluting the working directory, also
run `make clean` after building the release packages.
2024-06-27 09:57:09 +02:00
8b08b91840 Bump golang.org/x/image to fix vulnerability
Vulnerability #1: GO-2024-2937
    Panic when parsing invalid palette-color images in golang.org/x/image
  More info: https://pkg.go.dev/vuln/GO-2024-2937
  Module: golang.org/x/image
    Found in: golang.org/x/image@v0.10.0
    Fixed in: golang.org/x/image@v0.18.0
    Example traces found:
      #1: internal/worker/output_uploader.go:144:36: worker.loadAsJPEG calls image.Decode, which calls tiff.Decode
2024-06-27 09:54:33 +02:00
ad9e826cba Manager: add task dependency test for fan-out and fan-in
Add a unit test for task dependencies, where there is a fan-in fan-out
pattern.

No functional changes, just a new test.
2024-06-26 12:37:11 +02:00
982262c6b8 Manager: add more logging of job & task creation
This may help to debug things like task dependencies.
2024-06-26 12:36:35 +02:00
d60451a829 Manager: run some worker management API calls in a background context
Run the actually-doing-stuff parts of `RequestWorkerStatusChange()` and
`SetWorkerTags()` in a background context. That way the operation can
continue even when the HTTP client disconnects.
2024-06-26 10:48:03 +02:00
6c2d3d7fc0 Manager: avoid logging error on HTTP disconnect on some API calls
Improve the error handling on some worker management API calls, to deal
with closed HTTP connections better.

A new function, `api_impl.handleConnectionClosed()` can now be called when
`errors.Is(err, context.Canceled)`. This will only log at debug level, and
send a `419 I'm a Teapot` response to the client. This response will very
likely never be seen, as the connection was closed. However, in case this
function is called by mistake, this response is unlikely to be accepted
by the HTTP client.
2024-06-26 10:26:33 +02:00
125e9aba23 Bumped version to 3.6-alpha2 2024-06-25 17:53:16 +02:00
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
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
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
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
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
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
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
2b3cb307bd Website: publish 3.6-alpha1 as latest experimental version 2024-06-25 11:27:53 +02:00
d3a3178300 Bumped version to 3.6-alpha1 2024-06-25 11:26:12 +02:00
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
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
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
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
1ec65e8c29 Cleanup: fix comment
Fix a comment in a unit test. No functional changes.
2024-06-08 20:55:54 +02:00
f05e87860c Bump Go version to 1.22.4 2024-06-08 20:55:54 +02:00
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
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
7a9f809c43 Manager: convert more worker functions to sqlc
No functional changes.
2024-05-28 18:20:15 +02:00
9a229a7b8f Manager: Convert CreateWorker to sqlc
No functional changes.
2024-05-28 18:20:07 +02:00
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
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
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
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
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
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
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
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