Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
105 changes: 58 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions pyhilo/util/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Optional, Type, TypedDict, TypeVar, Union

import aiofiles
import ruyaml as yaml
import yaml

from pyhilo.const import LOG

Expand Down Expand Up @@ -42,7 +42,8 @@ class RegistrationDict(TypedDict, total=False):

class FirebaseDict(TypedDict):
fid: Optional[str]
name: Optional[str] # "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a"
# "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a"
name: Optional[str]
token: TokenDict


Expand Down Expand Up @@ -108,9 +109,15 @@ async def set_state(
"""
async with lock: # note ic-dev21: on lock le fichier pour être sûr de finir la job
current_state = await get_state(state_yaml) or {}
merged_state: dict[str, Any] = {key: {**current_state.get(key, {}), **state}} # type: ignore
merged_state: dict[str, Any] = {
key: {**current_state.get(key, {}), **state}
} # type: ignore
new_state: dict[str, Any] = {**current_state, **merged_state}
async with aiofiles.open(state_yaml, mode="w") as yaml_file:
LOG.debug("Saving state to yaml file")
# TODO: Use asyncio.get_running_loop() and run_in_executor to write
# to the file in a non blocking manner. Currently, the file writes
# are properly async but the yaml dump is done synchroniously on the
# main event loop.
content = yaml.dump(new_state)
await yaml_file.write(content)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ async-timeout = ">=4.0.0"
attrs = ">=21.2.0"
backoff = ">=1.11.1"
python-dateutil = ">=2.8.2"
ruyaml = ">=0.91.0"
python = "^3.9.0"
voluptuous = ">=0.13.1"
websockets = ">=8.1,<16.0"
gql = "^3.5.2"
pyyaml = "^6.0.2"

[poetry.group.dev.dependencies]
Sphinx = "^7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ frozenlist>=1.3.3
idna>=3.4
multidict>=6.0.4
python-dateutil>=2.8.2
ruyaml>=0.91.0
pyyaml>=6.0.2
six>=1.16.0
typing_extensions>=4.5.0
yarl>=1.8.2
Loading