Skip to content

Conversation

@MFA-X-AI
Copy link
Member

@MFA-X-AI MFA-X-AI commented Oct 6, 2025

Description

This PR fixes a TypeError: 'InArg' object is not subscriptable error that occurred when using dynamic ports (dynalist/dynatuple) with indexed connections to Argument parameters in Xircuits workflows.

Previously, when the compiler generated code for dynamic ports connected to Argument parameters at specific indices, it would fail because InArg objects didn't support subscript operations. When users tried to connect Argument parameters to specific indices of dynamic ports (e.g., dlist[1].connect(self.test2)), the generated code would throw a TypeError: 'InArg' object is not subscriptable.

This PR implements two changes:

  1. Added subscript support to InArg class (base.py): Implemented getitem and setitem methods with an _IndexProxy helper class to enable indexed access and connection syntax like port[i].connect(other_port).

  2. Updated code generation for dynamic ports (generator.py): Changed from bulk assignment to per-element indexed operations that generate proper code for Argument parameters (.connect()), component references (.connect()), and literal values (direct assignment).

So previously given a workflow like this:

image

The incorrect generated code would look like:

        self.c_0.dlist[1].connect(self.test)
        self.c_0.dlist.value = ['hello ', 'there']

Error Code:

File ~/Github/xircuits/untitled.py:15, in untitled.__init__(self, id)
     13 self.c_0 = DynaPorts()
     14 self.c_0.__id__ = '7696ed2a-6079-4714-a484-4570d9c2dbac'
---> 15 self.c_0.dlist[1].connect(self.test)
     16 self.c_0.dlist.value = ['hello ', 'there']
     17 self.c_0.next = None

TypeError: 'InArg' object is not subscriptable

With the new this PR:

        self.c_0.dlist[1].connect(self.test)
        self.c_0.dlist[0] = 'hello '
        self.c_0.dlist[2] = 'there'

Output:

Xircuits is running...


Executing: untitled

Executing: DynaPorts
Printing dynalist value:
['hello ', 'inner', 'there']
Printing dynatuple value:
()

Finished Executing

References

Fixes the TypeError when Argument parameters are connected to indexed positions in dynamic ports (dynalist/dynatuple).

Pull Request Type

  • Xircuits Core (Jupyterlab Related changes)
  • Xircuits Canvas (Custom RD Related changes)
  • Xircuits Component Library
  • Xircuits Project Template
  • Testing Automation
  • Documentation
  • Others (Please Specify)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Tests

1. Dynamic Port with Argument Parameter Test

1. Create a Xircuits workflow with a component that has dynalist ports
2. Add two literals and one argument. Connect the argument so it is in the middle of the literals (like in the example above)
3. Compile and run the workflow
4. Verify that no TypeError occurs during execution
5. Verify the Argument values are properly passed at runtime and is in the correct position

Tested on? Specify Version.

  • Windows
  • Linux
  • Mac
  • Others (State here -> xxx )

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Binder 👈 Launch a binder notebook on branch XpressAI/xircuits/fahreza/fix-dyna-args

@MFA-X-AI MFA-X-AI requested a review from treo October 6, 2025 03:27
Copy link
Contributor

@treo treo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok at first glance, but I'm wondering if the recurring problems with dynalists may hint at a design problem. We should keep that in mind as we approach further development.

@MFA-X-AI MFA-X-AI merged commit f34af06 into master Oct 7, 2025
16 checks passed
@MFA-X-AI MFA-X-AI deleted the fahreza/fix-dyna-args branch October 7, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants