Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/origin.py
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 2021-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from datetime import datetime | from datetime import datetime | ||||
from itertools import islice | from itertools import islice | ||||
import logging | import logging | ||||
from typing import Generator, Iterable, Iterator, List, Optional, Tuple | from typing import Generator, Iterable, Iterator, List, Optional, Tuple | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | for idx, revision in enumerate(origin.revisions): | ||||
LOGGER.debug("Revision added") | LOGGER.debug("Revision added") | ||||
# head is treated separately | # head is treated separately | ||||
LOGGER.debug("Checking preferred origin") | LOGGER.debug("Checking preferred origin") | ||||
check_preferred_origin(provenance, origin, revision) | check_preferred_origin(provenance, origin, revision) | ||||
LOGGER.debug("Adding revision to origin") | LOGGER.debug("Adding revision to origin") | ||||
provenance.revision_add_to_origin(origin, revision) | provenance.revision_add_to_origin(origin, revision) | ||||
cache_flush_start = datetime.now() | |||||
if provenance.flush_if_necessary(): | |||||
LOGGER.info( | |||||
"Intermediate cache flush in %s", (datetime.now() - cache_flush_start) | |||||
vlorentz: saves a syscall when unnecessary | |||||
Done Inline Actionsnvm, I misunderstood that the point was to time the function in the conditional vlorentz: nvm, I misunderstood that the point was to time the function in the conditional | |||||
) | |||||
end = datetime.now() | end = datetime.now() | ||||
LOGGER.info("Processed origin %s in %s", origin.url, (end - start)) | LOGGER.info("Processed origin %s in %s", origin.url, (end - start)) | ||||
@statsd.timed(metric=ORIGIN_DURATION_METRIC, tags={"method": "process_revision"}) | @statsd.timed(metric=ORIGIN_DURATION_METRIC, tags={"method": "process_revision"}) | ||||
def origin_add_revision( | def origin_add_revision( | ||||
provenance: ProvenanceInterface, | provenance: ProvenanceInterface, | ||||
origin: OriginEntry, | origin: OriginEntry, | ||||
Show All 28 Lines |
saves a syscall when unnecessary