Skip to content

FEAT: New cli commands#7549

Open
eblanco-ansys wants to merge 21 commits intomainfrom
feat/enhanced-cli
Open

FEAT: New cli commands#7549
eblanco-ansys wants to merge 21 commits intomainfrom
feat/enhanced-cli

Conversation

@eblanco-ansys
Copy link
Copy Markdown
Contributor

@eblanco-ansys eblanco-ansys commented Apr 15, 2026

Description

This pull request introduces significant enhancements and refactoring to the CLI infrastructure for PyAEDT, with a focus on expanding available commands, improving modularity, and providing better support for test configuration management. The changes include new CLI commands, a more structured approach to sub-app registration, and the addition of agent-friendly JSON output. Several utility functions in common.py have been refactored for clarity and reusability, and process management code has been removed from common.py to streamline responsibilities.

CLI Command and Structure Enhancements:

  • Introduced new CLI commands and sub-apps, including session, project, script, and export, and restructured the main CLI app to use a callback for JSON output and improved help output. Also, added new commands version and aedt-versions for version reporting. (src/ansys/aedt/core/cli/__init__.py)
  • Added a new entry point src/ansys/aedt/core/cli/__main__.py to enable running the CLI as a module (e.g., python -m ansys.aedt.core.cli).
  • Added a changelog entry documenting the addition of new CLI commands. (doc/changelog.d/7549.added.md)

JSON Output and Utility Improvements:

  • Implemented a global json_mode flag and a print_output function in common.py to support agent-friendly JSON output for CLI commands. (src/ansys/aedt/core/cli/common.py)
  • Added utility functions for AEDT desktop and project/design resolution, improving code reuse and clarity for CLI commands. (src/ansys/aedt/core/cli/common.py)

These changes collectively improve the CLI's modularity, maintainability, and usability, enabling future agentic integrations using PyAEDT CLI**

Checklist

  • I have tested my changes locally.
  • I have added necessary documentation or updated existing documentation.
  • I have followed the coding style guidelines of this project.
  • I have added appropriate tests (unit, integration, system).
  • I have reviewed my changes before submitting this pull request.
  • I have linked the issue or issues that are solved by the PR if any.
  • I have agreed with the Contributor License Agreement (CLA).

@eblanco-ansys eblanco-ansys requested a review from a team as a code owner April 15, 2026 07:08
@github-actions github-actions bot added the enhancement New features or code improvements label Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@SMoraisAnsys SMoraisAnsys left a comment

Choose a reason for hiding this comment

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

Can you update the PR description so that it helps reviewing the changes ?

@eblanco-ansys
Copy link
Copy Markdown
Contributor Author

Can you update the PR description so that it helps reviewing the changes ?

Ready to review

Copy link
Copy Markdown
Collaborator

@SMoraisAnsys SMoraisAnsys left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @eblanco-ansys Here are some minor comments

pip install pyaedt[all]
The script runs with an attached Desktop object available as ``desktop``.

**Run am Ironpython script**
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
**Run am Ironpython script**
**Run an Ironpython script**

Do we really want to support the run of Iron Python scripts ? Shouldn't we establish a clear line between pyaedt and IronPython ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had this conversation yesterday with @Samuelopez-ansys and it's opened to discussion. I also agree with your point

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is useful, there are still users with Ironpython scripts. But if you do not agree we can delete it

Comment thread doc/source/Getting_started/cli.rst Outdated
Comment thread doc/source/Getting_started/cli.rst Outdated
Comment thread doc/source/Getting_started/cli.rst
Comment thread src/ansys/aedt/core/cli/__init__.py
return "ansysedtsv.exe" if student_version else "ansysedt.exe"


def _discover_aedt_sessions() -> list[dict[str, object]]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you reuse the internal logic that we have to handle this ? I mean, we have some internal logic to parse command line and so on so this would help with future maintenance if it's needed.

@session_app.command("list")
def list_sessions() -> None:
"""List all running AEDT instances."""
aedt_sessions = _discover_aedt_sessions()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you tell me why some commands are in try: ... except: ... while others don't ? Should this be homogenized or is this on purpose ?

return designs


def get_active_design_name(project) -> str | None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment as before, if that's not already the case, could we have some "internal" modules where this kind of code is stored ? AFAIK this kind of call (and the following) are used in other places like the extensions, ... It would be better if we could have a single location for everything.

Comment on lines +46 to +57
CONFIG_DESCRIPTIONS = {
"desktopVersion": "AEDT version to use",
"NonGraphical": "Run AEDT without GUI",
"NewThread": "Use new thread for AEDT",
"skip_circuits": "Skip circuit tests",
"use_grpc": "Use gRPC for communication",
"close_desktop": "Close AEDT after tests",
"use_local_example_data": "Use local example data",
"local_example_folder": "Path to local examples",
"skip_modelithics": "Skip Modelithics tests",
"use_pyedb_grpc": "Use PyEDB with gRPC for database access",
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this idea was already raised but could we align the configuration keys to lower case everywhere at some point ? This might be done in another PR ofc but I wanted to highlight it as I'm reading it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this idea was already raised but could we align the configuration keys to lower case everywhere at some point ? This might be done in another PR ofc but I wanted to highlight it as I'm reading it.

I agree, we should definitely do this in another PR. I think it's the moment to lower case all of them. @Samuelopez-ansys thoughts on this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, in a new PR we can do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New features or code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants