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

support serializing dynamic python engines #13841

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Libraries/PythonNodeModels/PythonNode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand Down Expand Up @@ -54,6 +54,11 @@ public PythonEngineVersion Engine
if (!Enum.TryParse(engine, out PythonEngineVersion engineVersion) ||
engineVersion == PythonEngineVersion.Unspecified)
{
//if this is a valid dynamically loaded engine, return unknown, and serialize the name.
if (PythonEngineManager.Instance.AvailableEngines.Any(x=>x.Name == engine))
{
return PythonEngineVersion.Unknown;
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't PythonEngineVersion.Unspecified good enough to be returned ?

Copy link
Member Author

@mjkkirschner mjkkirschner Mar 22, 2023

Choose a reason for hiding this comment

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

@pinzart90 - two reasons IMO:

  1. If the version is unspecified it makes sense to me that the default version should kick in.
  2. Logically Unspecified is not the same as Unknown. In this case the version is definitely specified, it's just not a valid value in the enum.

Copy link
Contributor

Choose a reason for hiding this comment

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

So all this is to enhance the user experience for an obsoleted API? Is it still used by our integrators ?

Copy link
Member Author

Choose a reason for hiding this comment

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

hah, not quite, I don't know who uses it, and I don't know when it will disappear, and IMO it is about enhancing correctness not user experience - not collapsing two different states into one.

Let us remove this enum and never mention it again, but until then, I don't want to break python node initialization and I also want dynamic engines to serialize correctly.

}
// This is a first-time case for newly created nodes only
SetEngineByDefault();
}
Expand Down Expand Up @@ -431,4 +436,4 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(
};
}
}
}
}
5 changes: 3 additions & 2 deletions src/NodeServices/PythonServices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -19,7 +19,8 @@ public enum PythonEngineVersion
{
Unspecified,
IronPython2,
CPython3
CPython3,
Unknown
}
}

Expand Down