Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Propagate args / kwargs to loadLoadables | ⚠️ Changes removed from main #7270

Merged

Conversation

marcus-wirtz-snkeos
Copy link
Contributor

@marcus-wirtz-snkeos marcus-wirtz-snkeos commented Oct 10, 2023

⚠️ Changes originally introduced through this pull-request have been removed from main by force pushing. Corresponding changes are superseded by #7330 ⚠️

Rational:


Would be great to have the progressbar option of loadSeriesByUID also for the higher level functions.

@marcus-wirtz-snkeos marcus-wirtz-snkeos changed the title ENH: propagate args / kwargs to loadLoadables ENH: Propagate args / kwargs to loadLoadables Oct 10, 2023
Copy link
Contributor

@lassoan lassoan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, I agree that it can be useful to expose messages and progressCallback arguments at higher-level functions, too. I would prefer to explicitly specify these arguments, as it would make the API more clear (and 2 extra arguments are not too many and I don't expect that loadLoadables will have many new options in the future).

@marcus-wirtz-snkeos
Copy link
Contributor Author

Thank you for your contribution, I agree that it can be useful to expose messages and progressCallback arguments at higher-level functions, too. I would prefer to explicitly specify these arguments, as it would make the API more clear (and 2 extra arguments are not too many and I don't expect that loadLoadables will have many new options in the future).

Alright, I explicitly specified the arguments. I realized that the main time consumer (~80%) in most of my cases is actually the function getLoadablesFromFileLists rather than loadLoadable. Does that match your experience? I updated the PR to pass the progressbar to the longer lasting function call.

@jcfr
Copy link
Member

jcfr commented Oct 30, 2023

Nitpick: Adding type annotation would be nice as well though this is outside of the immediate scope of this pull request

@marcus-wirtz-snkeos
Copy link
Contributor Author

Nitpick: Adding type annotation would be nice as well though this is outside of the immediate scope of this pull request

I don't see a single type hint in this entire module so far (even in the entire Scripted folder?) :-)

@jcfr
Copy link
Member

jcfr commented Nov 1, 2023

We indeed only recently started to introduce them in new code.

For example:

  • Modules/Scripted/DICOMLib1
  • Base/Python/slicer/parameterNodeWrapper2

In this case, adding annotation for messages would be sufficient. Adding the type for callback would be more involved.

Footnotes

  1. https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/DICOMLib/DICOMProcesses.py#L55-L58

  2. https://github.com/Slicer/Slicer/blob/main/Base/Python/slicer/parameterNodeWrapper/wrapper.py

@@ -22,7 +22,7 @@


# ------------------------------------------------------------------------------
def loadPatientByUID(patientUID):
def loadPatientByUID(patientUID, messages=None, progressCallback=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def loadPatientByUID(patientUID, messages=None, progressCallback=None):
def loadPatientByUID(patientUID, messages: Optional[list[str]]=None, progressCallback=None):

You also need to add the following at the top:

from typing import Optional

@jcfr
Copy link
Member

jcfr commented Nov 1, 2023

Integrating. Annotation type will be introduced later.

@jcfr jcfr merged commit 27cab9a into Slicer:main Nov 1, 2023
5 checks passed
@jcfr jcfr changed the title ENH: Propagate args / kwargs to loadLoadables ENH: Propagate args / kwargs to loadLoadables | ⚠️ Changes removed from main Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants