Updating a Tag's custom DataSet property

I would like to store a custom DataSet property in tags, then manipulate that DataSet’s contents via scripting.
I’m running into serialization/type issues with the property.

To illustrate the problem, the following should create a new tag with a custom DataSet property.
Then the tag is retrieved again, a row added to the existing data set, then written back.
The 2nd step fails as the original DataSet is stored as a “{document}” in the Tag:

basePath = '[default]'

# Create a new tag
tags = [
	{
		"name": "Test",
		"sample table": system.dataset.toDataSet(['name', 'value'], [['adam', 123]])
	}
]
system.tag.configure(basePath, tags, "o")
# OUTPUT: [Good]

# Add to the tag's sample table
tags = system.tag.getConfiguration('[default]Test', False)
tags[0]['sample table'] = system.dataset.addRow(tags[0]['sample table'], ["adam", 1])
system.tag.configure(basePath, tags, "o")
# OUTPUT: 
# Traceback (most recent call last):
#  File "<input>", line 17, in <module>
# TypeError: addRow(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.Dataset

I’ve also tried converting the “system.dataset.toDataSet” result to a PyDataSet, but then it’s stored as an “{Array}” in the Tag.

The same kind of problem occurs if I pre-create the tag and its custom DataSet property.
In that case, when I read the tag, the property type is a proper DataSet that I can add to.
But when I write it back to the tag via configure then it’s converted to a “{document}”, causing subsequent updates to fail.

Thoughts?

I’m guessing custom properties cannot be datasets. Or need to be written outside of system.tag.configure. (That isn’t intended to be heavily used at runtime–use system.tag.write*.)

A DataSet is supported:
image

That isn’t intended to be heavily used at runtime

That's fair, but this will only be used to store configuration updates made by a user, so once a day maybe? More often than not, it will go unused for weeks/months.

use system.tag.write* .

But I've seen system.tag.write mentioned elsewhere, but doesn't that only apply to the tag's value? I'm trying to add extra configuration information to a tag.

No, most (all?) properties are readable & writeable using normal methods. The tagpath ends with a dot and the property's proper name.

I wouldn't use spaces in property names.

Ah sweet, didn’t realize a property name could be specified, thanks!

This does the trick:

# Get the current configuration
ds = system.tag.readBlocking(['[default]Test.sample_table'])[0].value

# Add new value
username = 'adam'
val = 5
ds = system.dataset.addRow(ds, [username, val])
	
# Write the new configuration back
system.tag.writeBlocking('[default]Test.sample_table', ds)