Closed
Bug 1318960
Opened 8 years ago
Closed 7 years ago
Migrate files only when messages change
Categories
(Localization Infrastructure and Tools :: Fluent Migration, defect)
Localization Infrastructure and Tools
Fluent Migration
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: Pike, Assigned: stas)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Right now, the guard on wether to change a file or not is
if snapshot.toJSON() == current.toJSON():
We should only change the current file if the AST of the entities change.
It'd also be a nice optimization if we wouldn't toJSON() both ASTs. Given how often we'll run that code in practice, that might be worthwhile.
Assignee | ||
Comment 1•8 years ago
|
||
(In reply to Axel Hecht [:Pike] from comment #0)
> Right now, the guard on wether to change a file or not is
>
> if snapshot.toJSON() == current.toJSON():
>
> We should only change the current file if the AST of the entities change.
What's the rationale for this requirement?
> It'd also be a nice optimization if we wouldn't toJSON() both ASTs. Given
> how often we'll run that code in practice, that might be worthwhile.
I considered implementing Node.__eq__ but it looked like a lot of work. I don't think we should be worried about the performance at all tbh.
Reporter | ||
Comment 2•8 years ago
|
||
(In reply to Staś Małolepszy :stas from comment #1)
> (In reply to Axel Hecht [:Pike] from comment #0)
> > Right now, the guard on wether to change a file or not is
> >
> > if snapshot.toJSON() == current.toJSON():
> >
> > We should only change the current file if the AST of the entities change.
>
> What's the rationale for this requirement?
That we don't end up with files that only have a license header, for example. Also, as a side effect of that, less commits for many migrations.
Also, forward looking this will be the right indication when doing minimally-invasive edits based on the work here.
> > It'd also be a nice optimization if we wouldn't toJSON() both ASTs. Given
> > how often we'll run that code in practice, that might be worthwhile.
>
> I considered implementing Node.__eq__ but it looked like a lot of work. I
> don't think we should be worried about the performance at all tbh.
I'm worried about performance of stuff to be run during merge day, tbh.
Assignee | ||
Updated•7 years ago
|
Blocks: fluent.migrate
Assignee | ||
Comment 3•7 years ago
|
||
https://github.com/projectfluent/python-fluent/commit/73214e4686390dbc1fd068071db1cbb8347c3963 introduced BaseNode.equals which will help avoid serialization to JSON. I already tested it and all tests passed.
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → stas
Status: NEW → ASSIGNED
Summary: l20n.migrate should only change a file if entities change → Migrate files only when messages change
Assignee | ||
Comment 4•7 years ago
|
||
Attachment #8925105 -
Flags: review?(l10n)
Reporter | ||
Comment 5•7 years ago
|
||
I got a couple of questions on the identity check:
What's the right set of ignored_fields? Right now, you're using the default ['span'], I wonder if we should use ['comment','span']?
And, should we really re-serialize on order?
Flags: needinfo?(stas)
Assignee | ||
Comment 6•7 years ago
|
||
(In reply to Axel Hecht [:Pike] from comment #5)
> What's the right set of ignored_fields? Right now, you're using the default
> ['span'], I wonder if we should use ['comment','span']?
I don't think so. This is only relevant in the scenario when a message had already been migrated by the localizer manually and the value is the same as in the legacy file but the comment is different than in en-US. I think we should then leave the message as migrated by the localizer.
> And, should we really re-serialize on order?
I don't have a strong opinion about this. We can sort them before the equality check. That said, if subsequent changesets modify even one message, we'll re-serialize the whole file using the order from the en-US template anyways. Might as well do it when messages don't change except for their order. I'm happy leaving the decision to you.
Flags: needinfo?(stas) → needinfo?(l10n)
Reporter | ||
Comment 7•7 years ago
|
||
'k re comments.
As for sorting, I think we should only touch the file when we modify the contents. In that context, yeah, let's sort first, please.
Flags: needinfo?(l10n)
Reporter | ||
Updated•7 years ago
|
Attachment #8925105 -
Flags: review?(l10n) → review+
Assignee | ||
Comment 8•7 years ago
|
||
Landed in https://github.com/projectfluent/python-fluent/commit/9ec3db8322b5bd074e506a166caff714c243373a.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•7 years ago
|
No longer blocks: fluent.migrate
Component: Python Library → Fluent Migration
Product: L20n → Localization Infrastructure and Tools
You need to log in
before you can comment on or make changes to this bug.
Description
•