Skip to content

Commit

Permalink
Resolveing merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
flopezag committed Jul 25, 2023
2 parents c41e106 + 816fea8 commit 6f0c760
Show file tree
Hide file tree
Showing 108 changed files with 6,110 additions and 932 deletions.
39 changes: 39 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# .coveragerc to control coverage.py
[run]
branch = True
omit =
./docs/*
./docker/*
./examples/*
./grammar/*
./logs/*
./tests/*
./dist/*
./images/*
./output/*

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

# Don't complain about abstract methods, they aren't run:
@(abc\.)?abstractmethod

ignore_errors = True

[html]
directory = coverage_html_report
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.venv/
doc/
docs/
examples/
test/
*.jsonld
Expand All @@ -8,7 +8,6 @@ tox.ini
test-requirements.txt
README.md
.stestr.conf
.pre-commit-config.yaml
.gitignore
logs/access.log
.git/
Expand Down
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Unit tests / coverage reports
htmlcov/
.tox/
.nox/
Expand Down Expand Up @@ -102,7 +102,6 @@ celerybeat.pid
*.sage.py

# Environments
.env
.venv
env/
venv/
Expand Down Expand Up @@ -130,8 +129,13 @@ dmypy.json

# IDE
.idea
.vscode

# Temporal generated JSON-LD documents
*.jsonld
output
output/*.jsonld
tests/test1.py

# logs folder
logs
23 changes: 11 additions & 12 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,28 @@
from sdmx2jsonld.transform.parser import Parser
from api.server import launch
from sdmx2jsonld.exceptions import UnexpectedEOF, UnexpectedInput, UnexpectedToken
from ngsild.ngsild_connector import NGSILDConnector

if __name__ == '__main__':
if __name__ == "__main__":
args = parse_cli()

if args['run'] is True:
file_in = args['--input']
file_out = args['--output']
if args["run"] is True:
file_in = args["--input"]
generate_files = args["--output"]

myparser = Parser()
my_parser = Parser()

try:
myparser.parsing(content=file_in, out=file_out)
my_parser.parsing(content=file_in, out=generate_files)
except UnexpectedToken as e:
print(e)
except UnexpectedInput as e:
print(e)
except UnexpectedEOF as e:
print(e)

elif args['server'] is True:
port = int(args['--port'])
host = args['--host']
elif args["server"] is True:
port = int(args["--port"])
host = args["--host"]

launch(app="api.server:application",
host=host,
port=port)
launch(app="api.server:application", host=host, port=port)
55 changes: 21 additions & 34 deletions api/custom_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

class InterceptHandler(Handler):
loglevel_mapping = {
50: 'CRITICAL',
40: 'ERROR',
30: 'WARNING',
20: 'INFO',
10: 'DEBUG',
0: 'NOTSET',
50: "CRITICAL",
40: "ERROR",
30: "WARNING",
20: "INFO",
10: "DEBUG",
0: "NOTSET",
}

def emit(self, record):
Expand All @@ -49,46 +49,32 @@ def emit(self, record):
frame = frame.f_back
depth += 1

log = logger.bind(request_id='app')
log.opt(
depth=depth,
exception=record.exc_info
).log(level,record.getMessage())
log = logger.bind(request_id="app")
log.opt(depth=depth, exception=record.exc_info).log(level, record.getMessage())


class CustomizeLogger:

@classmethod
def make_logger(cls, config_path: Path):

config = cls.load_logging_config(config_path)
logging_config = config.get('logger')
logging_config = config.get("logger")

logger = cls.customize_logging(
filepath=logging_config.get('path'),
level=logging_config.get('level'),
retention=logging_config.get('retention'),
rotation=logging_config.get('rotation'),
format=logging_config.get('format'))
filepath=logging_config.get("path"),
level=logging_config.get("level"),
retention=logging_config.get("retention"),
rotation=logging_config.get("rotation"),
format=logging_config.get("format"),
)

return logger

@classmethod
def customize_logging(cls,
filepath: Path,
level: str,
rotation: str,
retention: str,
format: str):
def customize_logging(cls, filepath: Path, level: str, rotation: str, retention: str, format: str):

logger.remove()

logger.add(
sys.stdout,
enqueue=True,
backtrace=True,
level=level.upper(),
format=format)
logger.add(sys.stdout, enqueue=True, backtrace=True, level=level.upper(), format=format)

logger.add(
str(filepath),
Expand All @@ -97,12 +83,13 @@ def customize_logging(cls,
enqueue=True,
backtrace=True,
level=level.upper(),
format=format)
format=format,
)

basicConfig(handlers=[InterceptHandler()], level=0)
getLogger("uvicorn.access").handlers = [InterceptHandler()]

for _log in ['uvicorn', 'uvicorn.error', 'uvicorn.access', 'fastapi']:
for _log in ["uvicorn", "uvicorn.error", "uvicorn.access", "fastapi"]:
_logger = getLogger(_log)
_logger.handlers = [InterceptHandler()]

Expand All @@ -113,4 +100,4 @@ def load_logging_config(cls, config_path):
config = None
with open(config_path) as config_file:
config = load(config_file)
return config
return config
Loading

0 comments on commit 6f0c760

Please sign in to comment.