Skip to content

Commit

Permalink
chore: better ingest logging + reduce debug logspam
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed May 22, 2024
1 parent d43efeb commit f35e8e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion chord_drs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"logger",
]

logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.NOTSET)

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Remove `DEBUG:asyncio:Using selector: EpollSelector` spam
logging.getLogger("asyncio").setLevel(logging.INFO)
# Remove `DEBUG:urllib3.connectionpool:Starting new HTTPS connection` spam
logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO)
19 changes: 14 additions & 5 deletions chord_drs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ def object_ingest():
public: bool = data.get("public", "false").strip().lower() == "true"
file = request.files.get("file")

logger.info(f"Received ingest request metadata: {data}")

# This authz call determines everything, so we can mark authz as done when the call completes:
has_permission: bool = (
authz_middleware.evaluate_one(
Expand Down Expand Up @@ -415,19 +417,26 @@ def object_ingest():
candidate_drs_object: DrsBlob | None = DrsBlob.query.filter_by(checksum=checksum).first()

if candidate_drs_object is not None:
c_project_id = candidate_drs_object.project_id
c_dataset_id = candidate_drs_object.dataset_id
c_data_type = candidate_drs_object.data_type
c_public = candidate_drs_object.public

if (
candidate_drs_object.project_id == project_id
and candidate_drs_object.dataset_id == dataset_id
and candidate_drs_object.data_type == data_type
and candidate_drs_object.public == public
c_project_id == project_id
and c_dataset_id == dataset_id
and c_data_type == data_type
and c_public == public
):
logger.info(
f"Found duplicate DRS object via checksum (will fully deduplicate): {candidate_drs_object}"
)
drs_object = candidate_drs_object
else:
logger.info(
f"Found duplicate DRS object via checksum (will deduplicate JUST bytes): "
f"Found duplicate DRS object via checksum (will deduplicate JUST bytes; req resource: "
f"({project_id}, {dataset_id}, {data_type}, {public}) vs existing resource: "
f"({c_project_id}, {c_dataset_id}, {c_data_type}, {c_public})): "
f"{candidate_drs_object}"
)
object_to_copy = candidate_drs_object
Expand Down

0 comments on commit f35e8e6

Please sign in to comment.