ansys / ansys/pymodelcenter

Potential bug in 'move_component' method with Trade Study components

Open
#268 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6
Forks
1
Avg merge
30m
Merged PRs (30d)
2

Description

### 🔍 Before submitting the issue

- [x] I have searched among the existing issues
- [x] I am using a Python virtual environment

### 🐞 Description of the bug

I'm trying to create an example trade study script that adds and configures the Opt Tool into the 'BasicExample.pxcz' (process workflow that has single Quadratic component) in the repo's examples directory (https://github.com/ansys/pymodelcenter/blob/main/examples/BasicExample.pxcz).

After the Opt Tool is programmatically added, the existing Quadratic component needs to be moved inside of it before Opt Tool configuration. Attempting to use the 'move_component' method to do this gives the error that the Opt Tool component "is not an assembly"

Conversely, the 'create_component' method doesn't have any issue with the Opt Tool component not being an assembly. In the 'test_create_and_run_optimizer_very_basic' function of the 'test_workflow.py' unit test script (https://github.com/ansys/pymodelcenter/blob/main/integration/test_workflow.py), it programmatically creates the workflow, Opt Tool component, and Quadratic component from scratch. It uses the 'create_component' method for the Quadratic component creation and specifies the Opt Tool component as the parent. This works without issue, in that the Quadratic component is successfully created under the Opt Tool component.

### 📝 Steps to reproduce

Attached are two scripts to demonstrate the failure with 'move_component' (TradeStudy_Optimization_moveComponent.py) and the success with 'create_component' (TradeStudy_Optimization_createComponent.py).

For both:
1. Copy scripts and BasicExample.pxcz to a folder on a machine with PyMC configured
2. Open command line in folder or 'cd' to folder
3. Run moveComponent script using "python TradeStudy_Optimization_moveComponent.py". Will recieve assembly error, 'BasicExample.pxcz'

[TradeStudy_Optimization_createComponent.py](https://github.com/user-attachments/files/24625279/TradeStudy_Optimization_createComponent.py)
[TradeStudy_Optimization_moveComponent.py](https://github.com/user-attachments/files/24625280/TradeStudy_Optimization_moveComponent.py)

workflow should be unchanged due to error.
4. Run createComponent script using "python TradeStudy_Optimization_createComponent.py". When prompted, specify 'y' to save workflow, and hit 'Enter' button to close
5. Open 'BasicExample.pxcz', will see 'Optimization' component with nested 'Target' component

### 💻 Which operating system are you using?

Windows

### 📀 Which ANSYS version are you using?

25R2

### 🐍 Which Python version are you using?

3.13

### 📦 Installed packages

```shell
ansys-api-modelcenter==0.3.4
ansys-api-platform-instancemanagement==1.1.3
ansys-engineeringworkflow-api==0.1.2
ansys-modelcenter-workflow==0.1.3
ansys-platform-instancemanagement==1.1.2
ansys-tools-common==0.4.0
anyio==4.12.1
appdirs==1.4.4
certifi==2026.1.4
charset-normalizer==3.4.4
click==8.3.1
colorama==0.4.6
grpcio==1.76.0
idna==3.11
importlib_metadata==8.7.1
numpy==2.4.1
overrides==7.7.0
platformdirs==4.5.1
protobuf==6.33.4
pyansys-tools-variableinterop==0.1.2
requests==2.32.5
scooby==0.11.0
typing_extensions==4.15.0
urllib3==2.6.3
zipp==3.23.0
```

Contributor guide

Open the contributing guide

Research direction

Run TradeStudy_Optimization_moveComponent.py with examples/BasicExample.pxcz to reproduce the assembly error, then compare its move_component usage with the working create_component case in integration/test_workflow.py. Trace the move_component and create_component entry points and verify that the existing Quadratic component can be nested under the Opt Tool without the error while preserving the workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.