From 595e590d913fbcb8c072759942ad236b63d9c99a Mon Sep 17 00:00:00 2001 From: Ye Cao Date: Mon, 29 Jan 2024 16:04:49 +0800 Subject: [PATCH] Check whether the ipc socket exist When parsing the config YAML. (#1736) When using something like `client =vineyard.connect(config=./vineyard.yaml)`, we need to check whether the IPC socket file exists. --------- Signed-off-by: Ye Cao --- python/vineyard/core/client.py | 11 ++++++++--- python/vineyard/deploy/kubernetes.py | 6 +++--- python/vineyard/shared_memory/shared_memory.py | 12 ++++++++---- requirements-dev.txt | 2 +- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/python/vineyard/core/client.py b/python/vineyard/core/client.py index d175d45c4..da01ee463 100644 --- a/python/vineyard/core/client.py +++ b/python/vineyard/core/client.py @@ -83,9 +83,14 @@ def _parse_configuration(config) -> Tuple[Optional[str], Optional[str]]: ipc_socket = vineyard_config.get('IPCSocket', None) rpc_endpoint = vineyard_config.get('RPCEndpoint', None) - if ipc_socket and not os.path.isabs(ipc_socket): - base_dir = os.path.dirname(config) if os.path.isfile(config) else config - ipc_socket = os.path.join(base_dir, ipc_socket) + if ipc_socket: + if not os.path.isabs(ipc_socket): + base_dir = os.path.dirname(config) if os.path.isfile(config) else config + ipc_socket = os.path.join(base_dir, ipc_socket) + + if not os.path.exists(ipc_socket): + ipc_socket = None + return ipc_socket, rpc_endpoint diff --git a/python/vineyard/deploy/kubernetes.py b/python/vineyard/deploy/kubernetes.py index fe79a6d86..45ef02851 100644 --- a/python/vineyard/deploy/kubernetes.py +++ b/python/vineyard/deploy/kubernetes.py @@ -108,9 +108,9 @@ def start_vineyardd( 'Port': rpc_socket_port, 'Image': vineyard_image, 'ImagePullPolicy': vineyard_image_pull_policy, - 'ImagePullSecrets': vineyard_image_pull_secrets - if vineyard_image_pull_secrets - else 'none', + 'ImagePullSecrets': ( + vineyard_image_pull_secrets if vineyard_image_pull_secrets else 'none', + ), } definitions = fp.read().format(**formatter) diff --git a/python/vineyard/shared_memory/shared_memory.py b/python/vineyard/shared_memory/shared_memory.py index 533259feb..70ad0e786 100644 --- a/python/vineyard/shared_memory/shared_memory.py +++ b/python/vineyard/shared_memory/shared_memory.py @@ -195,10 +195,14 @@ def __init__(self, vineyard_client, sequence=None, *, name=None): sequence = sequence or () _formats = [ - self._types_mapping[type(item)] - if not isinstance(item, (str, bytes)) # noqa: E131 - else self._types_mapping[type(item)] - % (self._alignment * (len(item) // self._alignment + 1),) # noqa: E131 + ( + self._types_mapping[type(item)] + if not isinstance(item, (str, bytes)) # noqa: E131 + else self._types_mapping[type(item)] + % ( + self._alignment * (len(item) // self._alignment + 1), + ) # noqa: E131 + ) for item in sequence ] self._list_len = len(_formats) diff --git a/requirements-dev.txt b/requirements-dev.txt index 7ceddcf08..6a45e6cbf 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,7 +12,7 @@ linkify-it-py myst-parser>=0.13.0 nbsphinx pygments>=2.4.1 -pytest +pytest<8.0.0 pytest-benchmark pytest-cases pytest-datafiles