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

ConversionResult in HostObjectBuilder #3437

Closed
wants to merge 5 commits into from

Conversation

JR-Morgan
Copy link
Member

Still WIP

public ConversionResult(object target, object result, string resultId)
{
Target = target;
Result = result;
Copy link
Member

Choose a reason for hiding this comment

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

This object might know whether the conversion is successful with fallback displayValue or not. I mean, it is "successful" with "but". TBD

Copy link
Member Author

Choose a reason for hiding this comment

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

Potentially simply the result type will be enough for us to communicate this if we wish.
"Brep" was converted as "Mesh" communicates exactly the same thing as "with dispalyValues", but imo will be more intuitive to the user.

If we wanted more than this, I could see some utility in knowing what converter was used to convert the object.
But this would require some more restructuring of our "...WithFallBack" service, because right now, the converter is abstracted and the connector doesn't see it.

I think we could do something nice, where the "...WithFallBack" simply returns the converter (without calling it), instead of right now, where it both finds and immediately calls it


results.AddRange(convertedObjects.Select(e => new ConversionResult(tc, e, e.Handle.Value.ToString())));
}
catch (Exception ex) when (!ex.IsFatal())
Copy link
Member

Choose a reason for hiding this comment

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

hmm, just have general Qs:

  • Will we continue conversion if some bad error happens that might affect the state of the app?
  • Will we have a revert operation mechanism if smth bad happens?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now, I've gone for "continue conversion of the next object" for all non-fatal exceptions.
This was the behaviour of DUI2 and was (I seem to remember) agreed with Dim.

I don't think we ever saw any problems with this approach.

Although, when we do logging, we will be logging "expected" exceptions (like SpeckleException subtypes) differently from unexpected (e.g. nullreference)

We do have the flexibility here to pick and choose if we wanted to pivot to something else.
But I think this will strike a good balance for now.

We'll take a look at transactions/reverting for cancellation, probably in a separate PR.

@@ -51,7 +52,7 @@ public async Task Receive(string modelCardId)
}

// Receive host objects
IEnumerable<string> receivedObjectIds = await unitOfWork.Service
IReadOnlyList<ConversionResult> conversionResults = await unitOfWork.Service
Copy link
Member

Choose a reason for hiding this comment

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

Probably, we will have a different structure on send and receive since we also return ObjectReferences on send, so maybe it would be nice to name class explicitly as ReceiveConversionResult

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'll take a look at Receive today, if a new class makes sense, lets do it.

@@ -63,8 +64,7 @@ public async Task Receive(string modelCardId)
)
.ConfigureAwait(false);

// POC: Here we can't set receive result if ReceiveOperation throws an error.
Commands.SetModelReceiveResult(modelCardId, receivedObjectIds.ToList());
Commands.SetModelReceiveResult(modelCardId, conversionResults);
Copy link
Member

Choose a reason for hiding this comment

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

This is where I can start to think interop

.Where(obj => obj.Current is not Collection)
.Select(ctx => (GetLayerPath(ctx), ctx.Current))
.ToArray();
.TraverseWithProgress(rootObject, onOperationProgressed, cancellationToken)
Copy link
Member

Choose a reason for hiding this comment

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

Do we report progress on Traversing to UI?

Copy link
Member Author

Choose a reason for hiding this comment

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

The actually traversal step, does not get reported with progress because its super quick and only happens once.

TraverseWithProgress, since it returns a lazily enumerated IEnumerable reports the actual conversion progress (as the enumeration of objects occurs)

This was simply my hope to be DRY with the progress reporting, but I'm not tied to it if we find a better way.

{
ReceiverModelCardResult res =
new()
{
ModelCardId = modelCardId,
ReceiveResult = new ReceiveResult() { BakedObjectIds = bakedObjectIds }
ReceiveResult = new ReceiveResult()
Copy link
Member

Choose a reason for hiding this comment

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

Need some changes on UI side to send proper result


yield return tc;

onOperationProgressed?.Invoke("Converting", (double)++count / traversalGraph.Length);
Copy link
Member

Choose a reason for hiding this comment

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

Should we really report to UI progress when traversing? If so I believe it shouldn't be named with "Converting"?

Copy link
Member Author

Choose a reason for hiding this comment

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

See other comment, this isn't traversal progress (because traversal is super quick)
This is the conversion progress (as the IEnumerable is being enumerated)

Let me know if you want me to explain this better over voice call.

@@ -54,24 +52,13 @@ public object Convert(Base target)
return FallbackToDisplayValue(displayValue);
Copy link
Member

Choose a reason for hiding this comment

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

Need some thoughts on it -> How can we report fallback conversion, or should we?

Copy link
Member Author

Choose a reason for hiding this comment

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

See other comment above, Perhaps we don't need to, since we will know the original and result type and that's the main thing users will care about.

But if we wanted to go further, and know the converter that was used, I have an idea, but I think we should wait till we can get some feedback from the team.

@JR-Morgan
Copy link
Member Author

Changes will be included in #3448

@JR-Morgan JR-Morgan closed this Jun 3, 2024
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.

None yet

2 participants