Skip to content

Commit

Permalink
Changes from self review
Browse files Browse the repository at this point in the history
  • Loading branch information
ansjmoody committed Nov 21, 2024
1 parent c725e42 commit 89dc207
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 77 deletions.
3 changes: 2 additions & 1 deletion src/ansys/sherlock/core/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,8 @@ def add_modeling_region(
----------
project: str
Name of the Sherlock project.
modeling_regions: list[dict]
modeling_regions: list[dict[str, bool | float | str | dict[str, bool | float | str]\
| dict[str, float | str]]]
Modeling regions to add. Each dictionary should contain:
- cca_name: str
Expand Down
152 changes: 76 additions & 76 deletions src/ansys/sherlock/core/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,82 +1515,6 @@ def add_shock_event(
LOG.error(error)
raise e

@require_version()
def load_random_vibe_profile(
self, project: str, phase_name: str, event_name: str, file_path: str
) -> int:
"""Load random vibe profile from .csv or .dat file.
Available Since: 2023R1
Parameters
----------
project: str
Name of the Sherlock project
phase_name: str
Name of the lifecycle phase to add this event to.
event_name: str
Name of the random vibe event.
file_path: str
File path for thermal profile .dat or .csv file
Returns
-------
int
Status code of the response. 0 for success.
Example
-------
>>> from ansys.sherlock.core.launcher import launch_sherlock
>>> sherlock = launch_sherlock()
>>> sherlock.project.import_odb_archive(
"ODB++ Tutorial.tgz",
True,
True,
True,
True,
project="Test",
cca_name="Card"
)
>>> sherlock.lifecycle.load_random_vibe_profile(
project="Tutorial",
phase_name="Phase 1",
event_name="Random Event",
file_path="TestProfile.dat"
)
"""
try:
if project == "":
raise SherlockLoadRandomVibeProfileError(message="Project name is invalid.")
if phase_name == "":
raise SherlockLoadRandomVibeProfileError(message="Phase name is invalid.")
if event_name == "":
raise SherlockLoadRandomVibeProfileError(message="Event name is invalid.")
if file_path == "":
raise SherlockLoadRandomVibeProfileError(message="File path is invalid.")
if not self._is_connection_up():
raise SherlockNoGrpcConnectionException()

request = SherlockLifeCycleService_pb2.LoadRandomVibeProfileRequest(
project=project,
phaseName=phase_name,
eventName=event_name,
filePath=file_path,
)
response = self.stub.loadRandomVibeProfile(request)
return_code = response.returnCode
if return_code.value == -1:
if return_code.message == "":
raise SherlockLoadRandomVibeProfileError(error_array=response.errors)

raise SherlockLoadRandomVibeProfileError(message=return_code.message)

return return_code.value
except SherlockLoadRandomVibeProfileError as e:
LOG.error(str(e))
raise e

@require_version()
def add_shock_profiles(
self,
Expand Down Expand Up @@ -1811,6 +1735,82 @@ def add_shock_profiles(
LOG.error(error)
raise e

@require_version()
def load_random_vibe_profile(
self, project: str, phase_name: str, event_name: str, file_path: str
) -> int:
"""Load random vibe profile from .csv or .dat file.
Available Since: 2023R1
Parameters
----------
project: str
Name of the Sherlock project
phase_name: str
Name of the lifecycle phase to add this event to.
event_name: str
Name of the random vibe event.
file_path: str
File path for thermal profile .dat or .csv file
Returns
-------
int
Status code of the response. 0 for success.
Example
-------
>>> from ansys.sherlock.core.launcher import launch_sherlock
>>> sherlock = launch_sherlock()
>>> sherlock.project.import_odb_archive(
"ODB++ Tutorial.tgz",
True,
True,
True,
True,
project="Test",
cca_name="Card"
)
>>> sherlock.lifecycle.load_random_vibe_profile(
project="Tutorial",
phase_name="Phase 1",
event_name="Random Event",
file_path="TestProfile.dat"
)
"""
try:
if project == "":
raise SherlockLoadRandomVibeProfileError(message="Project name is invalid.")
if phase_name == "":
raise SherlockLoadRandomVibeProfileError(message="Phase name is invalid.")
if event_name == "":
raise SherlockLoadRandomVibeProfileError(message="Event name is invalid.")
if file_path == "":
raise SherlockLoadRandomVibeProfileError(message="File path is invalid.")
if not self._is_connection_up():
raise SherlockNoGrpcConnectionException()

request = SherlockLifeCycleService_pb2.LoadRandomVibeProfileRequest(
project=project,
phaseName=phase_name,
eventName=event_name,
filePath=file_path,
)
response = self.stub.loadRandomVibeProfile(request)
return_code = response.returnCode
if return_code.value == -1:
if return_code.message == "":
raise SherlockLoadRandomVibeProfileError(error_array=response.errors)

raise SherlockLoadRandomVibeProfileError(message=return_code.message)

return return_code.value
except SherlockLoadRandomVibeProfileError as e:
LOG.error(str(e))
raise e

@require_version()
def load_thermal_profile(
self, project: str, phase_name: str, event_name: str, file_path: str
Expand Down

0 comments on commit 89dc207

Please sign in to comment.