Skip to content

DYN-5965: introduce new string from nodes that accept numeric format specifiers #14369

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

Merged
merged 26 commits into from
Nov 11, 2024

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Sep 1, 2023

Purpose

DYN-5965
DYN-6557

this PR does the following:

  • adds some new overloads for the string conversion methods that the String From Object and String From Array nodes call internally.
  • modifies the built-in methods and string from nodes to accept a second optional parameter formatSpecifier the nodes pass these specifiers down in the case of integer or double to string calls.
  • adds two new nodes String From Object And Format and String From Array And Format.
  • adds DynamoPreferencesNumberFormat as a special format that uses the preferences to set the specifier - maybe a simpler name for this DYNFORMAT? I am still on the fence about this.
  • When we encounter a format exception - for example if you user tries to apply a binary format string to a floating point number (not allowed) - we catch the exception, log a warning on the node, and return the string "Format specifier was invalid." instead of the formatted string.
    • If this occurs to ANY data in an array, the entire array is not formatted.
  • adds extended help docs for these two new nodes.
  • new nodes are marked experimental.
  • Introduces a new experimental state for nodes, if this is true a node will display an experimental glyph in the UI and there will be some extra text in the description.
  • Introduces a feature flag to control if the glyph should be displayed.

support all c# numeric specifiers:
image
a new experimental glyph is added - we also display this glyph on nodes that are in the experimental category in the preferences - this is done with namespace matching.
Screenshot 2024-11-06 194145
we use the standard dotnet experimental attribute to control the experimental state - we also have a tooltip explaining what this means. Package authors can use this and it integrates into c# - if someone tries to use an experimental API it is a compile time error and they need to explicitly disable the warning to compile their c# code.
Screenshot 2024-11-06 165924
also add a bit of text to extended description of the node in the library.
Screenshot 2024-11-06 122100
extended docs for the new string format nodes are added and link to the super detailed c# docs.
Screenshot 2024-11-06 121849

TODO:

  • add tests
  • add more tests!
  • cleanup method names
  • add localized resources
  • additional controls for using standard c# string formats -
  • assess with the teams if this should make it into 3.4 or is too risky
  • Currently the default format specifier is f6 which keeps the behavior consistent with the old nodes... though I think actually G is a better default. It's what most users would expect IMO
  • file a follow-up task for using format specifiers on reference types (classes)
  • file a follow-up task for adding info or warnings if experimental methods are used in DS code or python.
  • file a follow-up task for generating experimental docs urls.
  • tsplines - remove from experimental check

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@mjkkirschner mjkkirschner changed the title Codeblockdisplay Revert preview string transformtion and allow users to use numeric format when converting string to object. Sep 1, 2023
@mjkkirschner mjkkirschner changed the title Revert preview string transformtion and allow users to use numeric format when converting string to object. WIP Revert preview string transformtion and allow users to use numeric format when converting string to object. Sep 5, 2023
@mjkkirschner mjkkirschner added this to the 2.19.0 milestone Sep 5, 2023
sm6srw

This comment was marked as outdated.

@sm6srw

This comment was marked as outdated.

@mjkkirschner

This comment was marked as outdated.

@mjkkirschner mjkkirschner added DNM Do not merge. For PRs. requires design labels Sep 6, 2023
@QilongTang QilongTang removed this from the 2.19.0 milestone Sep 6, 2023
Copy link

github-actions bot commented Oct 29, 2024

UI Smoke Tests

Test: success. 11 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests

@mjkkirschner mjkkirschner removed the DNM Do not merge. For PRs. label Oct 31, 2024
@mjkkirschner mjkkirschner changed the title WIP Revert preview string transformtion and allow users to use numeric format when converting string to object. introduce new string from nodes that accept numeric format specifiers Oct 31, 2024
@QilongTang QilongTang added this to the 3.5 milestone Nov 7, 2024
@Amoursol
Copy link
Contributor

Amoursol commented Nov 8, 2024

@mjkkirschner @Jingyi-Wen color choice of the icon is a bit faded. Also green suggests good - when experimental should be neutral. Suggest switching to Blue here which is our "Informational" color.

Also, styling of the hover tooltip is outdated @mjkkirschner

@Amoursol
Copy link
Contributor

Amoursol commented Nov 8, 2024

@mjkkirschner could we also replace the Dynamo Icon in the Library with the Experimental one?

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Nov 8, 2024

Also, styling of the hover tooltip is outdated @mjkkirschner

can you give me an example tooltip to checkout that has the correct styling?

@mjkkirschner could we also replace the Dynamo Icon in the Library with the Experimental one?

I can look into this - if it's easy will do it otherwise will file an improvement.

I can change the color as long as I can find the info state color in the resource dictionary - @Jingyi-Wen any idea what else it's used for?

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Nov 8, 2024

I can look into swapping the icon- if it's easy will do it otherwise will file an improvement.

actually, I don't think this such a great idea - we can control it from the feature flag, but I see two big downsides:

  • Existing experimental nodes that have nice icons will now not show them in the library - for example the paneling nodes. Or when tsplines was experimental we would not have seen the icons - if we imagined that we did another tsplines like integration today and marked it experimental.
  • If I am writing an experimental package or node I now don't have a way to test my icon easily - I guess locally I can swap the attribute out, but it's kind of a pain.

I will still evaluate how difficult it is to do technically, but it might benefit from ux thinking about it a bit more. @Jingyi-Wen - maybe we only swap it out if the icon is not the default... or perhaps communicating that the node is experimental is more important than the icon - I'm not sure how to make that call.

@@ -8,6 +8,7 @@ namespace ProtoCore.Utils
{
public static class StringUtils
{
//TODO consider removing this option. It makes sharing harder.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sort of looks similar to the scale factor setting issue where we have one in preferences and another setting in the workspace (graph), where the latter overrides the former. I would have suggested adding this format specifier at the graph level as well but I don't think that's needed if we're going to deprecate the old string nodes at some point.

@@ -104,8 +107,6 @@ public FormattedStringFromObject() : base("__ToStringFromObjectAndFormat")
[OutPortTypes("string")]
[IsDesignScriptCompatible]
[AlsoKnownAs("DSCoreNodesUI.StringNodes.FromObject", "DSCoreNodesUI.FromObject")]
[Obsolete("this node is obsolete, please use the version of string from _ with numeric format option")]
[NodeDeprecated]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't we deprecating this?

Copy link
Member Author

@mjkkirschner mjkkirschner Nov 11, 2024

Choose a reason for hiding this comment

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

My reasoning was as follows:

Since I am marking the new nodes experimental, I did not want to also mark the old nodes as obsolete (hiding them from the lib) - then it would not be clear to users how to proceed in a safe / future proof way.

I'd like to propose we follow this pattern when introducing new nodes (that replace existing ones) - if we are not so sure about the design.

  • phase 1:
    • Introduce new nodes as experimental.
    • Old nodes are untouched.
  • phase 2:
    • gather feedback on experimental nodes.
    • experimental nodes can be changed at any time.
  • phase 3:
    • experimental attribute is removed from new nodes.
    • old nodes are marked obsolete
  • phase 4:
    • old nodes are removed in a major release.

@Jingyi-Wen
Copy link

I can look into swapping the icon- if it's easy will do it otherwise will file an improvement.

actually, I don't think this such a great idea - we can control it from the feature flag, but I see two big downsides:

  • Existing experimental nodes that have nice icons will now not show them in the library - for example the paneling nodes. Or when tsplines was experimental we would not have seen the icons - if we imagined that we did another tsplines like integration today and marked it experimental.
  • If I am writing an experimental package or node I now don't have a way to test my icon easily - I guess locally I can swap the attribute out, but it's kind of a pain.

I will still evaluate how difficult it is to do technically, but it might benefit from ux thinking about it a bit more. @Jingyi-Wen - maybe we only swap it out if the icon is not the default... or perhaps communicating that the node is experimental is more important than the icon - I'm not sure how to make that call.

@mjkkirschner I agree with this, experimental is more of a state instead of a symbol for the node itself. I'd suggest not swapping the icon in library
The blue color we use for info state is #38ABDF. Graph node manager has the color :)
Also, I suggest changing the tooltip wording to "This node is currently in the experimental state. Its behavior, name, and signature are subject to change."

@@ -2782,6 +2782,7 @@ static Dynamo.Properties.Resources.DescriptionResource1.get -> string
static Dynamo.Properties.Resources.DirectoryNotFound.get -> string
static Dynamo.Properties.Resources.DisplayEngineFailureMessageDescription.get -> string
static Dynamo.Properties.Resources.DllLoadException.get -> string
static Dynamo.Properties.Resources.DocsExperimentalPrefixMessage.get -> string
Copy link
Contributor

@aparajit-pratap aparajit-pratap Nov 8, 2024

Choose a reason for hiding this comment

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

Are we still seeing these API analysis warnings in PRs?

Copy link
Contributor

@aparajit-pratap aparajit-pratap Nov 8, 2024

Choose a reason for hiding this comment

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

I expected to see them but lately I've not been seeing them. I wonder if something changed. @avidit ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw them in the github build checks

@@ -641,7 +643,16 @@ public bool IsFrozenExplicitly
return false;
}
}

[Experimental("NVM_ISEXPERIMENTAL_GLPYH")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the glyph need to be experimental?

Copy link
Member Author

@mjkkirschner mjkkirschner Nov 11, 2024

Choose a reason for hiding this comment

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

No, but it has to be public AFAK for wpf binding and was not sure we'd want to support it. Experimental experimental mode ;)

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

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

Minor comments and some questions. LGTM.

internal static readonly IEnumerable<string> InitialExperimentalLib_Namespaces =
[
//TODO remove tsplines - it's no longer experimental.
"ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline",
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I thought I removed the TSpline feature flag check would be enough, I guess not..

@@ -145,7 +146,12 @@ public FunctionDescriptorParams()
/// <summary>
/// Indicates if the lacing strategy is disabled on the function
/// </summary>
public bool IsLacingDisabled { get; set; }
public bool IsLacingDisabled { get; set; }
//TODO - should this somehow contain more info - ExperimentalInfo{IsExperimental, ExperimentalMessage/url}?}
Copy link
Contributor

@QilongTang QilongTang Nov 11, 2024

Choose a reason for hiding this comment

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

How would the message be surfaced in your opinion if it exists?

Copy link
Member Author

@mjkkirschner mjkkirschner Nov 11, 2024

Choose a reason for hiding this comment

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

kind of like how the underlying system.diagnostics.codeanalysis.experimental attribute surfaces them. In this case it shows the errors in the errors tab of visual studio as compile time warnings and generates a url given a base url format and the experimental diagnostic id.

we could do something similar, show info states on nodes pointing to the docs browser, though it would be much more useful if you get a link to some dynamic documentation that we update, for example in the forum or primer.

For now I will just leave it as a TODO and file a follow-up to consider it.

see:
https://learn.microsoft.com/en-us/dotnet/fundamentals/syslib-diagnostics/experimental-overview

@mjkkirschner
Copy link
Member Author

I think I have addressed all review comments, I will merge after I see a passing test result - at the moment a date time test is failing, I think @pinzart90 was trying to improve in another pr.

@mjkkirschner mjkkirschner merged commit 7ec4fc7 into DynamoDS:master Nov 11, 2024
21 of 23 checks passed
@mjkkirschner mjkkirschner deleted the codeblockdisplay branch November 11, 2024 21:57
@mjkkirschner
Copy link
Member Author

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.

8 participants