#When this is loaded via python sdk it

1 messages · Page 1 of 1 (latest)

wary knoll
#

Hi @whole island , could you tell me which version of the permify-python SDK you’re using?

whole island
#

Hi @wary knoll permify 1.4.4

ornate canopy
#

Hi @whole island, can you also share the desired behavior? I would like to reproduce on my end.

whole island
#

Hi @ornate canopy Here is a sample JSON which is accepted by the data write api { "metadata": { "schema_version": "" }, "tuples": [], "attributes": [ { "entity": { "type": "report", "id": "1" }, "attribute": "admin_group", "value": { "@type": "type.googleapis.com/base.v1.StringValue", "data": "admin123" } }, { "entity": { "type": "report", "id": "1" }, "attribute": "editor_group", "value": { "@type": "type.googleapis.com/base.v1.StringValue", "data": "editor123" } }, { "entity": { "type": "report", "id": "1" }, "attribute": "viewer_group", "value": { "@type": "type.googleapis.com/base.v1.StringValue", "data": "viewer123" } } ] }

#

if we try to write this via Python SDK, it would look like this

ornate canopy
#

thank you, will check this today.

whole island
#

authz_data = {}

body = DataWriteBody(**authz_data)```
#

It will throw an error

#

it do not have data field defined

whole island
#

@ornate canopy Did you get a chance to check this

ornate canopy
#

yes, i am working on this. or if possible i will share you the workaround

ornate canopy
#

hi @whole island, can you check the issue page. i have shared a code block hopefully will help you. for future references, i would like it to be on issue page. thanks

whole island
#

Hi @ornate canopy It doesnt throw any exception, but attributes doesnt get saved. The same can be verified by reading the attributes. I have updated the same in the GH issue

ornate canopy
#

hi @whole island, can you try this:

    attributes = [
        permify.Attribute.from_dict({
            "entity": {"type": "report", "id": "1"},
            "attribute": "admin_group",
            "value": {"@type": "type.googleapis.com/base.v1.StringValue", "data": "admin123"}
            }
        ), 
        permify.Attribute.from_dict({
            "entity": {"type": "report", "id": "1"},
            "attribute": "editor_group",
            "value": {"@type": "type.googleapis.com/base.v1.StringValue", "data": "editor123"}
            }
        ), 
        permify.Attribute.from_dict({
            "entity": {"type": "report", "id": "1"},
            "attribute": "viewer_group",
            "value": {"@type": "type.googleapis.com/base.v1.StringValue", "data": "viewer123"}
            }
        )
    ]
    
    data_body = permify.DataWriteBody(
        metadata=write_metadata,
        tuples=[],
        attributes=attributes
    )
    try:
        response = data_api.data_write(tenant_id="t1", body=data_body)
        print(f"Data insert response: {response}")
    except Exception as data_exc:
        print(f"Exception while inserting data: {data_exc}")
    ```
#

this causes a pydantic warning but works

#

i will check the warning

#

if you wanna avoid the warning just add this in the ffile

import warnings
warnings.filterwarnings('ignore', category=UserWarning, module='pydantic')
whole island
#

@ornate canopy That is loading data. I could use this as a work around for now, but I hope you will be fixing the actual underlying issue