Sending data from Python to Dynamo

I’m trying to pass a simple integer from dynamo and pull that number into Python. However, when I read the objects passed through, I only get data in the form of:

id=‘5ee0e11ec712900cf8585909’ private=None canRead=None canWrite=None owner=None anonymousComments=None comments=None createdAt=None updatedAt=None type=‘Placeholder’ name=None geometryHash=None hash=None applicationId=None properties=None partOf=None parent=None children=None ancestors=None

I’m quite new to speckle and python in general so I’m struggling to understand the GitHub material in terms of the correct way to extrapolate the integer data that is being passed by dynamo.

Hey @dtnaughton,

Can you show some of your code? Otherwise it’s a bit difficult to help!

In order to send data via Spckle you need to use the Base object and then serialize it, here’s a sample from the speckle-py repo:

base_obj = Base()
base_obj.name = "my base"
base_obj["@nested"] = detached_base

serializer = BaseObjectSerializer()
hash, obj_dict = serializer.traverse_base(base_obj)

Hi @teocomi

Here’s the code, it’s from the PySpeckle intro. The data in my stream is essentially a singular number. I want to understand the premise before I complicate my data further. I have the correct login and stream info in my code.

# Create a client using the appropriate server
client = SpeckleApiClient('hestia.speckle.works')

# Login with your details
client.login(
    email='XXXXX',
    password='XXXXX'
)

# Stream ID to get
stream_id = 'XXXXX'

# Get stream data using its ID
stream = client.streams.get(stream_id)

# Print out some object info
for object in stream.objects:
  print(object)

Thanks!

I’m afraid that’s code for Speckle v1! We’re not actively supporting v1 connectors, but I’ll ping the author in case he’s around and has time to help :slight_smile: @TomSvilans

If you’re curious about v2, here’s the repo (in alpha stage currently).

I see! I’ve been reading through v2 documentation but unfortunately a lot of it is going over my head with my limited knowledge haha!

Hopefully @TomSvilans is able to offer some advice. Thanks @teocomi!

1 Like

Hi @dtnaughton and @teocomi, apologies for the delay in replying.

In Speckle 1.0, the objects you receive back from a stream are all Placeholder objects. You then need to get the actual object data using the id of Placeholder objects you retrieve from the streams.

This is done with something like:
obj = client.objects.get(<id_from_placeholder>)

Hope that helps!

1 Like

Hi @TomSvilans, thanks for the response!

I copied the code and inputted the ID number to no avail.

Code:

# Get stream data using its ID
stream = client.streams.get(stream_id)

# Print out some object info


obj = client.objects.get('5eda6faca9cfd20ce6d8ecfa')

print(obj)

Output:

/Desktop/Python') id='5eda6faca9cfd20ce6d8ecfa' private=False canRead=[] canWrite=[] owner='5ed9fe62a9cfd20ce6d89e0d' anonymousComments=False comments=[] createdAt='2020-06-05T16:15:40.477Z' updatedAt='2020-06-05T16:15:40.477Z' type='Number' name=None geometryHash=None hash='84a9886a5cfa6f460740a0e3913096b2' applicationId=None properties=None partOf=None parent=None children=[] ancestors=[] __v=0 deleted=False value=0

The output should be the number ‘2’. Any thoughts on what I’m doing wrong?

Well the object is coming through properly (type='Number') but its value is not 2 (value=0).

The value of the number is 0 on the server as well. Check the inputs to make sure the value is set properly.

Use obj.value to get the value of the Speckle object.

1 Like