Unable to receive with `specklepy`. ValueError: not enough values to unpack (expected 2, got 1)

Hi :smiling_hearts_spockle: !

Objective

Receive alluvium, siltstone, basement, alignment and excavation

from Weka Hills Leapfrog Demo Model (public) using specklepy.

Issue

My code

from specklepy.api.client import SpeckleClient
from specklepy.core.api import operations
from specklepy.transports.server import ServerTransport

weka_hills_speckle_project_id = "7a489ac0d4"

speckle_client = SpeckleClient(host="app.speckle.systems")
transport = ServerTransport(
    stream_id=weka_hills_speckle_project_id, client=speckle_client
)

weka_hills_speckle_models = speckle_client.model.get_models(
    project_id=weka_hills_speckle_project_id
)

speckle_models_w_versions = {}
for model in weka_hills_speckle_models.items:
    speckle_model = speckle_client.model.get_with_versions(
        model_id=model.id,
        project_id=weka_hills_speckle_project_id,
    )
    if "geo/geology-model" in model.name:
        geological_unit = str(model.name).replace("geo/geology-model/", "")
        speckle_models_w_versions[geological_unit] = speckle_model
        print(f"{geological_unit}: {model.id}")
    elif "tunnel" in model.name:
        tunnel_model = str(model.name).replace("tunnel/", "")
        speckle_models_w_versions[tunnel_model] = speckle_model
        print(f"{tunnel_model}: {model.id}")

model_data = operations.receive(
    # speckle_models_w_versions["alluvium"].versions.items[0].referencedObject,
    # speckle_models_w_versions["alignment"].versions.items[0].referencedObject,
    speckle_models_w_versions["excavation"].versions.items[0].referencedObject,
    transport,
)

returns the error

Traceback (most recent call last):
  File "%HOMEPATH%\ReposWindows\IFC5-development\Geotech\receive_from_speckle.py", line 31, in <module>
    model_data = operations.receive(
                 ^^^^^^^^^^^^^^^^^^^
  File "%HOMEPATH%\ReposWindows\IFC5-development\.venv\Lib\site-packages\specklepy\core\api\operations.py", line 86, in receive
    obj_string = remote_transport.copy_object_and_children(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "%HOMEPATH%\ReposWindows\IFC5-development\.venv\Lib\site-packages\specklepy\transports\server\server.py", line 172, in copy_object_and_children
    hash, obj = line.split("\t")
    ^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

At first I only got this error when trying to receive the "excavation".

My issue sounded very similar to the issues described in

so I deleted the cache through the Speckle Manager and removed the Objects.db in %APPDATA%\Speckle, but now I’m getting that ValueError: not enough values to unpack with everything I’m trying to receive.

Thanks a bunch in advance for the help :starstruck_spockle:

Hi @JoostGevaert ! Are you running a standalone script or through some kind of web app? Last time I saw this, it was caused by receiving speckle data in a wrong format due to wrong http headers passed with the request

I’m running “my code” as a stand-alone script.

I’m using uv to manage Python (would really recommend uv :cool_spockle:). The virtual env I’m using to run the script can be recreated using these files:
pyproject.toml (271 Bytes)
uv.lock (321.3 KB)
.python-version (6 Bytes)

Alternatively, when using uv, you can add

# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "specklepy"
# ]
# ///

to the top of the script and then run it by using

uv run receive_from_speckle.py

Here’s the script in a GitHub repo btw:

Hi!

I’m still having this error. What can I do about it?

Hey @JoostGevaert, sorry for being late on this we’re actively looking at the issue.

Will get back to you.

1 Like

Hey @JoostGevaert

we’ve identified the issue, it was a problem with “unauthenticated” receives, that is why our initial repo steps failed in specklepy and blender.

We’ve pushed a new release of specklepy 2.21.3 upgrading to that should make the problem go away.

Thanks for bearing with us :slight_smile:

2 Likes

Hi @gergo,

Thanks for helping out! :smiling_hearts_spockle:

It works like a charm again :starstruck_spockle:

Thanks!

2 Likes