From 31edea309bb09bac4bd36356edb9aa8ff7854604 Mon Sep 17 00:00:00 2001 From: Nathan Hui Date: Sat, 14 Dec 2024 12:22:29 -0800 Subject: [PATCH] feat: Adds current time annotation --- label_studio_slack_reporter/service.py | 5 ++ poetry.lock | 19 +++++- pyproject.toml | 2 + volumes/logs/service.log.2024-12-13 | 84 ++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 volumes/logs/service.log.2024-12-13 diff --git a/label_studio_slack_reporter/service.py b/label_studio_slack_reporter/service.py index 0c6cf3b..c9d0242 100644 --- a/label_studio_slack_reporter/service.py +++ b/label_studio_slack_reporter/service.py @@ -3,6 +3,7 @@ from __future__ import annotations import argparse +import datetime as dt import logging import time from pathlib import Path @@ -13,6 +14,7 @@ import pycron from prometheus_client import start_http_server from tomlkit import parse +from tzlocal import get_localzone from label_studio_slack_reporter.config import configure_logging from label_studio_slack_reporter.label_studio import Reporter @@ -72,6 +74,9 @@ def __init__(self, ) def __configure_schedule(self): + current_tz = get_localzone() + now = dt.datetime.now(current_tz) + self.__log.info('Current time %s', now.isoformat()) for output_unit, output_config in self.__config['output'].items(): if 'schedule' not in output_config: raise KeyError(f'Expected schedule in output.{output_unit}') diff --git a/poetry.lock b/poetry.lock index e413a20..71e7042 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3465,6 +3465,23 @@ files = [ {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, ] +[[package]] +name = "tzlocal" +version = "5.2" +description = "tzinfo object for the local timezone" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tzlocal-5.2-py3-none-any.whl", hash = "sha256:49816ef2fe65ea8ac19d19aa7a1ae0551c834303d5014c6d5a62e4cbda8047b8"}, + {file = "tzlocal-5.2.tar.gz", hash = "sha256:8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e"}, +] + +[package.dependencies] +tzdata = {version = "*", markers = "platform_system == \"Windows\""} + +[package.extras] +devenv = ["check-manifest", "pytest (>=4.3)", "pytest-cov", "pytest-mock (>=3.3)", "zest.releaser"] + [[package]] name = "ujson" version = "5.10.0" @@ -3731,4 +3748,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.12,<3.13" -content-hash = "a761a89872c4e01191a99017acd04f8dbe90b3173772c79e90b1219b902110f9" +content-hash = "dd838ddad29674fb1160cb90969a8dbef351d0100efb3d6caeed6d46349ecc11" diff --git a/pyproject.toml b/pyproject.toml index 3c8485a..eb298e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,8 @@ platformdirs = "^4.3.6" tomlkit = "^0.13.2" pycron = "^3.1.1" prometheus-client = "^0.21.1" +pytz = "^2024.2" +tzlocal = "^5.2" [tool.poetry.group.dev.dependencies] pylint = "^3.2.7" diff --git a/volumes/logs/service.log.2024-12-13 b/volumes/logs/service.log.2024-12-13 new file mode 100644 index 0000000..d09e45c --- /dev/null +++ b/volumes/logs/service.log.2024-12-13 @@ -0,0 +1,84 @@ +2024-12-14T07:30:24.105Z - root - INFO - Log path: volumes\logs +2024-12-14T07:30:24.105Z - root - INFO - Data path: volumes\data +2024-12-14T07:30:24.105Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:30:24.752Z - Service - INFO - Running +2024-12-14T07:33:58.411Z - root - INFO - Log path: volumes\logs +2024-12-14T07:33:58.411Z - root - INFO - Data path: volumes\data +2024-12-14T07:33:58.411Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:34:38.145Z - root - INFO - Log path: volumes\logs +2024-12-14T07:34:38.145Z - root - INFO - Data path: volumes\data +2024-12-14T07:34:38.145Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:35:15.728Z - root - INFO - Log path: volumes\logs +2024-12-14T07:35:15.728Z - root - INFO - Data path: volumes\data +2024-12-14T07:35:15.741Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:35:17.166Z - Service - INFO - Running +2024-12-14T07:45:37.348Z - root - INFO - Log path: volumes\logs +2024-12-14T07:45:37.348Z - root - INFO - Data path: volumes\data +2024-12-14T07:45:37.348Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:45:37.886Z - httpcore.connection - DEBUG - connect_tcp.started host='labeler.e4e.ucsd.edu' port=443 local_address=None timeout=60 socket_options=None +2024-12-14T07:45:37.973Z - httpcore.connection - DEBUG - connect_tcp.complete return_value= +2024-12-14T07:45:37.974Z - httpcore.connection - DEBUG - start_tls.started ssl_context= server_hostname='labeler.e4e.ucsd.edu' timeout=60 +2024-12-14T07:45:38.003Z - httpcore.connection - DEBUG - start_tls.complete return_value= +2024-12-14T07:45:38.003Z - httpcore.http11 - DEBUG - send_request_headers.started request= +2024-12-14T07:45:38.006Z - httpcore.http11 - DEBUG - send_request_headers.complete +2024-12-14T07:45:38.007Z - httpcore.http11 - DEBUG - send_request_body.started request= +2024-12-14T07:45:38.007Z - httpcore.http11 - DEBUG - send_request_body.complete +2024-12-14T07:45:38.008Z - httpcore.http11 - DEBUG - receive_response_headers.started request= +2024-12-14T07:46:01.111Z - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Allow', b'GET, HEAD, OPTIONS'), (b'Alt-Svc', b'h3=":443"; ma=2592000'), (b'Content-Disposition', b'attachment; filename="project-10-at-2024-12-14-07-46-eabccfc4.json"'), (b'Content-Language', b'en-us'), (b'Content-Length', b'19278894'), (b'Content-Security-Policy-Report-Only', b"default-src 'self' 'report-sample'; connect-src 'self' 'report-sample' https://*.google-analytics.com https://*.analytics.google.com https://analytics.google.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.ingest.sentry.io; script-src 'self' 'report-sample' 'unsafe-inline' 'unsafe-eval' blob: browser.sentry-cdn.com https://*.googletagmanager.com; img-src 'self' 'report-sample' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.google.com; style-src 'self' 'report-sample' 'unsafe-inline'"), (b'Content-Type', b'application/.json'), (b'Date', b'Sat, 14 Dec 2024 07:46:00 GMT'), (b'Filename', b'project-10-at-2024-12-14-07-46-eabccfc4.json'), (b'Referrer-Policy', b'same-origin'), (b'Server', b'Caddy'), (b'Server', b'WSGIServer/0.2 CPython/3.10.12'), (b'Set-Cookie', b'sessionid=eyJ1aWQiOiJjYjk2ODkxYi04YjRjLTQxNGItYWFlMS0xYzI1YWIyZmYyYzEiLCJvcmdhbml6YXRpb25fcGsiOjF9:1tMMqe:WhO5I-QSHOyrClEkLymDwTYGfo5RMq6OauEzYEufTKY; expires=Sat, 28 Dec 2024 07:46:00 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax'), (b'Vary', b'Accept-Language, Cookie, Origin'), (b'X-Content-Type-Options', b'nosniff')]) +2024-12-14T07:46:01.116Z - httpx - INFO - HTTP Request: GET https://labeler.e4e.ucsd.edu/api/projects/10/export?download_resources=false&download_all_tasks=false&export_type=JSON "HTTP/1.1 200 OK" +2024-12-14T07:46:01.116Z - httpcore.http11 - DEBUG - receive_response_body.started request= +2024-12-14T07:46:03.808Z - httpcore.http11 - DEBUG - receive_response_body.complete +2024-12-14T07:46:03.808Z - httpcore.http11 - DEBUG - response_closed.started +2024-12-14T07:46:03.808Z - httpcore.http11 - DEBUG - response_closed.complete +2024-12-14T07:51:21.884Z - root - INFO - Log path: volumes\logs +2024-12-14T07:51:21.884Z - root - INFO - Data path: volumes\data +2024-12-14T07:51:21.884Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:51:40.847Z - httpcore.connection - DEBUG - connect_tcp.started host='labeler.e4e.ucsd.edu' port=443 local_address=None timeout=60 socket_options=None +2024-12-14T07:51:40.918Z - httpcore.connection - DEBUG - connect_tcp.complete return_value= +2024-12-14T07:51:40.919Z - httpcore.connection - DEBUG - start_tls.started ssl_context= server_hostname='labeler.e4e.ucsd.edu' timeout=60 +2024-12-14T07:51:40.949Z - httpcore.connection - DEBUG - start_tls.complete return_value= +2024-12-14T07:51:40.949Z - httpcore.http11 - DEBUG - send_request_headers.started request= +2024-12-14T07:51:40.950Z - httpcore.http11 - DEBUG - send_request_headers.complete +2024-12-14T07:51:40.951Z - httpcore.http11 - DEBUG - send_request_body.started request= +2024-12-14T07:51:40.952Z - httpcore.http11 - DEBUG - send_request_body.complete +2024-12-14T07:51:40.952Z - httpcore.http11 - DEBUG - receive_response_headers.started request= +2024-12-14T07:52:44.148Z - root - INFO - Log path: volumes\logs +2024-12-14T07:52:44.149Z - root - INFO - Data path: volumes\data +2024-12-14T07:52:44.150Z - root - INFO - Cache path: volumes\cache +2024-12-14T07:52:44.696Z - httpcore.connection - DEBUG - connect_tcp.started host='labeler.e4e.ucsd.edu' port=443 local_address=None timeout=60 socket_options=None +2024-12-14T07:52:44.764Z - httpcore.connection - DEBUG - connect_tcp.complete return_value= +2024-12-14T07:52:44.765Z - httpcore.connection - DEBUG - start_tls.started ssl_context= server_hostname='labeler.e4e.ucsd.edu' timeout=60 +2024-12-14T07:52:44.788Z - httpcore.connection - DEBUG - start_tls.complete return_value= +2024-12-14T07:52:44.788Z - httpcore.http11 - DEBUG - send_request_headers.started request= +2024-12-14T07:52:44.795Z - httpcore.http11 - DEBUG - send_request_headers.complete +2024-12-14T07:52:44.795Z - httpcore.http11 - DEBUG - send_request_body.started request= +2024-12-14T07:52:44.796Z - httpcore.http11 - DEBUG - send_request_body.complete +2024-12-14T07:52:44.797Z - httpcore.http11 - DEBUG - receive_response_headers.started request= +2024-12-14T07:53:08.219Z - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Allow', b'GET, HEAD, OPTIONS'), (b'Alt-Svc', b'h3=":443"; ma=2592000'), (b'Content-Disposition', b'attachment; filename="project-10-at-2024-12-14-07-53-eabccfc4.json"'), (b'Content-Language', b'en-us'), (b'Content-Length', b'19278894'), (b'Content-Security-Policy-Report-Only', b"default-src 'self' 'report-sample'; connect-src 'self' 'report-sample' https://*.google-analytics.com https://*.analytics.google.com https://analytics.google.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.ingest.sentry.io; script-src 'self' 'report-sample' 'unsafe-inline' 'unsafe-eval' blob: browser.sentry-cdn.com https://*.googletagmanager.com; img-src 'self' 'report-sample' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.google.com; style-src 'self' 'report-sample' 'unsafe-inline'"), (b'Content-Type', b'application/.json'), (b'Date', b'Sat, 14 Dec 2024 07:53:07 GMT'), (b'Filename', b'project-10-at-2024-12-14-07-53-eabccfc4.json'), (b'Referrer-Policy', b'same-origin'), (b'Server', b'Caddy'), (b'Server', b'WSGIServer/0.2 CPython/3.10.12'), (b'Set-Cookie', b'sessionid=eyJ1aWQiOiIxNDkwMDlhYS04OWE5LTQ5ZWMtYTBjZS1mMjBkMWFhMDU2NDIiLCJvcmdhbml6YXRpb25fcGsiOjF9:1tMMxX:vaE8naMtNhImLo5IxO5rcPQ8RCMun0gW9rdS3gkBiJw; expires=Sat, 28 Dec 2024 07:53:07 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax'), (b'Vary', b'Accept-Language, Cookie, Origin'), (b'X-Content-Type-Options', b'nosniff')]) +2024-12-14T07:53:08.235Z - httpx - INFO - HTTP Request: GET https://labeler.e4e.ucsd.edu/api/projects/10/export?download_resources=false&download_all_tasks=false&export_type=JSON "HTTP/1.1 200 OK" +2024-12-14T07:53:08.235Z - httpcore.http11 - DEBUG - receive_response_body.started request= +2024-12-14T07:53:11.014Z - httpcore.http11 - DEBUG - receive_response_body.complete +2024-12-14T07:53:11.014Z - httpcore.http11 - DEBUG - response_closed.started +2024-12-14T07:53:11.014Z - httpcore.http11 - DEBUG - response_closed.complete +2024-12-14T07:53:11.319Z - httpcore.http11 - DEBUG - send_request_headers.started request= +2024-12-14T07:53:11.319Z - httpcore.http11 - DEBUG - send_request_headers.complete +2024-12-14T07:53:11.319Z - httpcore.http11 - DEBUG - send_request_body.started request= +2024-12-14T07:53:11.319Z - httpcore.http11 - DEBUG - send_request_body.complete +2024-12-14T07:53:11.319Z - httpcore.http11 - DEBUG - receive_response_headers.started request= +2024-12-14T07:53:11.424Z - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Allow', b'GET, POST, HEAD'), (b'Alt-Svc', b'h3=":443"; ma=2592000'), (b'Content-Language', b'en-us'), (b'Content-Length', b'7156'), (b'Content-Security-Policy-Report-Only', b"default-src 'self' 'report-sample'; connect-src 'self' 'report-sample' https://*.google-analytics.com https://*.analytics.google.com https://analytics.google.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.ingest.sentry.io; script-src 'self' 'report-sample' 'unsafe-inline' 'unsafe-eval' blob: browser.sentry-cdn.com https://*.googletagmanager.com; img-src 'self' 'report-sample' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.google.com; style-src 'self' 'report-sample' 'unsafe-inline'"), (b'Content-Type', b'application/json'), (b'Date', b'Sat, 14 Dec 2024 07:53:10 GMT'), (b'Referrer-Policy', b'same-origin'), (b'Server', b'Caddy'), (b'Server', b'WSGIServer/0.2 CPython/3.10.12'), (b'Set-Cookie', b'sessionid=eyJ1aWQiOiIxNDkwMDlhYS04OWE5LTQ5ZWMtYTBjZS1mMjBkMWFhMDU2NDIiLCJvcmdhbml6YXRpb25fcGsiOjF9:1tMMxa:y7vc_HdZynRUHUjnijbktOZAeBHXIx1_fVZzJZ4_Nqc; expires=Sat, 28 Dec 2024 07:53:10 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax'), (b'Vary', b'Accept-Language, Cookie, Origin'), (b'X-Content-Type-Options', b'nosniff')]) +2024-12-14T07:53:11.427Z - httpx - INFO - HTTP Request: GET https://labeler.e4e.ucsd.edu/api/users/ "HTTP/1.1 200 OK" +2024-12-14T07:53:11.428Z - httpcore.http11 - DEBUG - receive_response_body.started request= +2024-12-14T07:53:11.429Z - httpcore.http11 - DEBUG - receive_response_body.complete +2024-12-14T07:53:11.431Z - httpcore.http11 - DEBUG - response_closed.started +2024-12-14T07:53:11.431Z - httpcore.http11 - DEBUG - response_closed.complete +2024-12-14T07:53:11.438Z - httpcore.http11 - DEBUG - send_request_headers.started request= +2024-12-14T07:53:11.440Z - httpcore.http11 - DEBUG - send_request_headers.complete +2024-12-14T07:53:11.441Z - httpcore.http11 - DEBUG - send_request_body.started request= +2024-12-14T07:53:11.441Z - httpcore.http11 - DEBUG - send_request_body.complete +2024-12-14T07:53:11.442Z - httpcore.http11 - DEBUG - receive_response_headers.started request= +2024-12-14T07:53:11.652Z - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Allow', b'GET, PUT, PATCH, DELETE, HEAD, OPTIONS'), (b'Alt-Svc', b'h3=":443"; ma=2592000'), (b'Content-Language', b'en-us'), (b'Content-Length', b'2248'), (b'Content-Security-Policy-Report-Only', b"default-src 'self' 'report-sample'; connect-src 'self' 'report-sample' https://*.google-analytics.com https://*.analytics.google.com https://analytics.google.com https://*.googletagmanager.com https://*.g.doubleclick.net https://*.ingest.sentry.io; script-src 'self' 'report-sample' 'unsafe-inline' 'unsafe-eval' blob: browser.sentry-cdn.com https://*.googletagmanager.com; img-src 'self' 'report-sample' data: https://*.google-analytics.com https://*.googletagmanager.com https://*.google.com; style-src 'self' 'report-sample' 'unsafe-inline'"), (b'Content-Type', b'application/json'), (b'Date', b'Sat, 14 Dec 2024 07:53:10 GMT'), (b'Referrer-Policy', b'same-origin'), (b'Server', b'Caddy'), (b'Server', b'WSGIServer/0.2 CPython/3.10.12'), (b'Set-Cookie', b'sessionid=eyJ1aWQiOiIxNDkwMDlhYS04OWE5LTQ5ZWMtYTBjZS1mMjBkMWFhMDU2NDIiLCJvcmdhbml6YXRpb25fcGsiOjF9:1tMMxa:y7vc_HdZynRUHUjnijbktOZAeBHXIx1_fVZzJZ4_Nqc; expires=Sat, 28 Dec 2024 07:53:10 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax'), (b'Vary', b'Accept-Language, Cookie, Origin'), (b'X-Content-Type-Options', b'nosniff')]) +2024-12-14T07:53:11.655Z - httpx - INFO - HTTP Request: GET https://labeler.e4e.ucsd.edu/api/projects/10/ "HTTP/1.1 200 OK" +2024-12-14T07:53:11.655Z - httpcore.http11 - DEBUG - receive_response_body.started request= +2024-12-14T07:53:11.656Z - httpcore.http11 - DEBUG - receive_response_body.complete +2024-12-14T07:53:11.656Z - httpcore.http11 - DEBUG - response_closed.started +2024-12-14T07:53:11.656Z - httpcore.http11 - DEBUG - response_closed.complete