Dataset not converting

copy/pasted from another working project, but i don't see why this isn't working:

	userDataset = system.tag.readBlocking(userDataPath)  # <--- '[]/Users/username
	system.perspective.print(userDataset)  # <--- this prints
	py_userDataset = system.dataset.toPyDataSet(userDataset)  # <--- dies here
	system.perspective.print('bloop')  # <--- this does not
	system.perspective.print(py_userDataset)  # <--- nor does this
    # ... additional code that follows, but never executes because of line 3

this is the stuff that kneecaps me right when i think i'm getting a stride going...

Where is this executing? What is the error?

it's in a called function from the project script library. it all works just fine up until that one line. then it dies. and since i have not yet had time to implement a logging system, this is the interim tracking solution. (which sux, i know, but i only have so many hours in a day.) as for what error, have no idea. it normally works in other scripts of similar scope, so i'm stumped. and userDataset populates properly, which was my biggest concern, so i can't understand why the conversion tanks since it's just processing variable data... :confused:

I told you this in another thread - you don’t need to implement your own logging system. When a script fails to execute an error should be logged in the Ignition Gateway logs.

3 Likes

Does userDataPath point to a Dataset Tag?

Even so, with this code, userDataset would be a list of QualifiedValue objects not a Dataset.

Change the first three lines to:

userDataset = system.tag.readBlocking(userDataPath)[0]
system.perspective.print(type(userDataset.value))
py_userDataset = system.dataset.toPyDataSet(userDataset.value)

See what type prints out then

2 Likes

i know that. but i don't want to dig through 1000s of lines of every :fork_and_knife: system's dump to logs. literally every client's system dumps there. plus, i have no idea what i'm looking for. :stuck_out_tongue:

but you have a point: stop being a lazy :poodle: and dig. *sigh* be right back...

1 Like

Yes, I spotted this as well, but he needs to learn how to troubleshoot for himself, and avoiding the logs like a scared child isn't going cut it.

edit: sorry, a bit harsh on my part. I was maybe a bit hangry :stuck_out_tongue:

4 Likes

You can filter the logs to only match certain projects, views, etc:
https://docs.inductiveautomation.com/display/DOC81/Diagnostics+-+Logs#DiagnosticsLogs-MappedDiagnosticContextKeys

@Kevin.Herron i beg your pardon?? you neither know me nor what i'm working with nor my time pressure. i'll thank you to refrain from responding in the future if this is the kind of 'help' you're offering. 'scared child' indeed... :roll_eyes: i even ceded the point... good Lord...

@lrose yes, it points to a valid tag. but i keep forgetting that bloody index... and i looked up QualifiedValue and now understand better. thank you. working code looks like this:

userDataset = system.tag.readBlocking(userDataPath)[0].value
#  blah blah blah.

there is so much Java spillover that i think i need to just learn some basic Java to understand this :poop:. there's nothing like this in Python and it's always throwing me for a loop.

BTW, readBlocking takes a list of strings, not a string.

Ever wrote C#? Basically Java.

Either way, if you have a list of python objects with publicly accessible variables you would call them the same way.

True, but there is a special case where it will take a single string and work.

It is essentially a way to ease compatibility from the old system.tag.read() function that did take a string

3 Likes

Wrong, it takes both. The doco I believe still says it takes only a list, and that's what you should give it, but the function was modified ages ago to accept just a string as well. Albeit, it always returns a list

Oops, I missed @lrose 's reply :sweat_smile:

1 Like