pymmcore-plus / useq-schema

An implementation agnostic schema for describing a sequence of events during a multi-dimensional imaging acquisition.
https://pymmcore-plus.github.io/useq-schema/
BSD 3-Clause "New" or "Revised" License
14 stars 5 forks source link

Feature: add "requested destination" or other save specs? #131

Open tlambert03 opened 11 months ago

tlambert03 commented 11 months ago

Should we add something like requested_destination to MDASequence?

I don't (immediately) want to add a whole lot of specific saving stuff, but a single field requesting a destination path might be very useful for possible downstream writers: It would provide a directory, base name, and extension. Writers could then increment that base name as desired (until any further spec added instructions on that sort of thing)

@ianhi ?

ianhi commented 11 months ago

Sounds good to me! Maybe also an extra metadata dictionary to allow for downstream uses we can't conceive of now?

Are you imagining these all as required arguments, or optional?

tlambert03 commented 11 months ago

everything optional. you should probably always be able to call MDAEvent() or MDASequence() without args.

ianhi commented 11 months ago

ooh right because requested_destination is the name. Rather than something like "save_params" which would be it's own object

tlambert03 commented 11 months ago

yeah, for now, the writer (over in pymmcore-plus) would have all the parameters. This is just a bare-minimum sort of start. I can imagine something like this:

seq = MDASequence(requested_destination='...')

class MDARunner():
    def run(self, events: MDASequence):
        if seq.requested_destination:
            for writer in self.writers:  # these are the objects with as-of-yet undetermined parameters
                writer.set_destination(seq.requested_destination)

but... I dunno

ianhi commented 11 months ago

for writer in self.writers:

a little bit of an aside here: in a couple places you've given examples of how to work with many writers. Is that just a generality thing, or are their use cases im not thinking of for multiple writers? unless we think of something like the napari display as also being a writer

tlambert03 commented 11 months ago

yeah, good question. I can't see an immediate use case for multiple writers... but I do think that so far, the writer "spec" fits a general category of something that I can see multiple of: namely, anything that wants to be notified at the start, end, and each frame of an acquisition, let's call it a handler:

class Handler:
    def sequenceStarted(): ...
    def frameReady(): ...
    def sequenceFinished(): ...

so, I'm kinda mentally leaving that possibility open :)