biolab / orange-canvas-core

Orange Canvas core workflow editor
GNU General Public License v3.0
36 stars 66 forks source link

Add-on example workflows are not sorted #203

Closed mw25 closed 3 years ago

mw25 commented 3 years ago

Hi,

I have seen that the example workflows are sorted for each examples_entry_points in this function:

https://github.com/biolab/orange-canvas-core/blob/28669be1ad2b510e2f6522d07d190132a0ee78d8/orangecanvas/application/examples.py#L17

The example workflows of my add-on are always placed at the end. I can't place them between or in front of the default workflows, no matter what prefix I give them. I would suggest sorting the whole workflow list at the end of collecting them:

https://github.com/biolab/orange-canvas-core/blob/28669be1ad2b510e2f6522d07d190132a0ee78d8/orangecanvas/application/examples.py#L72-L73

    workflows.extend(examples)
workflows.sort(key=lambda x: x.resource)
return workflows

Or is it your intention to always put the default examples bundled at the front?

ales-erjavec commented 3 years ago

Or is it your intention to always put the default examples bundled at the front?

Yes that is the intention.

markotoplak commented 3 years ago

@mw25, could you explain your use case?

Whenever we wanted to do something similar in our lab, we made a new release of Orange with some other name, where we basically modified the main.py slightly, like in https://github.com/quasars/quasar

Quasar does not modify the example workflows, but I think https://singlecell.biolab.si/ did. I just can not find the sources to that installer/runner anywhere.

mw25 commented 3 years ago

I have an add-on with special evaluation widgets. Some Orange inexperienced users will mainly use these widgets. To let them know how to use these widgets I have created example workflows. I wanted to put these workflows prominently at the top of Example Workflows Dialog so they would be seen right away (Only by our internal users, the add-on is not public).

I also thought of customizing Orange in certain places to suit my needs, as you suggested. Except I wanted to avoid having a custom Orange version unless absolutely necessary.

After the last release of orange3-single-cell, some installer/launcher files were removed. Did you mean the file orangecontrib/single_cell/launcher/__init__.py, possibly the examples_entry_points() function? Link

markotoplak commented 3 years ago

Oh, they were deleted - that is why I had problems finding them. Great that you found them!

That should be probably useful as a reference with possible small changes needed due to Orange's and canvas-core evolution in the meantime. I think this code was deleted because it was an additional burden to maintain it. The code that runs Quasar is up-to-date.

I do understand that it might be useful for the add-on to put its example workflows to the front. I do not see a reason why Orange would need to prevent that, so perhaps this sorting could be rewritten. Whatever the rewrite is it should keep backward compatibility. I haven't looked into the code, but perhaps there is a way that keeps the current order for the current add-ons and allows some new workflows to come to the front. Perhaps negative priorities?

ajdapretnar commented 3 years ago

I just wanted to say what @markotoplak already said - I also see no reason for enforcing the priority. So a +1 from me.

mw25 commented 3 years ago

As I understand the process in the function workflows() at the moment, it goes like this:

In this context, I'm afraid I don't understand what @markotoplak mean by negative priorities.

I think my original suggestion was not a good idea, because then the workflows of the different add-ons would get mixed up, because they seem to be always numbered from the beginning. (orange3-text is the only official add-on where I could just find example workflows: Examples).

I now had the idea to work with the entry point name. For example, in the function quoted above, how about not just appending the entry-points to the Orange-defaults, but putting them at the front for a certain criterion (e.g. prefix is numeric or starting with 0)?

markotoplak commented 3 years ago

@mw25, it seems that by now you have worked on this the most. :) If you find a good solution feel free to make a pull request.

mw25 commented 3 years ago

I will be on vacation for now 😁, but after that I think I will give it a try.

mw25 commented 3 years ago

Hi,

I have seen that the example workflows are sorted for each examples_entry_points in this function:

https://github.com/biolab/orange-canvas-core/blob/28669be1ad2b510e2f6522d07d190132a0ee78d8/orangecanvas/application/examples.py#L17

The example workflows of my add-on are always placed at the end. I can't place them between or in front of the default workflows, no matter what prefix I give them. I would suggest sorting the whole workflow list at the end of collecting them:

https://github.com/biolab/orange-canvas-core/blob/28669be1ad2b510e2f6522d07d190132a0ee78d8/orangecanvas/application/examples.py#L72-L73

    workflows.extend(examples)
workflows.sort(key=lambda x: x.resource)
return workflows

Or is it your intention to always put the default examples bundled at the front?