-
Notifications
You must be signed in to change notification settings - Fork 279
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: add basename for loaders #4363
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use actual default values instead of None
. I've made explicit suggestions in one case but it should be generalised
Co-authored-by: Clément Robert <cr52@protonmail.com>
Co-authored-by: Clément Robert <cr52@protonmail.com>
Thanks! Learnt a nicer way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! Left a comment on fixing the type check failures.
Had a couple minutes to think about this patch, and while I don't want to oppose it, I want to raise a couple important issues with the design.
Setting Furthermore, wouldn't The image filename generating code is already difficult to maintain, and I'll fully admit that I didn't grasp the full picture in 20min of exploration. I think it's important that we try our best not to make the code even harder to reason about. |
Thanks for your comments! Sorry for my late response since I'm traveling these days. I agree to make the logic simpler rather than more complex, while it might be better to make the name customizable than hard-coded? I raise this question when I have to read a series of dataset (say, with filename |
It is certainly achievable if you construct the filename outside yt and pass it to the |
Let me double-confirm: I used to wrap up a data loader into a custom function |
not yet. I agree that something in the spirit of your patch is needed to support that. I would feel much more confortable with discussing this if anyone could explain how this line Line 388 in 7ef07cf
ends up affecting image file prefixes. |
For all the stream dataset types, The
and I don't see anywhere else the So in terms of how that relates to the image file prefixes, it should be similar to any other dataset type. When a name is not supplied to if name is None:
name = str(self.ds) which returns the dataset def __str__(self):
return self.basename and @property
def basename(self):
return os.path.basename(self.filename) So in effect, Slight confusing aside... but it's worth noting that during the |
Thanks @chrishavlin for the detailed walkthrough. I missed that As I already pointed, I'm personally -1 on |
Ya, I agree -1 for |
Is it just images we prefix with this? Do we use it for sidecar files,
ever?
…On Wed, Mar 22, 2023 at 2:45 PM Chris Havlin ***@***.***> wrote:
Ya, I agree -1 for basename, for all the reasons you point out. I'm also
not so sure about image_prefix since it's a little more general than that
(e.g., print(ds) is not obviously related to an image prefix). How about
just dataset_name with an explanation in the docstring that this is used
in place of a filename for in-memory stream datasets?
—
Reply to this email directly, view it on GitHub
<#4363 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVXO5W63I6DFU5DKEWLCDW5NJGRANCNFSM6AAAAAAVOZTBNM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sounds good to me |
So from what I can tell, in general, the
# Load Morton index from file if provided
fname = getattr(ds, "index_filename", None) or f"{ds.parameter_filename}.ewah" or to store sidecar
I'm not sure how much of that is relevant to the Stream frontend in particular, but I think that yes, the All that to say, yes, the |
So I think we're in agreement here, ya? use
Sound good, @neutrinoceros and @matthewturk ? @jisuoqing do you mind making that change? (Maybe wait a bit to give @neutrinoceros and/or @matthewturk a chance to reply to this comment) |
Thanks! Happy to make the change after hearing back from others. |
Sounds good to me |
Let's do it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you ! LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks @jisuoqing !
The
handler.name
are hard-coded with a string in dataset loaders, and assigning values tods.basename
will pop out anAttributeError: can't set attribute 'basename'
(which is allowed by previous yt versions, though).Here an additional parameter
basename
for dataset loaders is proposed, so users can load multiple datasets with different base names and analyze/visualize them in a workflow (e.g., saving plots with different filenames without worrying about overwriting each other.)