Skip to content

Commit

Permalink
Added config details
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal.cd committed Feb 6, 2024
1 parent 8b4129e commit 25f158d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pebblo/app/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import lru_cache
from typing import Annotated

creds_details = load_config(None)



@lru_cache
Expand Down
35 changes: 15 additions & 20 deletions pebblo/app/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,28 @@ class Config(BaseSettings):

def load_config(path) -> Config:
if not path:
con_file = DEFAULT_SERVICE_CONFIG
try:
with open(con_file, "r") as output:
cred_json = yaml.safe_load(output)
print(cred_json, Config)
parsed_config = Config.parse_obj(cred_json)
return parsed_config.dict()

except IOError as err:
print(f"no credentials file found at {con_file}")
conf_obj = Config(
daemon=PortConfig(
host='0.0.0.0',
port=3700
),
reports=ReportConfig(
format='pdf',
outputDir='/home/Kunal/pebblo'
),
logging=LoggingConfig(
level='info'
)
)
return conf_obj.dict()
else:
con_file = path

try:
with open(con_file, "r") as output:
cred_json = yaml.safe_load(output)
print(cred_json, Config)
parsed_config = Config.parse_obj(cred_json)
config_dict = parsed_config.dict()
return config_dict
except IOError as err:
print(f"no credentials file found at {con_file}")

if config_dict:
try:
with open(DEFAULT_SERVICE_CONFIG, "w") as output:
yaml.dump(config_dict, output)
print(config_dict)
return config_dict
except IOError as err:
print(f"no credentials file found at {con_file}")
4 changes: 2 additions & 2 deletions pebblo/app/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
daemon:
port: 2300
host: '0.0.0.0'
port: 8000
host: 'localhost'
logging:
level: info
reports:
Expand Down

0 comments on commit 25f158d

Please sign in to comment.