-
Notifications
You must be signed in to change notification settings - Fork 276
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
BUG: implement AthenaDataset._is_valid #3424
Conversation
2812a8d
to
82a2ab8
Compare
except Exception: | ||
pass | ||
return False | ||
return "vtk" in os.path.basename(filename) |
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'm 99% sure that it's not even in the filename, but it's supposed to be .vtk
extension. So either:
filename.endswith(".vtk")
or
os.path.splitext(filename)[-1] == ".vtk"
or
pathlib.Path(filename).suffix == ".vtk"
(so many choices!) would be even more strict and appropriate.
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.
yeah I went your your first suggestion in my first iteration, then changed my mind in fear that it was not conservative enough, but I'm glad that you made me change my mind again, !
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.
forced pushed !
82a2ab8
to
0e92b11
Compare
We're definitely going to need to revisit this, because this is going to
have a ton of false positives.
…On Fri, Jul 9, 2021 at 10:04 AM Clément Robert ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In yt/frontends/athena/data_structures.py
<#3424 (comment)>:
> @@ -632,12 +632,7 @@ def _parse_parameter_file(self):
@classmethod
def _is_valid(cls, filename, *args, **kwargs):
- try:
- if "vtk" in filename:
- return True
- except Exception:
- pass
- return False
+ return "vtk" in os.path.basename(filename)
forced pushed !
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3424 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVXO4H2XD6UQCEQLBXNHLTW4FXPANCNFSM5ACK6WGQ>
.
|
Yup. Do you know someone in the community who use Athena and might be able to help ? |
I think we can just follow the vtk's manual:
I don't think there's anything special that Athena does, so there's always going to be an ambiguity. Looking at what frontend does, it expects 1. from above snippet and 2. in a form of string containing: So roughly:
|
I think that would work for me. |
Although I'd recommend avoiding using |
Cool, thanks a lot. I'll implement your suggestion. |
0e92b11
to
c14a09c
Compare
@Xarthisius I implemented a somewhat stricter version of your suggestion using regexes.
@matt thanks for the headsup. I ended up using the binary implementation of For reference, I tested my implementation by loading every Athena datasets we have available: import yt
for name in ["MHDSloshing","ShockCloud", "MHDBlast", "RamPressureStripping", "AM06", "KeplerianDisk"]:
print(yt.load_sample(name)) |
Oh and now this fixes #3001 |
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.
Looks great.
if not re.match(b"# vtk DataFile Version \\d\\.\\d\n", fh.readline(256)): | ||
return False | ||
if not re.match( | ||
b"(CONSERVED|PRIMITIVE) vars at time= .*, level= \\d, domain= \\d\n", |
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 need to dig into the code and relevant datasets more, but I recall that there are some Athena datasets which are just one variable only--so they may not have CONSERVED
or PRIMITIVE
in the header. It may take me a day or two to figure out if this is the case.
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.
Good to know ! it may be useful to have such a dataset in the sample collection. I wrote using only the ones we already have as validation.
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 checked, you remembered correctly:
https://princetonuniversity.github.io/Athena-Cversion/AthenaDocsUGbtk
From the source code (see line 129), it looks like in the case of single-variables, "CONSERVED vars" is replaced by "Really cool Athena data". I could reproduce this joke and hardcode it in yt too, but it seems safer to assume it could change any time in the future (no matter how unlikely), so I'm going to loosen the strictness of this regexp.
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.
Fine by me.
Wait @jzuhone , I think there was a misunderstanding here. You merged before I could push the fix you required ! |
@meeseeksdev backport to yt-4.0.x |
…4-on-yt-4.0.x Backport PR #3424 on branch yt-4.0.x (implement AthenaDataset._is_valid)
PR Summary
This patch adresse (bug does not fix) #3001 (update: now it does !)
I ran into a random CI failure again because of this brittle validator, so I hope that this patch makes it even less likely and doesn't break anything.
Long term, this validator must be refined into a more characteristic heuristic.update: done