Skip to content

Commit 09007ff

Browse files
committed
Minor changes
1 parent d8443c5 commit 09007ff

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

backend/infrahub/database/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_branch_name(branch: Optional[Union[Branch, str]] = None) -> str:
7878

7979

8080
class DatabaseSchemaManager:
81-
def __init__(self, db: InfrahubDatabase):
81+
def __init__(self, db: InfrahubDatabase) -> None:
8282
self._db = db
8383

8484
def get(self, name: str, branch: Optional[Union[Branch, str]] = None, duplicate: bool = True) -> MainSchemaTypes:

backend/tests/helpers/query_benchmark/car_person_generators.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ async def load_cars(self, nb_cars: int, persons: Optional[dict[str, Node]] = Non
3131
await car_node.new(db=self.db, name=car_name, nbr_seats=4, owner=random_person)
3232
else:
3333
await car_node.new(db=self.db, name=car_name, nbr_seats=4)
34-
await self._save_obj(car_node)
34+
35+
async with self.db.start_session():
36+
await car_node.save(db=self.db)
37+
3538
cars[car_name] = car_node
3639

3740
return cars
@@ -60,7 +63,10 @@ async def load_persons(self, nb_persons: int, cars: Optional[dict[str, Node]] =
6063
await person_node.new(db=self.db, name=person_name, cars=random_cars)
6164
else:
6265
await person_node.new(db=self.db, name=person_name)
63-
await self._save_obj(person_node)
66+
67+
async with self.db.start_session():
68+
await person_node.save(db=self.db)
69+
6470
persons_names_to_nodes[person_name] = person_node
6571

6672
return persons_names_to_nodes

backend/tests/helpers/query_benchmark/data_generator.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from rich.console import Console
66
from rich.progress import Progress
77

8-
from infrahub.core.node import Node
98
from tests.helpers.query_benchmark.db_query_profiler import InfrahubDatabaseProfiler, ProfilerEnabler, query_analyzer
109

1110

@@ -26,11 +25,6 @@ async def init(self) -> None:
2625
async def load_data(self, nb_elements: int) -> None:
2726
raise NotImplementedError("Abstract method")
2827

29-
async def _save_obj(self, obj: Node) -> None:
30-
async with self.db.start_session() as dbs:
31-
async with dbs.start_transaction() as dbt:
32-
await obj.save(db=dbt)
33-
3428

3529
async def load_data_and_profile(
3630
data_generator: DataGenerator,

0 commit comments

Comments
 (0)