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

feat: Feat/add local launcher #454

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Conversation

StefanThoene
Copy link
Collaborator

@StefanThoene StefanThoene commented Feb 13, 2025

Description

Provide local launcher method

Issue linked

#410

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 assigned this PR to myself.
  • I have made sure that the title of my PR follows Conventional commits style (e.g. feat: add optical property)
  • I have agreed with the Contributor License Agreement (CLA).

@github-actions github-actions bot added maintenance Package and maintenance related enhancement New features or code improvements labels Feb 13, 2025
@StefanThoene
Copy link
Collaborator Author

@echambla @pluAtAnsys @jomadec do we want to add this before the release?

@pluAtAnsys
Copy link
Collaborator

I am a bit hesitate here due to large magick method refactor (maybe?)

@StefanThoene StefanThoene self-assigned this Mar 24, 2025
@StefanThoene StefanThoene linked an issue Mar 24, 2025 that may be closed by this pull request
@StefanThoene
Copy link
Collaborator Author

@pluAtAnsys can oyu have a look?

we also need to think on how to test it?

add simple test
@github-actions github-actions bot added the testing Anything related to tests label Mar 25, 2025
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 87.48%. Comparing base (9064b19) to head (d81ac41).

Files with missing lines Patch % Lines
src/ansys/speos/core/launcher.py 86.95% 6 Missing ⚠️
src/ansys/speos/core/generic/general_methods.py 50.00% 3 Missing ⚠️
src/ansys/speos/core/kernel/client.py 93.18% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #454      +/-   ##
==========================================
+ Coverage   86.87%   87.48%   +0.60%     
==========================================
  Files          35       36       +1     
  Lines        3840     3923      +83     
==========================================
+ Hits         3336     3432      +96     
+ Misses        504      491      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StefanThoene StefanThoene changed the title wip: Feat/add local launcher feat: Feat/add local launcher Apr 8, 2025
@StefanThoene StefanThoene marked this pull request as ready for review April 8, 2025 14:45
@StefanThoene
Copy link
Collaborator Author

@pluAtAnsys could you have a look?

it might also make sense to have a look at the documentation for the launch Speos RPC part
or do you think we should do that in a seperate PR

Copy link
Contributor

@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.

I left some comments, we can discuss about them on a call if you want.

@@ -108,3 +110,26 @@ def wrapper(*args, **kwargs):
return method(*args, **kwargs)

return wrapper


def error_no_install(install_loc: Union[Path, str], version: Union[int, str]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this method is only used in launcher.py, I would move it to that file

Comment on lines +125 to +135
install_loc = Path(install_loc)
exe_notfound = (
"Ansys Speos RPC server installation not found at {}."
" Please define AWP_ROOT{} environment variable"
)
raise FileNotFoundError(
exe_notfound.format(
str(Path(install_loc.parent)),
version,
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install_loc = Path(install_loc)
exe_notfound = (
"Ansys Speos RPC server installation not found at {}."
" Please define AWP_ROOT{} environment variable"
)
raise FileNotFoundError(
exe_notfound.format(
str(Path(install_loc.parent)),
version,
)
)
if not install_loc:
install_loc_msg = ''
else:
install_loc_msg = f"at {Path(install_loc).parent}"
install_loc = Path(install_loc)
raise FileNotFoundError(
f"Ansys Speos RPC server installation not found{install_loc_msg}. "
f"Please define AWP_ROOT{version} environment variable"
)

Leveraging f-string and better handling of '' as location input.

):
"""Initialize the ``SpeosClient`` object."""
self._closed = False
self._remote_instance = remote_instance
self._command_line = command_line
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need to provide this command_line as input ? This may allow an attacker to launch arbitrary executables on the system. When exposing this direct launch mode to untrusted users, it is important to validate that the command is safe or hard-code it in the app.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but how can i know where the app is installed on the customers PC

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i don't want this variable to be set by anyone else than the launcher ideally

Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't you leverage the app location (once retrieved) to define the command instead ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it wouldn't change what would be transmitted really

-> yes i can transfer the install location but that would just remove the executable.
and rename the variable name

Comment on lines +532 to +533
p = subprocess.Popen(command)
p.wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
p = subprocess.Popen(command)
p.wait()
subprocess.run(command, check=True)

log_level: int = 20,
speos_rpc_loc: Optional[Union[Path, str]] = None,
) -> Speos:
"""Launch Speos RPC server locally.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Launch Speos RPC server locally.
"""Launch Speos RPC server locally.
.. warning::
Do not execute this function with untrusted input parameters.

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 maintenance Package and maintenance related testing Anything related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Launch local Service Method to launcher
4 participants