Skip to content

Commit 6be2304

Browse files
authored
Merge pull request #801 from aboutcode-org/maven-fix
Fix maven pipeline failure when there is no new increment to mine
2 parents 785907d + 4ff70e1 commit 6be2304

File tree

15 files changed

+37
-40
lines changed

15 files changed

+37
-40
lines changed

minecode/management/commands/defederate_packages.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,4 @@ def handle(self, *args, **options):
7575
repo = repo_data.get("repo")
7676
for purl in yield_purls_from_yaml_files(repo.working_dir):
7777
# TODO: use batch create for efficiency
78-
package = packagedb_models.Package.objects.create(
79-
**purl.to_dict()
80-
)
78+
package = packagedb_models.Package.objects.create(**purl.to_dict())

minecode/management/commands/federate_packages.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import logging
1111
import sys
12-
from aboutcode import hashid
1312

1413
from aboutcode.federated import DataFederation
1514
from scanpipe.pipes import federatedcode
@@ -69,7 +68,7 @@ def handle(self, *args, **options):
6968
# TODO: do something more efficient
7069
files_to_commit = []
7170
commit_batch = 1
72-
files_per_commit=PACKAGE_BATCH_SIZE
71+
files_per_commit = PACKAGE_BATCH_SIZE
7372
for package in packagedb_models.Package.objects.all():
7473
package_repo, datafile_path = data_cluster.get_datafile_repo_and_path(purl=package.purl)
7574
purl_file = pipes.write_packageurls_to_file(

minecode_pipelines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
#
99

1010

11-
VERSION = "0.1.0"
11+
VERSION = "0.1.1"

minecode_pipelines/miners/cpan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ def get_cpan_packages(cpan_repo=CPAN_REPO, logger=None):
3535
packages_archive = get_temp_file(file_name="cpan_packages", extension=".gz")
3636
packages_content = get_temp_file(file_name="cpan_packages", extension=".txt")
3737
response = requests.get(cpan_packages_url, stream=True)
38-
with open(packages_archive, 'wb') as f:
38+
with open(packages_archive, "wb") as f:
3939
for chunk in response.iter_content(chunk_size=8192):
4040
f.write(chunk)
4141

4242
with gzip.open(packages_archive, "rb") as f_in:
4343
with open(packages_content, "wb") as f_out:
4444
f_out.writelines(f_in)
4545

46-
with open(packages_content, 'r', encoding='utf-8') as file:
46+
with open(packages_content, encoding="utf-8") as file:
4747
packages_content = file.read()
4848

4949
package_path_by_name = {}

minecode_pipelines/pipelines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _mine_and_publish_packageurls(
196196

197197
if len(checkout["file_to_commit"]) > batch_size:
198198
if logger:
199-
logger(f"Trying to commit PackageURLs.")
199+
logger("Trying to commit PackageURLs.")
200200
pipes.commit_and_push_checkout(
201201
local_checkout=checkout,
202202
commit_message=commit_msg_func(checkout["commit_count"] + 1),

minecode_pipelines/pipelines/mine_cpan.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222

2323

24-
from minecode_pipelines import pipes
2524
from minecode_pipelines.pipes import cpan
2625
from minecode_pipelines.pipelines import MineCodeBasePipeline
27-
from scanpipe.pipes import federatedcode
2826

2927

3028
class MineCpan(MineCodeBasePipeline):
@@ -57,4 +55,3 @@ def mine_packageurls(self):
5755
package_path_by_name=self.cpan_packages_path_by_name,
5856
logger=self.log,
5957
)
60-

minecode_pipelines/pipelines/mine_maven.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def steps(cls):
4343
cls.fetch_federation_config,
4444
cls.fetch_checkpoint_and_maven_index,
4545
cls.mine_and_publish_maven_packageurls,
46+
cls.save_check_point,
4647
cls.delete_working_dir,
4748
)
4849

@@ -59,7 +60,10 @@ def fetch_checkpoint_and_maven_index(self):
5960

6061
last_incremental = checkpoint.get("last_incremental")
6162
self.log(f"last_incremental: {last_incremental}")
62-
self.maven_nexus_collector = maven.MavenNexusCollector(last_incremental=last_incremental)
63+
self.maven_nexus_collector = maven.MavenNexusCollector(
64+
last_incremental=last_incremental,
65+
logger=self.log,
66+
)
6367

6468
def mine_and_publish_maven_packageurls(self):
6569
_mine_and_publish_packageurls(
@@ -71,7 +75,6 @@ def mine_and_publish_maven_packageurls(self):
7175
append_purls=self.append_purls,
7276
commit_msg_func=self.commit_message,
7377
logger=self.log,
74-
checkpoint_func=self.save_check_point,
7578
)
7679

7780
def save_check_point(self):

minecode_pipelines/pipelines/mine_npm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def steps(cls):
4848

4949
def mine_npm_packages(self):
5050
"""Mine npm package names from npm indexes or checkpoint."""
51-
(
52-
self.npm_packages, self.state, self.last_seq, self.config_repo
53-
) = npm.mine_npm_packages(logger=self.log)
51+
(self.npm_packages, self.state, self.last_seq, self.config_repo) = npm.mine_npm_packages(
52+
logger=self.log
53+
)
5454

5555
def get_npm_packages_to_sync(self):
5656
"""Get npm packages which needs to be synced using checkpoint."""

minecode_pipelines/pipes/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def get_mined_packages_from_checkpoint(config_repo, checkpoint_path):
103103
return checkpoint.get("packages_mined", [])
104104

105105

106-
def update_mined_packages_in_checkpoint(packages, config_repo, cloned_repo, checkpoint_path, logger=None):
106+
def update_mined_packages_in_checkpoint(
107+
packages, config_repo, cloned_repo, checkpoint_path, logger=None
108+
):
107109
mined_packages = get_mined_packages_from_checkpoint(
108110
config_repo=config_repo,
109111
checkpoint_path=checkpoint_path,

minecode_pipelines/pipes/cran.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
import json
2424
from pathlib import Path
25-
from typing import Iterable
26-
from typing import Tuple
27-
from typing import List
25+
from collections.abc import Iterable
2826

2927
import requests
3028
from packageurl import PackageURL
@@ -49,7 +47,7 @@ def fetch_cran_db(working_path, logger) -> Path:
4947
return output_path
5048

5149

52-
def mine_cran_packageurls(db_path: Path) -> Iterable[Tuple[str, List[str]]]:
50+
def mine_cran_packageurls(db_path: Path) -> Iterable[tuple[str, list[str]]]:
5351
"""
5452
Extract package names and their versions from a CRAN DB JSON file.
5553
Yields a tuple: (base_purl, list_of_purls)

0 commit comments

Comments
 (0)