Skip to content

Commit

Permalink
Check whether the ipc socket exist When parsing the config YAML. (#1736)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dashanji authored Jan 29, 2024
1 parent 95a1610 commit 595e590
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
11 changes: 8 additions & 3 deletions python/vineyard/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 3 additions & 3 deletions python/vineyard/deploy/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 8 additions & 4 deletions python/vineyard/shared_memory/shared_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 595e590

Please sign in to comment.