Main Application
UI
Starting the application as described in Usage will run the pheno_ui module to start the application.
- DeepEtoProfile entry point: pheno_ui.py
Defines the
pheno_uiclassThe __main__ method intatiates this class with the number of processing tasks passed as parameter (default = 1) and shows the dialog
- class pheno_ui(nProcTasks)
Bases:
QMainWindowThe pheno_ui loads the graphic definition from MainWindow.ui and exposes the functionality to the user.
Takes one optional parameter, the maximum number of Docker processing instances - default is 1
- tableData: []
Contains the view of data as it is displayed in the table of the main window
- cc: CentralCommand
The background object handling the execution of the annotation processes and the related communication between them and the user interface
- startCommServer()
Constructs a
CentralCommand.CentralCommandobject inccand start it in the background.
- connectTableView()
Connects the
tableDatato the main window. This data will be displayed in a table according to the specification fromTaskTableModel.TaskTableModel
- addMultipleClicked()
Opens the
add_multiple.add_multipledialog that allows to select and add several video files at once
- addTaskClicked()
Opens the
add_task.add_taskdialog that allows to select, view, and add one video file to be processed
- addNewFile(file)
Adds new file to
taskListand sets the appropiate events. A newPhenoTask.PhenoTaskobject is created by callingTaskList.TaskList.addVideo()with file andtaskCounterSlots are created for the new task’s signals and then a new entry is added in
tableData.- Parameters
file (str) – the path to the new video file
- updateState(id, state)
Updates the displayed state of a task
- Parameters
id (int) – The id of the element to be updated
state (
TaskState.TaskState) – The new state
- updateProgress(id, progress)
Updates the displayed execution progress of a task
- closeEvent(event)
Calls the stop method of the
CentralCommand.CentralCommandinstance inccbefore exiting.
- class add_task
Bases:
QDialogDialog that allows to select, view, and add a video to the processing queue.
The visual representation is specified in AddVideo.ui file.
- browseButtonClicked()
Opens the selection dialog QFileDialog
In case of success, calls
setVideoFile()to displays the video in the current dialog.
- setVideoFile(filename)
Creates a
QtMultimedia.QMediaPlayerinstance and loads the video in the file that was passed as parameter.- Parameters
filename (string) – The path to the video to be displayed
- class add_multiple
Bases:
QDialogDialog allowing the selection and adding of multiple videos from one folder at once.
The visual representation is specified in AddMultiple.ui file.
- videoList: []
Array of paths to selected video files. The
pheno_ui.pheno_uiinstance will check this array for new videos to be added in the processing queue.
- connectSignalsSlots()
Establishes communication between
add_multipleand the GUI signals.
- class TaskTableModel(data)
Bases:
QAbstractTableModelModels the table representation of the processing queue.
- headerData(section: int, orientation: PyQt5.QtCore.Qt.Orientation, role=PyQt5.QtCore.Qt.DisplayRole)
The columns are defined as: Id | File | Status | Progress Inherited from QAbstractTableModel
- Parameters
section (int) – the section id
orientation (Qt.Orientation) – only the horizontal case is handled
role (TYPE, optional) – defaults to Qt.DisplayRole
Communication
- class CentralCommand(taskList)
Processes the videos added by the user through
taskList. This list is updated every time a new video is added or the status of any of the containing tasks is changed.Provides the communication between the Docker instance(s) and the user interface.
- procPortPool: PortPool
A list of ports currently available for opening communication channels to Docker images.
- procPort = 20100
An offset for computing the communication ports between the Docker instances and the main application
- taskList: TaskList
Contains the list of all the video files that were added by the user. Is passed as parameter when instantiating the class.
- start(noProcClients=2)
Starts the method
startGUIConnection()in a thread. This will process the videos that are added in thetaskList.Initializes the
PortPoolwith the appropiate number of processes.- Parameters
noProcClients (int, optional) – maximum number of tasks that will be processed in parallel, defaults to 2
- stop()
Informs the
startGUIConnection()to stop processing new tasks.The processing of videos in Docker images that are already started will run until they are finished and produce valid, complete results.
- startGUIConnection()
Runs a loop as long as the flag
startedis True. The method is started in a thread bystart().It checks for available communication ports in
procPortPooland tasks waiting to be executed intaskList. When it has found both, it starts a new process by calling the methodstartProc().
- startProc(port, task)
Prepares the environment for the processing of a new video. A new Docker instance is created from the image ethoprofiler_nn_av. This image mounts the directory where the video file is found locally at /mnt/data. There is also a mapping between the Docked instance internal port 2000 and the communication port used to connect to the main application.
After the Docker instance is created, a new thread running
procVideo()is started to handle the communication with it.
- procVideo(port, task)
Provides an interface with a Docker instance. The communication is performed through a port identified in parameter and the video file to be processed is contained in task.
It updates the
taskwith the current execution status - this will be propagated to the user interface.
- receiveMessage(connSocket)
Receives a message from a Docker instance through the socket
connSocket, decodes it and returns the string version.- Parameters
connSocket (socket.socket) – communication socket where the message is to be received
- Returns
decoded version of the received message or ‘’
- Return type
- sendMessage(connSocket, message)
Encodes the
messageand sends it through theconnSocket- Parameters
connSocket (connSocket: socket.socket) – socket through which to send the message
message (str) – message to be sent
- Raises
RuntimeError – in case of failed send
- class PhenoTask(id, videoPath)
Bases:
QObjectClass encapsulating one video file and it’s current status.
Every time a video is selected for processing a new
PhenoTaskobject is created. The current state and the processing progress are managed here. The class also contains the means to propagate changes to other parts of the application.- Parameters
- setState(state)
Set the state to
stateof the task and activates thestateQtsignal to propagate the change.Variable
progresswill be also set to 0.- Parameters
state (TaskState) – new state
- setProgress(progress)
Set the state to
progressof the task to theprogressvalue in parameter. It also activates theprogressQtsignal to propagate the change.- Parameters
progress (int) – new progress value
- getDirPath()
Returns the folder path where the video corresponding to this task is found.
- class PortPool(noPorts)
Class implementing a single access list for managing the allocation of communication ports with the processing instances.
On construction a list of size noPorts is created and initialized to 0, meaning all ports are avaialble.
- Parameters
noPorts (int) – the number of ports available for the application
- portPool: []
internal array corresponding to the total number of ports and their availability
- class TaskList
Class implementing a single access list for managing creation and accessing tasks.
- tasksList: []
the list storing all the added tasks
- addVideo(id, filename)
Creates a new task with the provided parameters and adds it to the list. The list is locked during the process.
- getNewTask()
Checks if there are any tasks with
TaskState.TaskState.newstate intasksList. If one is found, its status is changed toTaskState.TaskState.selectedand then it is returned.The access to the list is blocked during the execution.
- Returns
selected task or None
- Return type