1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-22 16:04:18 +00:00
bda-6-steffo/unimore_bda_6/config.py

45 lines
850 B
Python
Raw Normal View History

2023-02-01 03:20:09 +00:00
import cfig
config = cfig.Configuration()
2023-02-01 15:03:10 +00:00
@config.optional()
def MONGO_HOST(val: str | None) -> str:
2023-02-01 03:20:09 +00:00
"""
The hostname of the MongoDB database to connect to.
"""
2023-02-01 15:03:10 +00:00
return val or "127.0.0.1"
2023-02-01 03:20:09 +00:00
2023-02-01 15:03:10 +00:00
@config.optional()
def MONGO_PORT(val: str | None) -> int:
2023-02-01 03:20:09 +00:00
"""
The port of the MongoDB database to connect to.
"""
2023-02-01 15:03:10 +00:00
if not val:
return 27017
try:
return int(val)
except ValueError:
raise cfig.InvalidValueError("Not an int.")
2023-02-01 03:20:09 +00:00
2023-02-01 15:03:10 +00:00
@config.optional()
def TRAINING_SET_SIZE(val: str | None) -> int:
2023-02-01 03:20:09 +00:00
"""
The number of reviews from each category to fetch for the training set.
"""
2023-02-01 15:03:10 +00:00
if not val:
return 1000
2023-02-01 03:20:09 +00:00
try:
return int(val)
except ValueError:
raise cfig.InvalidValueError("Not an int.")
__all__ = (
"config",
"MONGO_HOST",
"MONGO_PORT",
)