Skip to content

Commit

Permalink
fix: Raise the error in decode_record fn to main in htcondor_revert_e…
Browse files Browse the repository at this point in the history
…ncodings.py & remove encoding of records for HTCondor
  • Loading branch information
raghuvar-vijay committed Jan 15, 2025
1 parent 5c19399 commit 1d20723
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
from json.decoder import JSONDecodeError
from urllib.parse import unquote

import psycopg2
Expand Down Expand Up @@ -27,8 +28,8 @@ def decode_record(record_id, meta):
decoded_meta = {
key: [unquote(value) for value in values] for key, values in meta.items()
}
except json.JSONDecodeError:
decoded_meta = {} # If JSON decoding fails, return an empty dict
except Exception as e:
raise JSONDecodeError(f"Error decoding meta: {e}", str(meta), 0)
return decoded_record_id, json.dumps(decoded_meta)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from datetime import datetime as dt
from datetime import timezone
from typing import List, Optional, Tuple
from urllib.parse import quote

from pyauditor import (
AuditorClient,
Expand Down Expand Up @@ -221,7 +220,7 @@ def _get_meta(self, job: dict) -> Meta:
for item in entry if isinstance(entry, list) else [entry]:
value = get_value(item, job)
if value is not None:
values.append(quote(value, safe=""))
values.append(value)
if key == "site": # site is a special case
break
if values:
Expand Down Expand Up @@ -260,9 +259,7 @@ def _generate_record(self, job: dict) -> Record:
meta = self._get_meta(job)

try:
record_id = (
f"{self.config.record_prefix}-{quote(job_id.encode('utf-8'), safe='')}"
)
record_id = f"{self.config.record_prefix}-{job_id}"
record = Record(
record_id=record_id,
start_time=dt.fromtimestamp(start_time, tz=timezone.utc),
Expand Down
4 changes: 3 additions & 1 deletion media/website/content/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ description = "Migration Guide"
weight = 3
+++

# From 0.6.3 to unreleased/0.7.0
# From 0.6.3 to unreleased/0.7.0

Please backup your db before proceeding with any changes that are listed below.

## Remove forbidden characters:
The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier).
Expand Down

0 comments on commit 1d20723

Please sign in to comment.