MCPcopy Create free account
hub / github.com/mlco2/codecarbon / check_initial_data

Function check_initial_data

carbonserver/initial_data.py:17–33  ·  view source on GitHub ↗
(db)

Source from the content-addressed store, hash-verified

15
16
17def check_initial_data(db):
18 if settings.environment not in ("develop", "local"):
19 raise Exception("This script must be run in develop environment")
20
21 logger.info("Checking initial data...")
22 MAIN_USER_ID = "bb479cc8-3357-4859-985d-e3cc209d6fc9"
23 with db.session() as session:
24 e = session.query(SqlModelUser).filter(SqlModelUser.id == MAIN_USER_ID).first()
25 if e is None:
26 logger.info("User not found. Creating...")
27 db_user = SqlModelUser(
28 id=MAIN_USER_ID,
29 name="main user",
30 email="main.user@example.com",
31 )
32 session.add(db_user)
33 session.commit()
34
35
36# flake8: noqa

Callers 1

mainFunction · 0.85

Calls 1

sessionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…