Hops in hops | Rhino 8 | REST API

Hi there,
I have integrated hops (the main script with hops elements, as well as nested hops) into the gh model. I also have a kind of remote server with Rhino.Compute. The calculation on a remote server from a locally running Grasshopper is positive.


Rhino.Compute logs:

CG  [08:27:23 DBG] Using cached definition
[08:27:23 INF] HTTP POST /io responded 200 in 75.8728 ms
[08:27:23 INF] Max concurrent requests = 1
CG  [08:27:24 DBG] Using cached definition
[08:27:24 INF] HTTP POST /io responded 200 in 5.1727 ms
CG  [08:27:24 DBG] Using cached definition
[08:27:24 INF] HTTP POST /io responded 200 in 3.9008 ms
[08:27:26 INF] HTTP POST /io responded 200 in 464.3671 ms
[08:27:27 INF] HTTP POST /io responded 200 in 397.8919 ms
CG  [08:27:28 DBG] Using cached definition
[08:27:28 INF] HTTP POST /io responded 200 in 3.3694 ms
[08:27:30 INF] HTTP POST /io responded 200 in 527.9378 ms
[08:27:31 INF] HTTP POST /io responded 200 in 771.8101 ms
[08:27:32 INF] HTTP POST /io responded 200 in 604.9685 ms
[08:27:33 INF] HTTP POST /io responded 200 in 740.9338 ms
[08:27:34 INF] HTTP POST /io responded 200 in 750.5256 ms
[08:27:35 INF] HTTP POST /io responded 200 in 735.1951 ms
[08:27:36 INF] HTTP POST /io responded 200 in 394.8211 ms
CG  [08:27:37 DBG] Using cached definition
[08:27:37 INF] HTTP POST /io responded 200 in 4.2134 ms
[08:27:38 INF] HTTP GET / responded 200 in 1.9452 ms
[08:27:38 INF] HTTP POST /io responded 200 in 761.9471 ms
CG  [08:27:39 DBG] Using cached definition
CG  [08:27:39 DBG] Skipping input tree... same input
...............................
[08:27:39 INF] HTTP POST /grasshopper responded 200 in 6.5939 ms
[08:27:39 INF] HTTP POST /grasshopper responded 200 in 1.9483 ms
[08:27:39 INF] HTTP POST /grasshopper responded 200 in 2.7543 ms
CG  [08:27:39 DBG] Using cached definition
[08:27:40 INF] HTTP POST /grasshopper responded 200 in 432.5039 ms
CG  [08:27:41 DBG] Using cached definition
[08:27:41 INF] HTTP POST /grasshopper responded 200 in 864.5040 ms
CG  [08:27:42 DBG] Using cached definition
[08:27:42 INF] HTTP POST /grasshopper responded 200 in 554.4727 ms
CG  [08:27:43 DBG] Using cached definition
CG  [08:27:43 DBG] Skipping input tree... same input
.................................................
[08:27:43 INF] HTTP POST /grasshopper responded 200 in 202.4363 ms
CG  [08:27:44 DBG] Using cached definition
[08:27:44 INF] HTTP POST /grasshopper responded 200 in 489.9061 ms
CG  [08:27:45 DBG] Using cached definition
CG  [08:27:45 DBG] Skipping input tree... same input
...............................................
[08:27:45 INF] HTTP POST /grasshopper responded 200 in 221.8771 ms

But when I try to call the calculation of the main gh model from the code, an empty geometry comes up. And part of the log on Rhino.Compute looks like this:

CG  [08:29:11 DBG] Floating parameter  failed to collect data: component "Relay" (9107f948-0ea1-4387-9cb8-1228ae16d719)
CG  [08:29:11 DBG] Floating parameter  failed to collect data: component "Panel" (c21c07d1-fabe-4407-8d4b-4b41fdc4023c)
CG  [08:29:11 DBG] Input parameter DoorFrame failed to collect data: component "Context Bake" (f5f4a5f8-1a57-47ef-a9fb-e1911d70be6f)
CG  [08:29:11 DBG] Input parameter Window failed to collect data: component "Context Bake" (fca3c9b0-e3c2-4cf2-9acb-f0cbeb196759)
CG  [08:29:11 DBG] Input parameter M failed to collect data: component "Mesh Colours" (3a4382ff-7dc3-403f-b7c4-a8634fba98eb)
CG  [08:29:11 DBG] Input parameter Storve failed to collect data: component "Context Bake" (13d13346-90ce-45cc-b9b9-5146e63ff062)
[08:29:11 INF] HTTP POST /grasshopper responded 200 in 13821.2390 ms

Code for calling calculations. I tried both through pointer and through file decoding::

    async with aiohttp.ClientSession() as session:
        async with session.post(url=post_url, data=json.dumps({
            "algo": str(encoded, 'utf-8'),
            # "algo": None,
            "pointer": None,
            # "pointer": "https://my-server/api/v2606/hops_main",
            "dataversion": 8,
            "values": construct_values(compute_data),
            # "values": [],
        }), headers=headers) as response:

Response:

"modelunits":"Millimeters",
"dataversion":7,
"algo":"",
"pointer":"md5_7A21008E20C4DB9170D113A09A680501",
"cachesolve":false,
"values":[{
  "ParamName":"Room",
  "InnerTree":{
    "{0}":[]
  }
},
{
  "ParamName":"Floor",
    "InnerTree":{}
  },
{"ParamName":"StorveProtect","InnerTree":{}}

it’s as if nested hops are not involved in the calculations.

In general, is such an algorithm for working with hops, nested hops possible?

Pointer receives the file from the server endpoint. I thought that the problem was in the absolute paths to the hops files, but the change did not affect the performance.

@app.get("/api/v2606/hops_frame")
async def hops_def():
    workdir = os.getcwd() + '/'
    return FileResponse(path=workdir + "v2606/Hops 1 FrameBase.gh")

But I’ll notice again. If you run Rhino.Compute locally, the result of the calculations is positive.

Hi. Testing to use hops remotely on simple gh model. But, as it turned out, it doesn’t even work locally.
main.gh:


hops inside main:

When I use absolute path to folder, all working (we see /io and twice /grasshopper endpoints):
image

But when i use url, have empty tree_parameters in response and in compute logs we see:

Interestingly, in grasshopper itself, hops understand urls.

Any ideas?

@stevebaer is this something you can help with?

Hi Yuri. My apologies on the delay. Would you have a simple example file which shows the errors you’re seeing. It’s a little bit complicated to follow in the post exactly what’s happening. If you can’t share it publicly, you can upload the file directly to me following this link

Sorry for the noise and the long response.

I couldn’t find a solution to the problem for a long time. As a result, the problem was the custom configuration of the server. In hops/Servers.cs, the URL was not correctly determined in the GetComputeServerBaseUrl method. I had to set it manually. After that, everything worked.

Interestingly, there was this error on the test server. Everything turned out fine on the production server. Apparently the configuration is completely broken)

Thank you all very much for your attention, as well as intellectual and moral support)