-
Notifications
You must be signed in to change notification settings - Fork 2
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
Restrict symbols in names #43
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oruebel
approved these changes
Feb 3, 2025
rly
commented
Feb 3, 2025
rly
commented
Feb 3, 2025
rly
commented
Feb 3, 2025
rly
commented
Feb 3, 2025
rly
commented
Feb 3, 2025
Sorry @oruebel , I forgot to make a few changes in |
oruebel
approved these changes
Feb 3, 2025
Looks great! This will help a lot with language and backend compatibility. Hopefully it won't cause headaches for too many people. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Namespace name
When HDMF caches schema, groups are created based on the namespace name. Therefore the namespace name must not contain
"/"
for both HDF5 and Zarr backends. They should also not contain":"
for Zarr backends on Windows because":"
is not allowed in a file name. (There are actually many characters that are not allowed in filenames on Windows, but":"
is probably the most likely to be used.) We should consider restricting the other ones. Ref: hdmf-dev/hdmf-zarr#219The schema already states that namespace names cannot contain whitespace (I don't know why).
Proposal: Additionally disallow "/" and ":" (in addition to whitespace) from namespace names
Version string
Groups are also created based on the version string. The version string should follow the NWB versioning guidelines: https://www.nwb.org/versioning-guidelines/
I do not think we need to be strict about this, but at least, the version string must not contain
"/"
and should not contain":"
.Proposal: Disallow "/" and ":" whitespace from version strings
Fixed group, dataset, attribute, and link names
For the same reason as above, names of groups and datasets, which may be set in schema or defined by users, must not contain
"/"
and should not contain":"
. This restriction is already set in HDMF. hdmf-dev/hdmf#1202Fixed names of groups, datasets, attributes, and links (things that could be properties of a class) and default names of groups and datasets set in a schema must follow the pattern
"^[A-Za-z_][A-Za-z0-9_]*$"
for compatibility with the MatNWB and PyNWB APIs: NeurodataWithoutBorders/matnwb#35The above link only discusses whitespace for Matlab, but Matlab allows only the above pattern for field names, property names, and variable names. https://www.mathworks.com/help/matlab/ref/struct.html
Python attribute names have the same restriction. (Matlab additionally says the maximum length of a name = 63 characters currently.)
In HDMF, we have already blocked creating fixed names of groups and datasets with
"/"
: hdmf-dev/hdmf#1219Proposal: Require fixed names for groups, datasets, attributes, and links set in schema to follow the pattern
"^[A-Za-z_][A-Za-z0-9_]*$"
Data type names
When generating classes, PyNWB and MatNWB use
data_type_def
as the class name.Python class names must follow the pattern
"^[A-Za-z_][A-Za-z0-9_]*$"
(plus some allowance of non-ASCII characters): https://docs.python.org/3/reference/lexical_analysis.html#identifiers .Matlab class names follow the same rules: https://www.mathworks.com/help/matlab/ref/classdef.html
Therefore,
data_type_def
values should follow the same pattern"^[A-Za-z_][A-Za-z0-9_]*$"
.Proposal: Require data type names to follow the pattern
"^[A-Za-z_][A-Za-z0-9_]*$"
The last two proposals were previously proposed in NeurodataWithoutBorders#1 . I am just reviving that issue here and adding to it.