Job status change system for SocketIO broadcasts

Not fully tested yet.
This commit is contained in:
Sybren A. Stüvel 2022-04-05 15:49:31 +02:00
parent c875745bd4
commit 0c0df41f5d
28 changed files with 829 additions and 163 deletions

View File

@ -10,7 +10,7 @@
"""
__version__ = "781f1d93-dirty"
__version__ = "c875745b-dirty"
# import ApiClient
from flamenco.manager.api_client import ApiClient

View File

@ -76,7 +76,7 @@ class ApiClient(object):
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Flamenco/781f1d93-dirty (Blender add-on)'
self.user_agent = 'Flamenco/c875745b-dirty (Blender add-on)'
def __enter__(self):
return self

View File

@ -404,7 +404,7 @@ conf = flamenco.manager.Configuration(
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 1.0.0\n"\
"SDK Package Version: 781f1d93-dirty".\
"SDK Package Version: c875745b-dirty".\
format(env=sys.platform, pyversion=sys.version)
def get_host_settings(self):

View File

@ -0,0 +1,15 @@
# JobUpdate
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | UUID of the Job |
**updated** | **datetime** | Timestamp of last update |
**status** | [**JobStatus**](JobStatus.md) | |
**previous_status** | [**JobStatus**](JobStatus.md) | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,283 @@
"""
Flamenco manager
Render Farm manager API # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
from flamenco.manager.model_utils import ( # noqa: F401
ApiTypeError,
ModelComposed,
ModelNormal,
ModelSimple,
cached_property,
change_keys_js_to_python,
convert_js_args_to_python_args,
date,
datetime,
file_type,
none_type,
validate_get_composed_info,
OpenApiModel
)
from flamenco.manager.exceptions import ApiAttributeError
def lazy_import():
from flamenco.manager.model.job_status import JobStatus
globals()['JobStatus'] = JobStatus
class JobUpdate(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
Attributes:
allowed_values (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The value is a dict
with a capitalized key describing the allowed value and an allowed
value. These dicts store the allowed enum values.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
discriminator_value_class_map (dict): A dict to go from the discriminator
variable value to the discriminator class name.
validations (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The value is a dict
that stores validations for max_length, min_length, max_items,
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
inclusive_minimum, and regex.
additional_properties_type (tuple): A tuple of classes accepted
as additional properties values.
"""
allowed_values = {
}
validations = {
}
@cached_property
def additional_properties_type():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
"""
lazy_import()
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
_nullable = False
@cached_property
def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
lazy_import()
return {
'id': (str,), # noqa: E501
'updated': (datetime,), # noqa: E501
'status': (JobStatus,), # noqa: E501
'previous_status': (JobStatus,), # noqa: E501
}
@cached_property
def discriminator():
return None
attribute_map = {
'id': 'id', # noqa: E501
'updated': 'updated', # noqa: E501
'status': 'status', # noqa: E501
'previous_status': 'previous_status', # noqa: E501
}
read_only_vars = {
}
_composed_schemas = {}
@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls, id, updated, status, *args, **kwargs): # noqa: E501
"""JobUpdate - a model defined in OpenAPI
Args:
id (str): UUID of the Job
updated (datetime): Timestamp of last update
status (JobStatus):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
Defaults to True
_path_to_item (tuple/list): This is a list of keys or values to
drill down to the model in received_data
when deserializing a response
_spec_property_naming (bool): True if the variable names in the input data
are serialized names, as specified in the OpenAPI document.
False if the variable names in the input data
are pythonic names, e.g. snake case (default)
_configuration (Configuration): the instance to use when
deserializing a file_type parameter.
If passed, type conversion is attempted
If omitted no type conversion is done.
_visited_composed_classes (tuple): This stores a tuple of
classes that we have traveled through so that
if we see that class again we will not use its
discriminator again.
When traveling through a discriminator, the
composed schema that is
is traveled through is added to this set.
For example if Animal has a discriminator
petType and we pass in "Dog", and the class Dog
allOf includes Animal, we move through Animal
once using the discriminator, and pick Dog.
Then in Dog, we will make an instance of the
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
previous_status (JobStatus): [optional] # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())
_configuration = kwargs.pop('_configuration', None)
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
self = super(OpenApiModel, cls).__new__(cls)
if args:
raise ApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
),
path_to_item=_path_to_item,
valid_classes=(self.__class__,),
)
self._data_store = {}
self._check_type = _check_type
self._spec_property_naming = _spec_property_naming
self._path_to_item = _path_to_item
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
self.id = id
self.updated = updated
self.status = status
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
self._configuration.discard_unknown_keys and \
self.additional_properties_type is None:
# discard variable.
continue
setattr(self, var_name, var_value)
return self
required_properties = set([
'_data_store',
'_check_type',
'_spec_property_naming',
'_path_to_item',
'_configuration',
'_visited_composed_classes',
])
@convert_js_args_to_python_args
def __init__(self, id, updated, status, *args, **kwargs): # noqa: E501
"""JobUpdate - a model defined in OpenAPI
Args:
id (str): UUID of the Job
updated (datetime): Timestamp of last update
status (JobStatus):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
Defaults to True
_path_to_item (tuple/list): This is a list of keys or values to
drill down to the model in received_data
when deserializing a response
_spec_property_naming (bool): True if the variable names in the input data
are serialized names, as specified in the OpenAPI document.
False if the variable names in the input data
are pythonic names, e.g. snake case (default)
_configuration (Configuration): the instance to use when
deserializing a file_type parameter.
If passed, type conversion is attempted
If omitted no type conversion is done.
_visited_composed_classes (tuple): This stores a tuple of
classes that we have traveled through so that
if we see that class again we will not use its
discriminator again.
When traveling through a discriminator, the
composed schema that is
is traveled through is added to this set.
For example if Animal has a discriminator
petType and we pass in "Dog", and the class Dog
allOf includes Animal, we move through Animal
once using the discriminator, and pick Dog.
Then in Dog, we will make an instance of the
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
previous_status (JobStatus): [optional] # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())
_configuration = kwargs.pop('_configuration', None)
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
if args:
raise ApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
),
path_to_item=_path_to_item,
valid_classes=(self.__class__,),
)
self._data_store = {}
self._check_type = _check_type
self._spec_property_naming = _spec_property_naming
self._path_to_item = _path_to_item
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
self.id = id
self.updated = updated
self.status = status
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
self._configuration.discard_unknown_keys and \
self.additional_properties_type is None:
# discard variable.
continue
setattr(self, var_name, var_value)
if var_name in self.read_only_vars:
raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
f"class with read only attributes.")

View File

@ -23,6 +23,7 @@ from flamenco.manager.model.job_all_of import JobAllOf
from flamenco.manager.model.job_metadata import JobMetadata
from flamenco.manager.model.job_settings import JobSettings
from flamenco.manager.model.job_status import JobStatus
from flamenco.manager.model.job_update import JobUpdate
from flamenco.manager.model.jobs_query import JobsQuery
from flamenco.manager.model.jobs_query_result import JobsQueryResult
from flamenco.manager.model.manager_configuration import ManagerConfiguration

View File

@ -4,7 +4,7 @@ Render Farm manager API
The `flamenco.manager` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0
- Package version: 781f1d93-dirty
- Package version: c875745b-dirty
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://flamenco.io/](https://flamenco.io/)
@ -101,6 +101,7 @@ Class | Method | HTTP request | Description
- [JobMetadata](flamenco/manager/docs/JobMetadata.md)
- [JobSettings](flamenco/manager/docs/JobSettings.md)
- [JobStatus](flamenco/manager/docs/JobStatus.md)
- [JobUpdate](flamenco/manager/docs/JobUpdate.md)
- [JobsQuery](flamenco/manager/docs/JobsQuery.md)
- [JobsQueryResult](flamenco/manager/docs/JobsQueryResult.md)
- [ManagerConfiguration](flamenco/manager/docs/ManagerConfiguration.md)

View File

@ -94,8 +94,8 @@ func main() {
//
// go persist.PeriodicMaintenanceLoop(mainCtx)
flamenco := buildFlamencoAPI(configService, persist)
webUpdater := webupdates.New()
flamenco := buildFlamencoAPI(configService, persist, webUpdater)
e := buildWebService(flamenco, persist, ssdp, webUpdater)
installSignalHandler(mainCtxCancel)
@ -132,14 +132,14 @@ func main() {
log.Info().Msg("shutdown complete")
}
func buildFlamencoAPI(configService *config.Service, persist *persistence.DB) api.ServerInterface {
func buildFlamencoAPI(configService *config.Service, persist *persistence.DB, webUpdater *webupdates.BiDirComms) api.ServerInterface {
timeService := clock.New()
compiler, err := job_compilers.Load(timeService)
if err != nil {
log.Fatal().Err(err).Msg("error loading job compilers")
}
logStorage := task_logs.NewStorage(configService.Get().TaskLogsPath)
taskStateMachine := task_state_machine.NewStateMachine(persist)
taskStateMachine := task_state_machine.NewStateMachine(persist, webUpdater)
shamanServer := shaman.NewServer(configService.Get().Shaman, nil)
flamenco := api_impl.NewFlamenco(compiler, persist, logStorage, configService, taskStateMachine, shamanServer)
return flamenco

View File

@ -11,6 +11,7 @@ import (
"git.blender.org/flamenco/internal/manager/job_compilers"
"git.blender.org/flamenco/internal/manager/persistence"
"git.blender.org/flamenco/internal/manager/task_state_machine"
"git.blender.org/flamenco/internal/manager/webupdates"
"git.blender.org/flamenco/pkg/api"
"git.blender.org/flamenco/pkg/shaman"
"github.com/labstack/echo/v4"
@ -66,6 +67,14 @@ type TaskStateMachine interface {
// TaskStateMachine should be a subset of task_state_machine.StateMachine.
var _ TaskStateMachine = (*task_state_machine.StateMachine)(nil)
type ChangeBroadcaster interface {
// BroadcastNewJob sends a 'new job' notification to all SocketIO clients.
BroadcastNewJob(jobUpdate api.JobUpdate)
}
// ChangeBroadcaster should be a subset of webupdates.BiDirComms.
var _ ChangeBroadcaster = (*webupdates.BiDirComms)(nil)
type JobCompiler interface {
ListJobTypes() api.AvailableJobTypes
Compile(ctx context.Context, job api.SubmittedJob) (*job_compilers.AuthoredJob, error)

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: git.blender.org/flamenco/internal/manager/task_state_machine (interfaces: PersistenceService)
// Source: git.blender.org/flamenco/internal/manager/task_state_machine (interfaces: PersistenceService,ChangeBroadcaster)
// Package mocks is a generated GoMock package.
package mocks
@ -122,3 +122,38 @@ func (mr *MockPersistenceServiceMockRecorder) UpdateJobsTaskStatusesConditional(
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateJobsTaskStatusesConditional", reflect.TypeOf((*MockPersistenceService)(nil).UpdateJobsTaskStatusesConditional), arg0, arg1, arg2, arg3, arg4)
}
// MockChangeBroadcaster is a mock of ChangeBroadcaster interface.
type MockChangeBroadcaster struct {
ctrl *gomock.Controller
recorder *MockChangeBroadcasterMockRecorder
}
// MockChangeBroadcasterMockRecorder is the mock recorder for MockChangeBroadcaster.
type MockChangeBroadcasterMockRecorder struct {
mock *MockChangeBroadcaster
}
// NewMockChangeBroadcaster creates a new mock instance.
func NewMockChangeBroadcaster(ctrl *gomock.Controller) *MockChangeBroadcaster {
mock := &MockChangeBroadcaster{ctrl: ctrl}
mock.recorder = &MockChangeBroadcasterMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockChangeBroadcaster) EXPECT() *MockChangeBroadcasterMockRecorder {
return m.recorder
}
// BroadcastJobUpdate mocks base method.
func (m *MockChangeBroadcaster) BroadcastJobUpdate(arg0 api.JobUpdate) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "BroadcastJobUpdate", arg0)
}
// BroadcastJobUpdate indicates an expected call of BroadcastJobUpdate.
func (mr *MockChangeBroadcasterMockRecorder) BroadcastJobUpdate(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BroadcastJobUpdate", reflect.TypeOf((*MockChangeBroadcaster)(nil).BroadcastJobUpdate), arg0)
}

View File

@ -10,6 +10,7 @@ import (
"github.com/rs/zerolog/log"
"git.blender.org/flamenco/internal/manager/persistence"
"git.blender.org/flamenco/internal/manager/webupdates"
"git.blender.org/flamenco/pkg/api"
)
@ -19,11 +20,12 @@ const taskFailJobPercentage = 10 // Integer from 0 to 100.
// StateMachine handles task and job status changes.
type StateMachine struct {
persist PersistenceService
persist PersistenceService
broadcaster ChangeBroadcaster
}
// Generate mock implementations of these interfaces.
//go:generate go run github.com/golang/mock/mockgen -destination mocks/interfaces_mock.gen.go -package mocks git.blender.org/flamenco/internal/manager/task_state_machine PersistenceService
//go:generate go run github.com/golang/mock/mockgen -destination mocks/interfaces_mock.gen.go -package mocks git.blender.org/flamenco/internal/manager/task_state_machine PersistenceService,ChangeBroadcaster
type PersistenceService interface {
SaveTask(ctx context.Context, task *persistence.Task) error
@ -45,9 +47,18 @@ type PersistenceService interface {
// PersistenceService should be a subset of persistence.DB
var _ PersistenceService = (*persistence.DB)(nil)
func NewStateMachine(persist PersistenceService) *StateMachine {
type ChangeBroadcaster interface {
// BroadcastJobUpdate sends the job update to clients.
BroadcastJobUpdate(jobUpdate api.JobUpdate)
}
// ChangeBroadcaster should be a subset of webupdates.BiDirComms
var _ ChangeBroadcaster = (*webupdates.BiDirComms)(nil)
func NewStateMachine(persist PersistenceService, broadcaster ChangeBroadcaster) *StateMachine {
return &StateMachine{
persist: persist,
persist: persist,
broadcaster: broadcaster,
}
}
@ -244,6 +255,15 @@ func (sm *StateMachine) JobStatusChange(ctx context.Context, job *persistence.Jo
if err != nil {
return fmt.Errorf("updating job's tasks after job status change: %w", err)
}
// Broadcast this change to the SocketIO clients.
jobUpdate := api.JobUpdate{
Id: job.UUID,
Updated: job.UpdatedAt,
PreviousStatus: &oldJobStatus,
Status: job.Status,
}
sm.broadcaster.BroadcastJobUpdate(jobUpdate)
}
return nil

View File

@ -18,7 +18,8 @@ import (
)
type StateMachineMocks struct {
persist *mocks.MockPersistenceService
persist *mocks.MockPersistenceService
broadcaster *mocks.MockChangeBroadcaster
}
// In the comments below, "T" indicates the performed task status change, and
@ -32,6 +33,8 @@ func TestTaskStatusChangeQueuedToActive(t *testing.T) {
task := taskWithStatus(api.JobStatusQueued, api.TaskStatusQueued)
mocks.expectSaveTaskWithStatus(t, task, api.TaskStatusActive)
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusActive)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusQueued, api.JobStatusActive)
assert.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusActive))
}
@ -81,6 +84,8 @@ func TestTaskStatusChangeActiveToCompleted(t *testing.T) {
mocks.expectSaveTaskWithStatus(t, task3, api.TaskStatusCompleted)
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(3, 3, nil) // 3 of 3 complete.
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusCompleted)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusActive, api.JobStatusCompleted)
assert.NoError(t, sm.TaskStatusChange(ctx, task3, api.TaskStatusCompleted))
}
@ -93,6 +98,8 @@ func TestTaskStatusChangeQueuedToFailed(t *testing.T) {
mocks.expectSaveTaskWithStatus(t, task, api.TaskStatusFailed)
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusActive)
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusFailed).Return(1, 100, nil) // 1 out of 100 failed.
mocks.expectBroadcastJobChange(task.Job, api.JobStatusQueued, api.JobStatusActive)
assert.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusFailed))
}
@ -104,6 +111,8 @@ func TestTaskStatusChangeActiveToFailedFailJob(t *testing.T) {
task := taskWithStatus(api.JobStatusActive, api.TaskStatusActive)
mocks.expectSaveTaskWithStatus(t, task, api.TaskStatusFailed)
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusFailed)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusActive, api.JobStatusFailed)
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusFailed).Return(10, 100, nil) // 10 out of 100 failed.
// Expect failure of the job to trigger cancellation of remaining tasks.
@ -127,6 +136,8 @@ func TestTaskStatusChangeRequeueOnCompletedJob(t *testing.T) {
task := taskWithStatus(api.JobStatusCompleted, api.TaskStatusCompleted)
mocks.expectSaveTaskWithStatus(t, task, api.TaskStatusQueued)
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusRequeued)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusCompleted, api.JobStatusRequeued)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusRequeued, api.JobStatusQueued)
// Expect queueing of the job to trigger queueing of all its tasks, if those tasks were all completed before.
// 2 out of 3 completed, because one was just queued.
@ -156,6 +167,8 @@ func TestTaskStatusChangeCancelSingleTask(t *testing.T) {
mocks.expectSaveTaskWithStatus(t, task2, api.TaskStatusCanceled)
mocks.persist.EXPECT().JobHasTasksInStatus(ctx, job, api.TaskStatusCancelRequested).Return(false, nil)
mocks.expectSaveJobWithStatus(t, job, api.JobStatusCanceled)
mocks.expectBroadcastJobChange(task.Job, api.JobStatusCancelRequested, api.JobStatusCanceled)
assert.NoError(t, sm.TaskStatusChange(ctx, task2, api.TaskStatusCanceled))
}
@ -196,6 +209,10 @@ func TestJobRequeueWithSomeCompletedTasks(t *testing.T) {
"Queued because job transitioned status from \"active\" to \"requeued\"",
)
mocks.expectSaveJobWithStatus(t, job, api.JobStatusQueued)
mocks.expectBroadcastJobChange(job, api.JobStatusActive, api.JobStatusRequeued)
mocks.expectBroadcastJobChange(job, api.JobStatusRequeued, api.JobStatusQueued)
assert.NoError(t, sm.JobStatusChange(ctx, job, api.JobStatusRequeued))
}
@ -224,14 +241,18 @@ func TestJobRequeueWithAllCompletedTasks(t *testing.T) {
Return(0, 3, nil). // By now all tasks are queued.
After(call3)
mocks.expectBroadcastJobChange(job, api.JobStatusCompleted, api.JobStatusRequeued)
mocks.expectBroadcastJobChange(job, api.JobStatusRequeued, api.JobStatusQueued)
assert.NoError(t, sm.JobStatusChange(ctx, job, api.JobStatusRequeued))
}
func mockedTaskStateMachine(mockCtrl *gomock.Controller) (*StateMachine, *StateMachineMocks) {
mocks := StateMachineMocks{
persist: mocks.NewMockPersistenceService(mockCtrl),
persist: mocks.NewMockPersistenceService(mockCtrl),
broadcaster: mocks.NewMockChangeBroadcaster(mockCtrl),
}
sm := NewStateMachine(mocks.persist)
sm := NewStateMachine(mocks.persist, mocks.broadcaster)
return sm, &mocks
}
@ -261,6 +282,19 @@ func (m *StateMachineMocks) expectSaveJobWithStatus(
})
}
func (m *StateMachineMocks) expectBroadcastJobChange(
job *persistence.Job,
fromStatus, toStatus api.JobStatus,
) *gomock.Call {
expectUpdate := api.JobUpdate{
Id: job.UUID,
Updated: job.UpdatedAt,
PreviousStatus: &fromStatus,
Status: toStatus,
}
return m.broadcaster.EXPECT().BroadcastJobUpdate(expectUpdate)
}
/* taskWithStatus() creates a task of a certain status, with a job of a certain status. */
func taskWithStatus(jobStatus api.JobStatus, taskStatus api.TaskStatus) *persistence.Task {
job := persistence.Job{

View File

@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package webupdates
type SocketIORoomName string
const (
// Predefined SocketIO rooms.
SocketIORoomChat SocketIORoomName = "Chat" // For chat messages.
SocketIORoomJobs SocketIORoomName = "Jobs" // For job updates.
)
type SocketIOEventType string
const (
// Predefined SocketIO event types.
SIOEventChatMessageRcv SocketIOEventType = "/chat" // clients send messages here
SIOEventChatMessageSend SocketIOEventType = "/message" // messages are broadcasted here
SIOEventJobUpdate SocketIOEventType = "/jobs" // sends api.JobUpdate
)

View File

@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package webupdates
import (
"github.com/rs/zerolog/log"
"git.blender.org/flamenco/pkg/api"
)
// BroadcastJobUpdate sends the job update to clients.
func (b *BiDirComms) BroadcastJobUpdate(jobUpdate api.JobUpdate) {
log.Debug().Interface("jobUpdate", jobUpdate).Msg("socketIO: broadcasting job update")
b.sockserv.BroadcastTo(string(SocketIORoomJobs), "/jobs", jobUpdate)
}
// BroadcastNewJob sends a "new job" notification to clients.
func (b *BiDirComms) BroadcastNewJob(jobUpdate api.JobUpdate) {
if jobUpdate.PreviousStatus != nil {
log.Warn().Interface("jobUpdate", jobUpdate).Msg("socketIO: new jobs should not have a previous state")
jobUpdate.PreviousStatus = nil
}
log.Debug().Interface("jobUpdate", jobUpdate).Msg("socketIO: broadcasting new job")
b.sockserv.BroadcastTo(string(SocketIORoomJobs), "/jobs", jobUpdate)
}

View File

@ -37,7 +37,7 @@ func socketIOServer() *gosocketio.Server {
// socket connection
err = sio.On(gosocketio.OnConnection, func(c *gosocketio.Channel) {
log.Debug().Str("clientID", c.Id()).Msg("socketIO: connected")
if err := c.Join("Room"); err != nil {
if err := c.Join(string(SocketIORoomChat)); err != nil {
log.Warn().Err(err).Str("clientID", c.Id()).Msg("socketIO: unable to make client join broadcast message room")
}
})
@ -48,7 +48,7 @@ func socketIOServer() *gosocketio.Server {
// socket disconnection
err = sio.On(gosocketio.OnDisconnection, func(c *gosocketio.Channel) {
log.Debug().Str("clientID", c.Id()).Msg("socketIO: disconnected")
if err := c.Leave("Room"); err != nil {
if err := c.Leave(string(SocketIORoomChat)); err != nil {
log.Warn().Err(err).Str("clientID", c.Id()).Msg("socketIO: unable to make client leave broadcast message room")
}
})
@ -64,12 +64,12 @@ func socketIOServer() *gosocketio.Server {
}
// chat socket
err = sio.On("/chat", func(c *gosocketio.Channel, message Message) string {
err = sio.On(string(SIOEventChatMessageRcv), func(c *gosocketio.Channel, message Message) string {
log.Info().Str("clientID", c.Id()).
Str("text", message.Text).
Str("name", message.Name).
Msg("socketIO: message received")
c.BroadcastTo("Room", "/message", message.Text)
c.BroadcastTo(string(SocketIORoomChat), string(SIOEventChatMessageSend), message)
return "message sent successfully."
})
if err != nil {

View File

@ -892,6 +892,25 @@ components:
"status": {$ref: "#/components/schemas/ShamanFileStatus"}
required: [status]
# SocketIO API. These types are not used in any HTTP operation defined in
# the 'paths' section of this document, so some code generators may choose
# to skip these.
JobUpdate:
type: object
properties:
"id":
type: string
format: uuid
description: UUID of the Job
"updated":
type: string
format: date-time
description: Timestamp of last update
"status": {$ref: "#/components/schemas/JobStatus"}
"previous_status": {$ref: "#/components/schemas/JobStatus"}
required: [id, updated, status]
securitySchemes:
worker_auth:
description: Username is the worker ID, password is the secret given at worker registration.

View File

@ -1,8 +1,7 @@
//go:generate oapi-codegen -generate types -o openapi_types.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate server -o openapi_server.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate spec -o openapi_spec.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate client -o openapi_client.gen.go -package api flamenco-manager.yaml
// SPDX-License-Identifier: GPL-3.0-or-later
package api
// SPDX-License-Identifier: GPL-3.0-or-later
//go:generate oapi-codegen -generate types,skip-prune -o openapi_types.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate server,skip-prune -o openapi_server.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate spec,skip-prune -o openapi_spec.gen.go -package api flamenco-manager.yaml
//go:generate oapi-codegen -generate client,skip-prune -o openapi_client.gen.go -package api flamenco-manager.yaml

View File

@ -18,100 +18,101 @@ import (
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+Q823LcOHa/guKmamYq7Itulq2naH2ZkTMzVix5J1VjlwSSh92QSIADgGr3uFS1H5E/",
"SbYqD9mn/ID3j1LAAUmwiZZaY8nj3fjB1eLl4ODcb+CHKBVlJThwraKDD5FK51BS+/NQKTbjkJ1SdWn+",
"zkClklWaCR4d9O4Spggl2vyiijBt/paQAruCjCRLoudAfhLyEuQ4iqNKigqkZmBXSUVZUp7Z30xDaX/8",
"k4Q8Ooj+MOmQmzjMJk/xheg6jvSyguggolLSpfn7QiTmbXdZacn4zF0/qyQTkuml9wDjGmYgmyfwauB1",
"TsvwjZthKk11fet2DP1O8EmzI6ou1yNS1ywzN3IhS6qjA7wQrz54HUcSfqmZhCw6+Ll5yBDH7aXFzdvC",
"CpU8kvhYxR2/3rXriuQCUm0QPLyirKBJAS9FcgJaG3QGknPC+KwAovA+ETmh5KVIiIGmAgIyFyzFn304",
"P82Bkxm7Ah6TgpVMWzm7ogXLzP81KKKFuaaAOCBj8ooXS1IrgyNZMD0nSDS7uFm7FcEB8VeFLYOc1oUe",
"4nU6B+JuIh5EzcWCO2RIrUCShcE9Aw2yZNyuP2eqIckYwXsww0u0VyZaiEKzyi3EeLeQkUeZ0xQsUMiY",
"NltHiA7/nBYK4iFx9RykQZoWhVgQ8+oqooTm2jwzB3IhEjKniiQAnKg6KZnWkI3JT6IuMsLKqliSDArA",
"14qCwHumECBVl4rkQiLoC5HEhPLMGBBRVqwwzzA9fss7QU+EKIByu6MrWgzp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WbU7efbuwTVucB5hfaO/O0bytWmPP1/cnZsInqDBw5NDRbnJarcS+f9bGONQEuOsSRO+",
"u7NJ7hxzBjlI0h7LQd9sqWG9/Ntoe/r4bdSVk+x0tE23ebEkiYkRdC1NamS/AdltT7WRG449teegBgzH",
"RJ0WSiAMJUoQHAgUysLpJsRDaFppsQScA81sm86R8N9HuMzoKeWjZ2afozcWQBSgoffFyRANhWQzxmlh",
"1zTwx+QodyPohfBH1tvzYky3o+SMu/NezDfXdqq8PUNKOaHMPpFBUuM5/g329sohNnrhEItuEsuN03iR",
"atAjpSXQsm8h2kpBwrjR72GtYBjL4xpq5ZDpJybxVrwGKfz29PFtjztx7Ami1/Lf3doPQpDudZMA2Nko",
"koBegBN2R05vkKaZrnEjBu6zKlb95cDutMFyI8s2vdkLfMQNldh9OuEWrW00sNMcJ3iVFCkoy4gEzIvt",
"+smyp3cYSpyvVaEDYnh2jsONaF18cridfC0eyHoGV7tb73fIj8IWP6ge3rT6mQuZsqRYkrQQCssk352e",
"HpNUcA7202ZowJoKkTO8OeNMzUH1+AUE3tNUE0VLcCGkFvZ4i3klE7WJ7vAFNX7LG65+Y786gNrkZCGB",
"EAdIIrLlWlfql3zMEl1aMSSLqyGZ3+hQccZ7Enk9r8E3qfsTToOpUaYVFPm4s2d2jmdoel+KpGnJ2trQ",
"LzVIBir2JknjlaGocW90TAWAHh4f9WdZ/Y6cKMuauwNKxqQPR6Fb8K60FfD1SL/D46PYLmRFrmO+25At",
"r5i/L0TSJrHKg+/4df3u+v8CAAD///kI70U9YQAA",
}
// GetSwagger returns the content of the embedded swagger specification file

View File

@ -225,6 +225,17 @@ type JobSettings struct {
// JobStatus defines model for JobStatus.
type JobStatus string
// JobUpdate defines model for JobUpdate.
type JobUpdate struct {
// UUID of the Job
Id string `json:"id"`
PreviousStatus *JobStatus `json:"previous_status,omitempty"`
Status JobStatus `json:"status"`
// Timestamp of last update
Updated time.Time `json:"updated"`
}
// JobsQuery defines model for JobsQuery.
type JobsQuery struct {
Limit *int `json:"limit,omitempty"`

View File

@ -5,46 +5,45 @@
<chat-chatbox
@sendMessage="sendMessage"
:chatHistory="messages"
></chat-chatbox>
/>
<jobs-listener
ref="jobsListener"
:websocketURL="websocketURL"
@jobUpdate="onJobUpdate"
@message="onChatMessage"
/>
</div>
</template>
<script>
import io from "socket.io-client";
import ChatNavbar from "./components/ChatNavbar.vue";
import ChatChatbox from "./components/ChatChatbox.vue";
import JobsListener from "./components/JobsListener.vue";
export default {
name: "App",
name: "FlamencoWebApp",
components: {
ChatNavbar,
ChatChatbox,
JobsListener,
},
data: () => {
return {
socket: null,
serverUrl: process.env.VUE_APP_SOCKET_URL || "ws://localhost:8080",
websocketURL: "ws://localhost:8080",
messages: [],
};
},
mounted: function () {
this.connectToWebsocket();
},
methods: {
connectToWebsocket() {
console.log("connecting to WS", this.serverUrl);
this.socket = io(this.serverUrl, {
transports: ["websocket"],
});
this.socket.on("/message", (message) => {
console.log("message received: ", message);
this.messages.push(message);
});
},
sendMessage(message) {
const payload = { name: "Nikita", text: message };
console.log("sending:", payload);
this.socket.emit("/chat", payload);
this.$refs.jobsListener.sendBroadcastMessage("typer", message);
},
onJobUpdate(jobUpdate) {
console.log("job update received:", jobUpdate);
},
onChatMessage(message) {
console.log("chat message received:", message);
},
},
};

View File

@ -0,0 +1,63 @@
<template>
<span />
</template>
<script>
import io from "socket.io-client";
export default {
emits: ["jobUpdate", "taskUpdate", "message"],
props: ["websocketURL"],
data() {
return {
socket: null,
}
},
mounted: function () {
this.connectToWebsocket();
},
beforeDestroy: function() {
this.disconnectWebsocket();
},
methods: {
connectToWebsocket() {
// The SocketIO client API docs are available at:
// https://github.com/socketio/socket.io-client/blob/2.4.x/docs/API.md
console.log("connecting JobsListener to WS", this.websocketURL);
this.socket = io(this.websocketURL, {
transports: ["websocket"],
});
this.socket.on("reconnect", (attemptNumber) => {
console.log("socketIO reconnected after", attemptNumber, "attempts");
})
this.socket.on("/jobs", (jobUpdate) => {
this.$emit("jobUpdate", jobUpdate);
});
// Chat system, useful for debugging.
this.socket.on("/message", (message) => {
this.$emit("message", message);
});
},
disconnectWebsocket() {
if (this.socket == null) {
console.log("no JobListener socket to disconnect");
return;
}
console.log("disconnecting JobsListener WS", this.websocketURL);
this.socket.disconnect();
this.socket = null;
},
sendBroadcastMessage(name, message) {
const payload = { name: name, text: message };
console.log("sending broadcast message:", payload);
this.socket.emit("/chat", payload);
},
},
};
</script>

View File

@ -10,34 +10,27 @@ import {
BButton,
} from "bootstrap-vue";
import URLs from './urls'
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
let url = new URL(window.location);
url.port = "8080";
const flamencoAPIURL = url.href;
url.protocol = "ws:";
const websocketURL = url.href;
console.log("Flamenco API:", flamencoAPIURL);
console.log("Websocket :", websocketURL);
// let flamencoManager = require('flamenco-manager');
// let apiClient = new flamencoManager.ApiClient(URLs.api);
let flamencoManager = require('flamenco-manager');
let apiClient = new flamencoManager.ApiClient(flamencoAPIURL);
// let query = new flamencoManager.JobsQuery();
// // query.status_in = ["active"];
// query.metadata = {project: "Heist"};
let query = new flamencoManager.JobsQuery();
// query.status_in = ["active"];
query.metadata = {project: "Heist"};
let JobsApi = new flamencoManager.JobsApi(apiClient);
JobsApi.queryJobs(query).then(function(data) {
console.log('API called successfully.');
console.log(data);
}, function(error) {
console.error(error);
});
// let JobsApi = new flamencoManager.JobsApi(apiClient);
// JobsApi.queryJobs(query).then(function(data) {
// console.log('API called successfully.');
// console.log(data);
// }, function(error) {
// console.error(error);
// });
Vue.config.productionTip = false
Vue.config.serverUrl = websocketURL;
Vue.use(FormInputPlugin);
Vue.use(NavbarPlugin);
@ -47,8 +40,7 @@ Vue.component("b-input-group", BInputGroup);
Vue.component("b-button", BButton);
Vue.use(IconsPlugin);
var vueApp = new Vue({
render: h => h(App),
});
var vueApp = new Vue(App);
vueApp.websocketURL = URLs.ws;
vueApp.$mount("#app");

16
web/app/src/urls.js Normal file
View File

@ -0,0 +1,16 @@
let url = new URL(window.location);
url.port = "8080";
const flamencoAPIURL = url.href;
url.protocol = "ws:";
const websocketURL = url.href;
const URLs = {
api: flamencoAPIURL,
ws: websocketURL,
};
console.log("Flamenco API:", URLs.api);
console.log("Websocket :", URLs.ws);
export default URLs;

View File

@ -152,6 +152,7 @@ Class | Method | HTTP request | Description
- [flamencoManager.Job](docs/Job.md)
- [flamencoManager.JobAllOf](docs/JobAllOf.md)
- [flamencoManager.JobStatus](docs/JobStatus.md)
- [flamencoManager.JobUpdate](docs/JobUpdate.md)
- [flamencoManager.JobsQuery](docs/JobsQuery.md)
- [flamencoManager.JobsQueryResult](docs/JobsQueryResult.md)
- [flamencoManager.ManagerConfiguration](docs/ManagerConfiguration.md)

View File

@ -0,0 +1,12 @@
# flamencoManager.JobUpdate
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | UUID of the Job |
**updated** | **Date** | Timestamp of last update |
**status** | [**JobStatus**](JobStatus.md) | |
**previous_status** | [**JobStatus**](JobStatus.md) | | [optional]

View File

@ -55,7 +55,7 @@ class ApiClient {
* @default {}
*/
this.defaultHeaders = {
'User-Agent': 'Flamenco/c00cf8b0-dirty / webbrowser'
'User-Agent': 'Flamenco/c875745b-dirty / webbrowser'
};
/**

View File

@ -25,6 +25,7 @@ import FlamencoVersion from './model/FlamencoVersion';
import Job from './model/Job';
import JobAllOf from './model/JobAllOf';
import JobStatus from './model/JobStatus';
import JobUpdate from './model/JobUpdate';
import JobsQuery from './model/JobsQuery';
import JobsQueryResult from './model/JobsQueryResult';
import ManagerConfiguration from './model/ManagerConfiguration';
@ -162,6 +163,12 @@ export {
*/
JobStatus,
/**
* The JobUpdate model constructor.
* @property {module:model/JobUpdate}
*/
JobUpdate,
/**
* The JobsQuery model constructor.
* @property {module:model/JobsQuery}

View File

@ -0,0 +1,104 @@
/**
* Flamenco manager
* Render Farm manager API
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
import ApiClient from '../ApiClient';
import JobStatus from './JobStatus';
/**
* The JobUpdate model module.
* @module model/JobUpdate
* @version 0.0.0
*/
class JobUpdate {
/**
* Constructs a new <code>JobUpdate</code>.
* @alias module:model/JobUpdate
* @param id {String} UUID of the Job
* @param updated {Date} Timestamp of last update
* @param status {module:model/JobStatus}
*/
constructor(id, updated, status) {
JobUpdate.initialize(this, id, updated, status);
}
/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj, id, updated, status) {
obj['id'] = id;
obj['updated'] = updated;
obj['status'] = status;
}
/**
* Constructs a <code>JobUpdate</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/JobUpdate} obj Optional instance to populate.
* @return {module:model/JobUpdate} The populated <code>JobUpdate</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new JobUpdate();
if (data.hasOwnProperty('id')) {
obj['id'] = ApiClient.convertToType(data['id'], 'String');
}
if (data.hasOwnProperty('updated')) {
obj['updated'] = ApiClient.convertToType(data['updated'], 'Date');
}
if (data.hasOwnProperty('status')) {
obj['status'] = JobStatus.constructFromObject(data['status']);
}
if (data.hasOwnProperty('previous_status')) {
obj['previous_status'] = JobStatus.constructFromObject(data['previous_status']);
}
}
return obj;
}
}
/**
* UUID of the Job
* @member {String} id
*/
JobUpdate.prototype['id'] = undefined;
/**
* Timestamp of last update
* @member {Date} updated
*/
JobUpdate.prototype['updated'] = undefined;
/**
* @member {module:model/JobStatus} status
*/
JobUpdate.prototype['status'] = undefined;
/**
* @member {module:model/JobStatus} previous_status
*/
JobUpdate.prototype['previous_status'] = undefined;
export default JobUpdate;