-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Allow synchronization of filename attributes #303
Comments
Thanks for the clear bug report!
I'd worry that having Datafiles rename files will cause all sorts of unforeseen problems. For example, what if two processes have the file open? If
On first pass, I think this is preferable and filename attributes should always be frozen. If a filename attribute is modified, what should happen? Ignore that attribute's changed value or raise an exception? This feels potentially related to #294. |
In general I agree that (a) is preferable as the default option. In particular, your suggested solution of ignoring the change and raising an exception sounds like the right solution here. That said, I believe there are valid use cases for changing the "filename" attributes and having them reflect in the filename - especially if the behaviour is opt-in via a The concern about two processes accessing the same file is valid, but I never felt like that was a fully supported use case - I suspect the users can already mangle the data by having the processes overwriting each the same datafiles (i.e. if using If all of this sounds acceptable, I would volunteer to implement the required changes. I already have a preliminary version of (b) implemented, and I can also contribute (a) and potentially file locking if that's what it would take to get the changes merged upstream 🙂 |
I'd like to see what that looks like in a PR! Given that the |
@jacebrowning I put up the preliminary changes, have a look at #304 🙂
I wouldn't discount the possibility, I really do think this is a valid concern. But as I mentioned, we currently lack the mechanism to prevent data corruption in the scenario of multiple processes accessing the same data files. I haven't tested it, but I am fairly certain that with sufficiently high amount of simultaneous processes reading and modifying the same data files, even the current state of things would lead to data corruption. But that's perhaps a discussion for a different issue 🙂 |
Currently,
datafiles
handles any attributes that are part of the filepath as not being stored in the file itself. Personally I consider this a good design, as duplicating the value would potentially cause issues if the "filename" and "file content" values did not agree.However, it seems we are unable to preserve any changes to the attributes that are part of the filename, effectively rendering them read-only. Consider a following datafile called
JohnDoe.yml
:and an associated short script:
As expected, this will produce the following output:
However, if we continue to modify the model instance:
we can observe on the filesystem that the file has been modified:
however, the filename itself has not been changed, it is still
JohnDoe.yml
, resulting in the following data:which does not align itself with the expected output from the viewpoint of the user. I would argue we should support one of the two options:
a) the "filename" attributes should be frozen and not allowed to be modified
b) or we should allow their modification, but rename the files, effectively preserving their modified value in the filename
If renaming is too drastic for it to be the default, we could perhaps have (a) as the default behaviour and allow (b) via an optional
rename=True
flag (similar how we handledefaults=True
).The text was updated successfully, but these errors were encountered: