Skip to content

Commit

Permalink
restart the changes: DataSources class typehints and description
Browse files Browse the repository at this point in the history
  • Loading branch information
luisaFelixSalles committed Oct 15, 2024
1 parent 0bc23b9 commit 765f41d
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/ansys/dpf/core/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
============
"""

from __future__ import annotations

import os
import warnings
import traceback
from typing import Union
from typing import Union, Optional, TYPE_CHECKING

from ansys.dpf.core import server as server_module
from ansys.dpf.gate import (
Expand All @@ -44,22 +46,28 @@
from ansys.dpf.core.check_version import version_requires
from ansys.dpf.core import errors

if TYPE_CHECKING:
from ansys.dpf import core as dpf
from ansys.dpf.core import server_types
from ansys.grpc.dpf import data_sources_pb2 as DataSourcesPB2


class DataSources:
"""Contains files with analysis results.
"""Manages paths to files as sources of data.
Use this object to declare data inputs for DPF and define their locations.
An extension key (``'rst'`` for example) is used to choose which files represent
results files versus accessory files. You can set a result file path when
initializing this class.
Parameters
----------
result_path : str or os.PathLike object, optional
result_path
Path of the result. The default is ``None``.
data_sources : ansys.grpc.dpf.data_sources_pb2.DataSources
data_sources
gRPC data sources message. The default is ``None``.
server : server.DPFServer, optional
server
Server with the channel connected to the remote or local instance. The
default is ``None``, in which case an attempt is made to use the global
server.
Expand All @@ -69,13 +77,20 @@ class DataSources:
Initialize a model from a result path.
>>> from ansys.dpf import core as dpf
>>> # Create the DataSources object with a main file path
>>> my_data_sources = dpf.DataSources('file.rst')
>>> # Get the path to the main result file
>>> my_data_sources.result_files
['file.rst']
"""

def __init__(self, result_path=None, data_sources=None, server=None):
def __init__(
self,
result_path: Optional[str, os.PathLike] = None,
data_sources: Optional[dpf.DataSources, int, DataSourcesPB2.DataSources] = None,
server: Optional[type[server_types.BaseServer]] = None,
):
"""Initialize a connection with the server."""
# step 1: get server
self._server = server_module.get_or_create_server(
Expand Down

0 comments on commit 765f41d

Please sign in to comment.