Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from ansys.dpf.core._version import min_server_version, server_to_ansys_version
from ansys.dpf.core.check_version import get_server_version, meets_version, version_requires
from ansys.dpf.core.server_context import AvailableServerContexts, ServerContext
from ansys.dpf.gate import data_processing_grpcapi, load_api
from ansys.dpf.gate import data_processing_capi, data_processing_grpcapi, load_api

if TYPE_CHECKING: # pragma: no cover
from ansys.dpf.core.server_factory import DockerConfig
Expand Down Expand Up @@ -709,6 +709,29 @@ def __del__(self):
except:
warnings.warn(traceback.format_exc())

def start_debug(self, folder_path: str | Path):
Copy link
Contributor

Choose a reason for hiding this comment

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

should it really be at the server API? Wouldn't it be better in core, close to load plugin...

Also, I would create a context manager (similar design to licensing context manager)

Copy link
Contributor

Choose a reason for hiding this comment

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

and tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I'll put tests but I wanted to validate the API first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put it at the Server level because it is a specific server you ask for its debug info.
I can make a context manager and also expose it at the ansys.dpf.core level as a global command which would take the global server.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense here, as it is for a given server.

Just a question, I remember we had an issue in the past that was fixed for data sources when the client was in a OS (say Windows) and the server was another (say Linux), that there was some path adaptation. I think that was fixed. Is this affected by that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes sense here, as it is for a given server.

Just a question, I remember we had an issue in the past that was fixed for data sources when the client was in a OS (say Windows) and the server was another (say Linux), that there was some path adaptation. I think that was fixed. Is this affected by that?

yes you are right, I am now adding the same logic here.

"""Start writing server debug information within the given folder.

Parameters
----------
folder_path:
Path to a folder where to write server debug info.

"""
api = self.get_api_for_type(
capi=data_processing_capi.DataProcessingCAPI,
grpcapi=data_processing_grpcapi.DataProcessingGRPCAPI,
)
api.data_processing_set_debug_trace(text=str(folder_path))

def stop_debug(self):
"""Stop writing server debug information."""
api = self.get_api_for_type(
capi=data_processing_capi.DataProcessingCAPI,
grpcapi=data_processing_grpcapi.DataProcessingGRPCAPI,
)
api.data_processing_set_debug_trace(text="")


class CServer(BaseServer, ABC):
"""Abstract class for servers going through the DPFClientAPI."""
Expand Down
Loading