Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #2177 (new)

Opened 14 years ago

Last modified 10 years ago

Add callback methods to omero.scripts.client

Reported by: jamoore Owned by: jamoore
Priority: critical Milestone: Unscheduled
Component: Scripting Version: 5.0.2
Keywords: n.a. Cc: jburel, wmoore, crueden-x
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.5d
Sprint: n.a.

Description (last modified by jamoore)

After discussions (Apr 12), scripts should have a mechanism for requesting more information from the user and informing the user about the current status of the script ("0.5% finished", etc.)

This will require work on the notification system (#2169)

Proposal:

 mainJobParams = omero.grid.JobParams()
 mainJobParams.name = "imageProjection" # Name of script
 mainJobParams.inputs = {"image" : omero.grid.Param(...)}

 secondaryJobParams = omero.grid.JobParams()
 secondaryJobParams.name = "z" # Name of step
 secondaryJobParams.input = {"z" : omero.grid.Param(...)}

 # Define a script which takes an image
 c = omero.scripts.client("name",\
        mainJobParams,
        callbacks = [
            secondaryJobParams
        ])

 values = c.callback(index=0, timeout = 5)
 # or
 values = c.callback(name="z", timeout = 5)

 c.progress(percent = 0.5, step = "Downloading", index = 5, total = 100)
 c.exception(exception = ex)

 # Possible future additions:
 c.checkpoint() # saves all the session items

Suggestions welcome

See:

Change History (8)

comment:1 Changed 14 years ago by wmoore

Just saving these ideas from discussion...

class GetZSliceCallback(ScriptUserCallback):
        def __init__(self):
            self.values = {}
            self.params = omero.grid.JobParams()
            z = omero.scripts.Long()
            self.params.inputs = {"z":z}

        def getParams(self, current = None):
            return self.params

        def setValue(self, name, value, current = None):
            self.values[name] = value
    
    cb = GetZSliceCallbackI()
    client.waitOnCallback(cb)
    z = cb.values["z"]
    
    client.waitOnCallback(ConfirmCallback())
    client.callback(StatusCallback(percent=.5))

    ofile = client.upload(someFile, format="text/html")
    cb = HtmlCallbackI(ofile)
    client.waitOnCallback(cb)
    
    

    """
    class ScriptCallbackHandlerI(ScriptCallbackHandler):
        def handle(jobId, cb):
            
        
    ISessionPrx prx;
    ScriptCallbackHandlerI handler;
    prx.runScript(scriptId, inputsValues, timeout, handler);
    
    """

    """
    ALTERNATIVE 1.
    """
    c = omero.scripts.client("name, description",
        job_params_1,
        callbacks = {
            "roi": job_params_2,
            "t": job_params_3,
            "z": jobs_params_4
            })
    
    c.status(0.3)
    do_something()
    c.status(0.5)
    values = c.callback("z")
    do_something_else()
    c.callback("t")
    c.status(0.7)
    values = c.callback("roi")
    c.status(1.0)
    if not c.hasCheckpoint(0):
        resume
    elif not c.hasCheckpoint(1):
        resume
    else:
    c.setOutput("image", 1)
    values = c.checkpoint(1, callback="z")
    
    
    c.progress(percent=0.3, step="Downloading")
    
    for d in range(downloads):
        c.progress(percent=0.3, step="Downloading", current=d, total=downloads)
    
    c.setOutput("processed", process_downloads())
    c.checkpoint(2) 
    c.progress(percent=0.5, step="Processing", current=5, total=123)

comment:2 Changed 14 years ago by jmoore

  • Milestone changed from OMERO-Beta4.2 to Unscheduled
  • Sprint 2010-04-02 (6) deleted

comment:3 Changed 11 years ago by spli

  • Cc crueden-x added; dzmacdonald removed

Out of the tickets in story #1341 this is potentially the most useful for long running scripts, which is what we've settled on for doing feature calculation (at least in the short term). Progress information is almost essential, callbacks for client feedback/choices would make the scripting UI a lot nicer.

CC: Curtis, might be useful for ImageJ work.

comment:4 Changed 11 years ago by jmoore

This needs to be compared with the new(ish) omero.cmd.Handle interface: https://github.com/openmicroscopy/openmicroscopy/blob/v.4.4.6/components/blitz/resources/omero/cmd/API.ice#L89

That may mean that a script need only do (conceptually) getCallback().step(0,10) if a callback has been set.

comment:5 Changed 10 years ago by jamoore

Referencing ticket #1341 has changed sprint.

comment:6 Changed 10 years ago by jamoore

  • Description modified (diff)
  • Version set to 5.0.2

comment:7 Changed 10 years ago by crueden-x

This is a great idea. We'll be able to implement it easily in ImageJ-OMERO by leaning on the StatusService (and eventually the TaskService), once an API is in place on the OMERO side.

comment:8 Changed 10 years ago by crueden-x

One minor issue to consider is to ensure the progress reporting is lenient -- I can foresee situations with ImageJ plugins where there are bugs in the algorithm's status reporting, or new subtasks get spawned by parent tasks, so progress might appear to go backwards in some cases. As long as there are no assumptions about monotonically increasing progress, it should be fine.

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.73146 sec.)

We're Hiring!