Skip to content

Commit

Permalink
[Python] v 1.2.1
Browse files Browse the repository at this point in the history
- bumps python version to 3.10
- adds nest-asyncio in the dependencies
- adds sync_connect in the GamaSyncClient
- removes __init__.py in the examples
  • Loading branch information
lesquoyb committed Dec 18, 2024
1 parent c8e7dd8 commit 87dbeee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Empty file removed python/examples/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion python/examples/bug tests/multiple_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def main(gaml_file, experiment):
await client.load(gaml_file, experiment)
res = await load_future

await client.reload(res["content"], parameters=[{"valueZ":"hehe"}])
await client.reload(res["content"], parameters=[{"valueZ": "hehe"}])

await client.load(gaml_file, experiment)
await client.load(gaml_file, experiment)
Expand Down
19 changes: 19 additions & 0 deletions python/gama_client/sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ def execute_cmd_sync(self, cmd: Dict[str, Any]):
self.futures[id] = self.event_loop.create_future()
return self.event_loop.run_until_complete(self.execute_cmd_inside(cmd, id))

def sync_connect(self, set_socket_id: bool = True, ping_interval: [Any, float] = 20, ping_timeout: float = 20):
"""
Tries to connect the client to gama-server using the url and port given at the initialization.
Once the connection is done it runs **start_listening_loop** and sets **socket_id** if **set_socket_id**
is True
:param set_socket_id: If True, the listening loop will filter out the messages of type ConnectionSuccessful
and the GamaClient will set its socket_id itself. If set to false, the users will have to set the client's
socket_id field themselves in the message_handler function
:param ping_interval: The interval between each
ping send to keepalive the connection, use None to deactivate this behaviour
:param ping_timeout: The time
the client is waiting for an answer to the ping sent before declaring that the connection is lost (part of
the keepalive loop)
:returns: Returns either once the listening loop starts if set_socket_id is False or when
a socket_id is sent by gama-server
:raise Exception: Can throw exceptions in case of connection problems.
"""
self.event_loop.run_until_complete(self.connect(set_socket_id, ping_interval, ping_timeout))

def sync_load(self, file_path: str, experiment_name: str, console: bool = None, status: bool = None,
dialog: bool = None, runtime: bool = None, parameters: List[Dict] = None, until: str = "",
socket_id: str = "",
Expand Down
5 changes: 3 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "gama_client"
version = "1.2.0"
version = "1.2.1"
authors = [
{ name="Baptiste Lesquoy", email="[email protected]" },
]
description = "A python library to interact with Gama server"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.7"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"websockets~=10.3",
"nest-asyncio"
]
[project.urls]
"Homepage" = "https://github.com/gama-platform/Gama-client-python"
Expand Down

0 comments on commit 87dbeee

Please sign in to comment.