#When this is loaded via python sdk it
1 messages · Page 1 of 1 (latest)
Hi @whole island , could you tell me which version of the permify-python SDK you’re using?
Hi @wary knoll permify 1.4.4
Hi @whole island, can you also share the desired behavior? I would like to reproduce on my end.
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
thank you, will check this today.
authz_data = {}
body = DataWriteBody(**authz_data)```
It will throw an error
The problem is in the Any model - https://github.com/Permify/permify-python/blob/main/permify/models/any.py#L30
it do not have data field defined
same is mentioned here - https://github.com/Permify/permify-python/issues/13
@ornate canopy Did you get a chance to check this
yes, i am working on this. or if possible i will share you the workaround
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
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
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')
@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