Skip to content

Commit

Permalink
progress on consuming results, but now we overflow ?
Browse files Browse the repository at this point in the history
  • Loading branch information
cdriesler committed Jul 20, 2023
1 parent 5d8f4cf commit b23b2aa
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
35 changes: 28 additions & 7 deletions apps/nodepen-client/components/NodesAppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const NodesAppContainer = ({ document: initialDocument, templates }: NodesAppCon
stream(id: $streamId) {
object(id: $objectId) {
data
children(query: $nodeSolutionDataTypeQuery, select: ["NodeRuntimeData"]) {
children(query: $nodeSolutionDataTypeQuery, select: ["NodeInstanceId", "NodeRuntimeData"]) {
totalCount
objects {
data
Expand Down Expand Up @@ -99,20 +99,41 @@ const NodesAppContainer = ({ document: initialDocument, templates }: NodesAppCon

const { data: streamSolutionData, children: nodeSolutionData } = data.stream.object

const documentSolutionData = streamSolutionData['SolutionData']

console.log(documentSolutionData)
const documentSolutionData: NodePen.DocumentSolutionData = {
solutionId: streamSolutionData['SolutionData']['SolutionId'],
documentRuntimeData: {
durationMs: streamSolutionData['SolutionData']['DocumentRuntimeData']['DurationMs'],
},
nodeSolutionData: [],
}

for (const node of nodeSolutionData.objects) {
const { data: currentNodeSolutionData } = node

documentSolutionData.nodeSolutionData.push({
nodeInstanceId: currentNodeSolutionData['NodeInstanceId'],
nodeRuntimeData: {
durationMs: currentNodeSolutionData['NodeRuntimeData']['DurationMs'],
messages: currentNodeSolutionData['NodeRuntimeData']['Messages'].map((message: any) => ({
level: message['Level'],
message: message['Message'],
})),
},
portSolutionData: [],
})
}

return data
return documentSolutionData
}

requestSolution()
.then((rootObjectId) => {
setStreamRootObjectId(rootObjectId)
return fetchSolutionRuntimeData(rootObjectId)
})
.then((solutionData) => {
// Do nothing
.then((documentSolutionData) => {
console.log(documentSolutionData)
// TODO: Drop it into state
})
}, [])

Expand Down
8 changes: 1 addition & 7 deletions apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,12 @@ public Response SolveGrasshopperDocument(NancyContext context)
definition.Profiler = GH_ProfilerMode.Processor;

// Solve Grasshopper document
Stopwatch documentSolutionTimer = new Stopwatch();

documentSolutionTimer.Start();

definition.NewSolution(true, GH_SolutionMode.Silent);

documentSolutionTimer.Stop();

// Collect document solution data
var documentSolutionData = new NodePenDocumentSolutionData(requestData.SolutionId);

documentSolutionData.DocumentRuntimeData.DurationMs = documentSolutionTimer.ElapsedMilliseconds;
documentSolutionData.DocumentRuntimeData.DurationMs = definition.SolutionSpan.Milliseconds;

// Collect node solution data
foreach (IGH_DocumentObject documentObject in definition.Objects)
Expand Down
1 change: 1 addition & 0 deletions apps/rhino-compute-server/Rhino.Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageReference Include="Nancy.Owin" Version="1.4.1" />
<!-- <PackageReference Include="Speckle.Objects.Converter.Grasshopper7" Version="2.14.2" /> -->
<!-- <PackageReference Include="NewtonSoft.Json" Version="13.0.1" /> -->
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<PackageReference Include="Topshelf" Version="4.1.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion packages/converters/Nodepen.Converters.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<!-- <PackageReference Include="Rhino.Inside" Version="7.0.0" /> -->
<PackageReference Include="Speckle.Objects" Version="2.14.2" />
<PackageReference Include="Speckle.Objects.Converter.Grasshopper7" Version="2.14.2" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion packages/converters/kits/NodePenDocumentSolutionDataKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public NodePenDataTreeValue ConvertToSpeckle<T>(GH_Goo<T> goo)
{
Type = goo.TypeName.ToLower(),
Description = goo.ToString(),
Value = nativeGeometry.ToString(),
// Value = nativeGeometry.ToString(),
Value = "",
Geometry = speckleGeometry,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/converters/models/NodePenDocumentSolutionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class NodePenDocumentRuntimeData : Base
/// The number of milliseconds the document took to execute during a given solution.
/// </summary>
[JsonProperty("durationMs")]
public long DurationMs { get; set; } = 0;
public int DurationMs { get; set; } = 0;

public NodePenDocumentRuntimeData()
{
Expand Down

0 comments on commit b23b2aa

Please sign in to comment.