omero.processor module

OMERO Grid Processor

class processor.MATLABProcessI(*args: Any, **kwargs: Any)[source]

Bases: ProcessI

command()[source]

Overrides ProcessI to call MATLAB idiosyncratically.

make_files()[source]

Modify the script_path field from ProcessI.make_files in ordert to append a “.m”

class processor.ProcessI(*args: Any, **kwargs: Any)[source]

Bases: Process, SimpleServant

Wrapper around a subprocess.Popen instance. Returned by ProcessorI when a job is submitted. This implementation uses the given interpreter to call a file that must be named “script” in the generated temporary directory.

Call is equivalent to:

cd TMP_DIR ICE_CONFIG=./config interpreter ./script >out 2>err &

The properties argument is used to generate the ./config file.

The params argument may be null in which case this process is being used solely to calculate the parameters for the script (“omero.scripts.parse=true”)

If iskill is True, then on cleanup, this process will reap the attached session completely.

Popen

Function which should be used for creating processes

activate()

Process creation has to wait until all external downloads, etc are finished.

allcallbacks(method, arg)
alreadyDone()

Allows short-cutting various checks if we already have a rcode for this popen. A non-None return value implies that a process was started and returned the given non-None value itself.

callback_cast

Function used to cast all ProcessCallback proxies

callbacks

dictionary from id strings to callback proxies

cleanup_output()[source]

Flush and close the stderr and stdout streams.

cleanup_tmpdir()[source]

Remove all known files and finally the temporary directory. If other files exist, an exception will be raised.

command()[source]

Method to allow subclasses to override the launch behavior by changing the command passed to self.Popen

deactivate()

Cleans up the temporary directory used by the process, and terminates the Popen process if running.

final_status

status which will be sent on set_job_status

interpreter

Executable which will be used on the script

isActive()

Tests only if this instance has a non-None popen attribute. After activation this method will return True until the popen itself returns a non-None value (self.rcode) at which time it will be nulled and this method will again return False

isFinished()
isRunning()
iskill

Whether or not, cleanup should kill the session

make_config()[source]

Creates the ICE_CONFIG file used by the client.

make_env()[source]
make_files()[source]
omero_home

Location for OMERO_HOME/lib/python

params

JobParams for this script. Possibly None if a ParseJob

pid

pid of the process. Once set, isn’t nulled.

popen

process. if None then this instance isn’t alive.

properties

Properties used to create an Ice.Config

rcode

return code from popen

set_job_status(client)[source]

Sets the job status

started

time the process started

status(msg='')[source]
stopped

time of deactivation

tmp_client()[source]

Create a client for performing cleanup operations. This client should be closed as soon as possible by the process

upload_output(client)[source]

If this is not a params calculation (i.e. parms != null) and the stdout or stderr are non-null, they they will be uploaded and attached to the job.

uuid

session this instance is tied to

wasActivated()

Returns true only if this instance has either a non-null popen or a non-null rcode field.

class processor.ProcessorI(*args: Any, **kwargs: Any)[source]

Bases: Processor, Servant

accepts_list

A list of contexts which will be accepted by this user-mode processor.

category

Category to be used w/ ProcessI

find_launcher(current)[source]
internal_session()[source]

Returns the session which should be used for lookups by this instance. Some methods will create a session based on the session parameter. In these cases, the session will belong to the user who is running a script.

lookup(job)[source]
parseJob(session, job, current=None)
process(client, session, job, current, params, properties=None, iskill=True)

session: session uuid, used primarily if client is None client: an omero.client object which should be attached to a session

processJob(session, params, job, current=None)
register_session(session)[source]
requestRunning(cb, current=None)
setProxy(prx)[source]

Overrides the default action in order to register this proxy with the session’s sharedResources to register for callbacks. The on_newsession handler will also keep new sessions informed.

See ticket:2304

use_session

If set, this session will be returned from internal_session and the “needs_session” setting ignored.

user_client(agent)[source]

Creates an omero.client instance for use by users.

willAccept(userContext, groupContext, scriptContext, cb, current=None)
class processor.UseSessionHolder(sf)[source]

Bases: object

check()[source]
cleanup()[source]
class processor.WithGroup(service, group_id)[source]

Bases: object

Wraps a ServiceInterfacePrx instance and applies a “omero.group” to the passed context on every invocation.

For example, using a job handle as root requires logging manually into the group. (ticket:2044)

processor.usermode_processor(client, serverid='UsermodeProcessor', cfg=None, accepts_list=None, stop_event=None, omero_home=omero_ext.path.path.getcwd)[source]

Creates and activates a usermode processor for the given client. It is the responsibility of the client to call “cleanup()” on the ProcessorI implementation which is returned.

cfg is the path to an –Ice.Config-valid file or files. If none is given, the value of ICE_CONFIG will be taken from the environment if available. Otherwise, all properties will be taken from the client instance.

accepts_list is the list of IObject instances which will be passed to omero.api.IScripts.validateScript. If none is given, only the current Experimenter’s own object will be passed.

stop_event is an threading.Event. One will be acquired from omero.util.concurrency.get_event if none is provided.

processor.with_context(func, context)[source]

Decorator for invoking Ice methods with a context