pyblish / pyblish-nuke

Pyblish for Nuke
GNU Lesser General Public License v3.0
9 stars 12 forks source link

Silent publishing #36

Closed tokejepsen closed 6 years ago

tokejepsen commented 7 years ago

This PR gives a built-in option for end-users to publish without any GUI.

oct 26 2017 1-24 pm oct 26 2017 1-25 pm

mottosso commented 7 years ago

I think for this to work, there will have to be some indicator progress. Otherwise you'd have no way of knowing whether it froze or just takes a really long time.

It'd be simple enough to do, we can convert util.publish into an iterator, and have it emit result dictionaries per plug-in. Then your splash gui could simply print the currently processed plug-in and perhaps overall status (errored, or all-clear).

tokejepsen commented 7 years ago

With the publish iterator on its way, let's talk about how to show the progress.

Initially I was thinking of a simple label of the plugin plus success/failed icon:

publish_progress

Ideally a progress bar would be better, but getting a total count of the plugins won't be possible without collecting first, unless you would count collection as a 1/4 of the progress.

mottosso commented 7 years ago

Ideally a progress bar would be better, but getting a total count of the plugins won't be possible without collecting first, unless you would count collection as a 1/4 of the progress.

That's a good point.

Maybe it'd be ok to yield different results at different times? For example..

iterator = pyblish.util.publish_iter()
plugins, context = next(iterator)  # Before collection
plugins, context = next(iterator)  # After collection, but before main processing
for Plugin, context in iterator:
  ...

Not sure how convenient that is..

tokejepsen commented 7 years ago

Maybe it'd be ok to yield different results at different times? For example..

Not entirely sure what you mean here.

We could also have two progress bars; one for collection and one for the main processing? Maybe that is what you meant...

mottosso commented 7 years ago

Not entirely sure what you mean here.

I mean yielding at multiple times in the function. It doesn't just have to come from the loop.

def publish():
  context = api.Context()
  yield context
  for collector in [SomeCollector]:
    api.process(collector)
  yield context

  for Plugin, instance in api.discover():
    yield Plugin, instance

Now when you call next(iterator) you'll get the first yield. When you call it again, you'll get the second yield. The third time onwards, you'll get the results from the loop.

tokejepsen commented 7 years ago

Alright let's walk through an example as I see it working.

I have ten plugins; three collectors, three validator, three extractors and one integrator.

Depending on the amount of plugins disregarded, the jump between the collection increment and the rest of the increments could be quite large. Also need to note that we are not considering the amount of instances a plugin needs to be process, but I can't figure out how to incorporate that.

tokejepsen commented 7 years ago

Actually I might have a solution for considering the instances.

Until the collection has been processed the percentage calculation would be:

(plugins processed) / (total plugins to process)

Once we have processed the collection, we'll have some instances. Continue from the above example the collection produced 4 instances that will be processed by the remaining plugins with the following calculation:

((instances processed / amount of instances) + plugins processed)) / (total plugins to process)

Will all this fairly complicated code, we are probably best off having the percentage calculation yielded from the publish iterator so the returns of the yields would be (percentage, result, context)

mottosso commented 7 years ago

Will all this fairly complicated code, we are probably best off having the percentage calculation yielded from the publish iterator so the returns of the yields would be (percentage, result, context)

How about we add progress to the result dictionary? It's already got a duration entry, for how long it took a particular plug-in to run, so I think some more of that kind of metadata would fit.

tokejepsen commented 7 years ago

How about we add progress to the result dictionary?

Sure, that sounds good to me. Would it be alright to add that in the publish.util module only?

mottosso commented 7 years ago

I guess for starters, add it like you did, and see if that's enough to build a reasonable GUI. If we add to result we'll need to do that across the board, for GUIs as well.

tokejepsen commented 7 years ago

Added a progress bar to work with the new pyblish.util.publish_iter

oct 31 2017 3-49 pm

tokejepsen commented 7 years ago

What do you think of this now? Works with https://github.com/pyblish/pyblish-base/pull/326

tokejepsen commented 7 years ago

Is this mergable now?

When it is I'll focus on some tests in pyblish-base to cement the essential parts of the functionality.

mottosso commented 7 years ago

We can't merge this, as the feature doesn't exist in base yet.

tokejepsen commented 7 years ago

We can't merge this, as the feature doesn't exist in base yet.

Sorry, didn't mean for it to be merged, just whether it was looking complete to you.

mottosso commented 7 years ago

Other than that nitpick, sure, looks good!