Skip to content
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

Migrate number nodes with sequence to CBNs. #7582

Merged
merged 8 commits into from
Feb 9, 2017

Conversation

ikeough
Copy link
Contributor

@ikeough ikeough commented Feb 6, 2017

Purpose

While developing a migration for the number node, a behavior was noticed in the migration framework that causes a second migration to not be applied when the first migration has the to field set to null. The to field has never really been clear in its intent, and could potentially cause a migration to get "swallowed" by another migration. Ex. you have a migration from: 0.0.0.1 to: 2.0.0.0 and one from: 1.0.0.0 to: 2.0.0.0. The second migration would never be applied because the first would set the current version to 2.0.0.0 during the loop. Similarly, without to: defined as in from: 0.0.0.1, any other migrations would not get processed because the loop exits when to: is null.

This PR marks the To field as obsolete on NodeMigrationAttribute, and adjusts the migration code to apply all migrations sequentially starting with the one whose version is >= the version of the stored workspace. All existing migrations have this intent, with migrations version ranges being sequential. So this change does not affect those migrations, and they will continue to be processed sequentially.

This PR also migrates number nodes with sequences, i.e. 0..5 to CBNs with 0..5;. Currently, we do not allow the user to input 0..5 in a number node, but we do not disallow the number node from opening such a node. It has been tested to work on number nodes with numeric ranges like 0..5 and ranges with variables like a..b..c. All connectors are successfully re-established after migration.

  • All tests pass on the self-service CI
  • Changes to the API have been listed in the API Changes doc.

PTAL @mjkkirschner
FYI @gregmarr


// Increase the number values.
numNode.Value = numNodeValue;
numNode.SetCodeContent(numNodeValue + ";", new ProtoCore.Namespace.ElementResolver());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a temporary change for testing purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This test needs to be updated to work after this migration is added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's going to replace the existing test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now.

@@ -321,22 +321,16 @@ orderby result.From
var migrationData = new NodeMigrationData(elNode.OwnerDocument);
migrationData.AppendNode(elNode as XmlElement);

while (workspaceVersion != null && workspaceVersion < currentVersion)
foreach(var migration in migrations.Where(m=>m.From >= workspaceVersion))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to make sense - does it break any existing migration tests here or for revit?

Copy link
Member

@mjkkirschner mjkkirschner Feb 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though - From seems kind of strange in context when said out loud, this WorkspaceMigration migrates workspaces with versions from 2.0... I don't know how to finish this sentence to make this correct.

Perhaps WorkspaceAttribute needs a different property name like migrateWorkspaceVersionsBelow ... I am not sure.

Also seems CurrentVersion is no longer used in this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove CurrentVersion, and I propose to rename from: to version, as in "This node migration is applied to nodes in version x.x.x and higher."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it "version x.x.x and lower", or "lower than version x.x.x"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregmarr You are correct :)

@@ -1360,6 +1354,7 @@ public class NodeMigrationAttribute : Attribute
/// <summary>
/// Version this migrates to.
/// </summary>
[Obsolete("All migrations are now processed, beginning with the first migration whose version is >= the workspace version. The To property will be ignored.", false)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, if this is targeted towards Dynamo 2.0 release should we just get rid of this? Or you prefer the tag for documentation purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's open for discussion. I can just rip it out, and take out all references to to: as well. I started to do that yesterday and thought better of it. But we are making a major version change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to do this in the Revit branches as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be only one NodeMigration applied in the Revit repos: https://github.com/DynamoDS/DynamoRevit/search?utf8=✓&q=NodeMigration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how these are used (it's been a while) but I just want to be sure that this change doesn't break them:

https://github.com/DynamoDS/DynamoRevit/blob/7270187e8688fbd8ec538b4617810dccdb9a695f/src/Libraries/RevitNodes/RevitNodes.Migrations.xml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not believe that Zero Touch migrations are affected, because they don't use the NodeMigrationAttribute.

@mjkkirschner
Copy link
Member

mjkkirschner commented Feb 9, 2017

@ikeough this looks good to me - is there anything else besides updating the API doc that needs to be done?

@ikeough ikeough merged commit 5360dd2 into DynamoDS:master Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants