Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show First 20 Lines • Show All 603 Lines • ▼ Show 20 Lines | def load(self) -> Dict: | ||||
snapshot=snapshot, | snapshot=snapshot, | ||||
visit=visit, | visit=visit, | ||||
failed_branches=failed_branches, | failed_branches=failed_branches, | ||||
status_visit="failed", | status_visit="failed", | ||||
status_load="failed", | status_load="failed", | ||||
errors=[str(e)], | errors=[str(e)], | ||||
) | ) | ||||
errors = [] | |||||
# Get the metadata of each version's package | # Get the metadata of each version's package | ||||
packages_info: List[Tuple[str, TPackageInfo]] = [ | packages_info: List[Tuple[str, TPackageInfo]] = [] | ||||
(branch_name, p_info) | for version in versions: | ||||
for version in versions | try: | ||||
for (branch_name, p_info) in self.get_package_info(version) | for branch_name, p_info in self.get_package_info(version): | ||||
] | packages_info.append((branch_name, p_info)) | ||||
except Exception as e: | |||||
load_exceptions.append(e) | |||||
sentry_sdk.capture_exception(e) | |||||
error = f"Failed to get package info for version {version} of {self.origin.url}" | |||||
logger.exception(error) | |||||
errors.append(f"{error}: {e}") | |||||
# Compute the ExtID of each of these packages | # Compute the ExtID of each of these packages | ||||
known_extids = self._get_known_extids([p_info for (_, p_info) in packages_info]) | known_extids = self._get_known_extids([p_info for (_, p_info) in packages_info]) | ||||
if last_snapshot is None: | if last_snapshot is None: | ||||
last_snapshot_targets: Set[Sha1Git] = set() | last_snapshot_targets: Set[Sha1Git] = set() | ||||
else: | else: | ||||
last_snapshot_targets = { | last_snapshot_targets = { | ||||
branch.target for branch in last_snapshot.branches.values() | branch.target for branch in last_snapshot.branches.values() | ||||
} | } | ||||
new_extids: Set[ExtID] = set() | new_extids: Set[ExtID] = set() | ||||
tmp_releases: Dict[str, List[Tuple[str, Sha1Git]]] = { | tmp_releases: Dict[str, List[Tuple[str, Sha1Git]]] = { | ||||
version: [] for version in versions | version: [] for version in versions | ||||
} | } | ||||
errors = [] | |||||
for (branch_name, p_info) in packages_info: | for (branch_name, p_info) in packages_info: | ||||
logger.debug("package_info: %s", p_info) | logger.debug("package_info: %s", p_info) | ||||
# Check if the package was already loaded, using its ExtID | # Check if the package was already loaded, using its ExtID | ||||
swhid = self.resolve_object_from_extids( | swhid = self.resolve_object_from_extids( | ||||
known_extids, p_info, last_snapshot_targets | known_extids, p_info, last_snapshot_targets | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines |