Skip to content

Commit

Permalink
Logs format improvements (#1539)
Browse files Browse the repository at this point in the history
* Improved logs from 708

* Updated logs from 707

* Add brackets to the logs following other patterns
  • Loading branch information
Tansito authored Nov 21, 2024
1 parent 92267ce commit 67ddfbb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gateway/api/management/commands/schedule_queued_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def schedule_jobs_if_slots_available(
succeed = True
except RecordModifiedError:
logger.warning(
"Schedule: Job[%s] record has not been updated due to lock.",
"Schedule: Job [%s] record has not been updated due to lock.",
job.id,
)

Expand Down
2 changes: 1 addition & 1 deletion gateway/api/management/commands/update_jobs_statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def handle(self, *args, **options):
job.save()
except RecordModifiedError:
logger.warning(
"Job[%s] record has not been updated due to lock.", job.id
"Job [%s] record has not been updated due to lock.", job.id
)

else:
Expand Down
2 changes: 1 addition & 1 deletion gateway/api/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def submit(self, job: Job) -> Optional[str]:
encoding="utf-8",
) as f:
if job.arguments:
logger.debug("uploading arguments for job %s", job.id)
logger.debug("uploading arguments for job [%s]", job.id)
f.write(job.arguments)
else:
f.write({})
Expand Down
2 changes: 1 addition & 1 deletion gateway/api/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def execute_job(job: Job) -> Job:
job.program.provider
and job.program.provider.name in gpujobs["gpu-functions"].keys()
):
logger.debug("Job %s will be run on GPU nodes", job.id)
logger.debug("Job [%s] will be run on GPU nodes", job.id)
job.gpu = True
job.save()

Expand Down
4 changes: 2 additions & 2 deletions gateway/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def build_env_variables(token, job: Job, args: str = None) -> Dict[str, str]:
arguments = "{}"
if args:
if objsize.get_deep_size(args) < 100000:
logger.debug("passing arguments as envvar for job %s", job.id)
logger.debug("passing arguments as env_var for job [%s]", job.id)
arguments = args
else:
logger.warning(
"arguments for job %s are too large and will not be written to env var",
"arguments for job [%s] are too large and will not be written to env_var",
job.id,
)

Expand Down
3 changes: 1 addition & 2 deletions gateway/api/views/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ def result(self, request, pk=None): # pylint: disable=invalid-name,unused-argum
saved = True
except RecordModifiedError:
logger.warning(
"Job[%s] record has not been updated due to lock. "
"Retrying. Attempts left %s",
"Job [%s] record has not been updated due to lock. Retrying. Attempts left %s", # pylint: disable=line-too-long
job.id,
attempts_left,
)
Expand Down
8 changes: 4 additions & 4 deletions gateway/api/views/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_queryset(self):

author_programs_count = author_programs.count()
logger.info(
"ProgramViewSet get author[%s] programs[%s]",
"ProgramViewSet get author [%s] programs [%s]",
author.id,
author_programs_count,
)
Expand All @@ -140,7 +140,7 @@ def get_run_queryset(self):
author_groups_with_run_permissions.count()
)
logger.info(
"ProgramViewSet get author[%s] groups [%s]",
"ProgramViewSet get author [%s] groups [%s]",
author.id,
author_groups_with_run_permissions_count,
)
Expand All @@ -155,7 +155,7 @@ def get_run_queryset(self):
).distinct()
author_programs_count = author_programs.count()
logger.info(
"ProgramViewSet get author[%s] programs[%s]",
"ProgramViewSet get author [%s] programs [%s]",
author.id,
author_programs_count,
)
Expand Down Expand Up @@ -328,7 +328,7 @@ def _get_program_queryset_for_title_and_provider(
author_groups_with_view_permissions.count()
)
logger.info(
"ProgramViewSet get author[%s] groups [%s]",
"ProgramViewSet get author [%s] groups [%s]",
author.id,
author_groups_with_view_permissions_count,
)
Expand Down

0 comments on commit 67ddfbb

Please sign in to comment.