Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPL operator invocation: Issue with setting output assignment for reserved names/properties #2414

Closed
markheger opened this issue Apr 17, 2020 · 1 comment · Fixed by #2418

Comments

@markheger
Copy link
Member

Following code raises TypeError: Object of type 'Expression' is not JSON serializable

        topo = Topology()
        b = op.Source(topo, "spl.utility::Beacon",
            'tuple<uint64 seq, rstring category>',
            params = {'iterations':2})
        b.seq = b.output('IterationCount()')
        b.category = b.output('"category"') # b.category causes TypeError: Object of type 'Expression' is not JSON serializable

Applying an output assignment for an attribute named "category" is not possible.

category is a reserved word, since a property with this name exists
https://streamsxtopology.readthedocs.io/en/stable/streamsx.spl.op.html#streamsx.spl.op.Source.category

@ghost
Copy link

ghost commented Apr 22, 2020

The solution from the user's perspective would be to allow assignments to attributes like category, params, ... etc. and to assign a category for grouping of processing logic.

Example:

topo = Topology()
b = op.Source(topo, "spl.utility::Beacon",
    'tuple<uint64 seq, rstring category, boolean params>',
    params = {'iterations':2})
# output assignments
b.seq = b.output('IterationCount()')
b.category = b.output('"category"')
b.params = b.output('true')
# category for grouping processing logic:
b.category = 'sources_category'   # can also happen before output assignment to category
# update operator parameters
b.params['period'] = 0.01
print(b.params) # {'iterations': 2, 'period': 0.01}
print(b.category) # 'sources_category'

markheger pushed a commit to markheger/streamsx.topology that referenced this issue Apr 22, 2020
markheger pushed a commit that referenced this issue Apr 22, 2020
test classes for distributed tests added, #2414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant