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

FileSelector/MultiFileSelector don't update objects when path is updated and FileSelector doesn't set its value #545

Closed
maximlt opened this issue Oct 8, 2021 · 2 comments · Fixed by #814
Labels
type-bug Bug report
Milestone

Comments

@maximlt
Copy link
Member

maximlt commented Oct 8, 2021

FileSelector behaves like Selector and should as such set its value to the first item of objects, objects being the result of a glob on path. When path is updated it should also update objects.

MultiFileSelector should also update objects when path is updated. Also the docs currently state that the default value is all of the matched files, but in practice it's None.

A param.MultiFileSelector is the analog of ListSelector but for files, i.e., again supporting a path glob but allowing the user to select a list of filenames rather than a single filename. The default value in this case is all of the matched files, not just the first one.

import param

class A(param.Parameterized):
    fs = param.FileSelector(path='/usr/share/*')
    mfs = param.MultiFileSelector(path='/usr/share/*')

a = A()

print(a.fs is None)  # True!
paths = a.param.fs.objects.copy()
a.param.fs.path = '/usr/bin/*'
print(a.param.fs.objects == paths)  # True!

print(a.mfs == a.param.mfs.default == None)  # True!
paths = a.param.mfs.objects.copy()
a.param.mfs.path = '/usr/bin/*'
print(a.param.mfs.objects == paths)  # True!
@maximlt maximlt added type-bug Bug report TRIAGE User-submitted issue that hasn't been triaged yet. labels Oct 8, 2021
@maximlt
Copy link
Member Author

maximlt commented Oct 8, 2021

Not updating objects when path changes seems like a bug to me.

But changing the default value of FileSelector (inconsistent with Selector) and MultiFileSelector (inconsistent with Selector but consistent with ListSelector) is a backwards incompatible change, which I'm less inclined to fix now.

@maximlt maximlt removed the TRIAGE User-submitted issue that hasn't been triaged yet. label Nov 18, 2021
@MridulS MridulS added this to the v1.12.1 milestone Feb 7, 2022
@maximlt maximlt modified the milestones: v1.12.x, 2.0 Apr 4, 2023
@jbednar
Copy link
Member

jbednar commented May 12, 2023

I vote for changing the default as indicated and for updating for path changes. The default behavior of None is both inconsistent with the docs and also seems very unlikely to be useful in practice, and Param 2.0 is probably our only real chance to change that. Updating for path changes is already covered by #546.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Bug report
Projects
None yet
3 participants