FIX: Connect to existing student version - #7918
Conversation
2a85972
Pull request was converted to draft
|
Verified on Windows 11, AEDT 2026 R1, this PR branch (1.3.dev0): ✅ Attach to existing session works — started
Remote-machine attach (the original #7884 remote case) was not tested — no routable gRPC path between our two machines. |
|
Hi @tzhou-yyds , thanks for the feedback, I applied a small fix that could impact the issue you mentioned, I tested 2026R1: app_1 = Hfss(version="2026.1", port=50700, new_desktop=False, non_graphical=True, machine="127.0.0.1") With an open AEDT in non graphical mode with the env. variable PYAEDT_USE_PRE_GRPC_ARGS, and it not open a new AEDT instance. |
|
Re-tested with the latest
Thanks for the quick turnaround! |
SMoraisAnsys
left a comment
There was a problem hiding this comment.
Overall LGTM but there is something bothering me with "Step 6". Otherwise, I left minor comments.
| for el in all_sessions.values(): | ||
| if self.port in el.values(): | ||
| self.logger.warning(f"Port {self.port} is already in use. Finding a new free port.") | ||
| self.port = _find_free_port() |
There was a problem hiding this comment.
I think we shoudl directly play with __port instead of the port property. That way we are sure that any change in the property (like this PR) wouldn't affect the inner logic. Open to discussion though :)
| # Step 6: Fallback method - Try to find ports by checking TCP network connections | ||
| for version, sessions in return_dict_filtered.items(): | ||
| if any(port == -1 for port in sessions.values()): | ||
| for pid in [i for i, v in sessions.items() if v == -1]: | ||
| version_number = version.replace("_student", "").replace("_nongraphical", "").replace("_graphical", "") | ||
| sessions[pid] = _check_connection_grpc_port( | ||
| connections, | ||
| pid, | ||
| version_number, | ||
| True if "nongraphical" in version else False, | ||
| ) |
There was a problem hiding this comment.
I'm not sure how this step interact with the returned value, isn't there something missing here ?
|
|
||
|
|
||
| @pyaedt_function_handler() | ||
| def all_active_sessions() -> dict[str, dict]: |
There was a problem hiding this comment.
| def all_active_sessions() -> dict[str, dict]: | |
| def all_active_sessions() -> dict[str, dict[int, int]]: |
|
|
||
| Returns | ||
| ------- | ||
| dict[str, dict] |
There was a problem hiding this comment.
| dict[str, dict] | |
| dict[str, dict[int, int]] |
| Returns | ||
| ------- | ||
| dict[str, dict] | ||
| Dictionary mapping AEDT process IDs to their corresponding ports. |
There was a problem hiding this comment.
| Dictionary mapping AEDT process IDs to their corresponding ports. | |
| Dictionary mapping AEDT version to the associated process IDs and their corresponding ports. |
| @pyaedt_function_handler() | ||
| def _assign_port(self): | ||
| self.__port = 0 | ||
| self.port = 0 |
There was a problem hiding this comment.
Same remark as above, I would keep the __port value
|
|
||
|
|
||
| """ | ||
| # Step 1: Determine target process names based on version type and operating system |
There was a problem hiding this comment.
Steps do not align with the docstring description and misses the second step :p
| assert d2.new_desktop | ||
|
|
||
|
|
||
| def test_new_session_port_0(mock_settings): |
There was a problem hiding this comment.
Please split that into multiple tests isntead of one gathering everything. Same comment for the following ones
Description
Student version was connecting to existing session.
Platform: windows, linux
Issue linked
Close #7891
Close #7884
Checklist