2020# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222
23- from datetime import datetime
2423from scanpipe .pipes import federatedcode
2524
26- from minecode_pipelines import pipes
2725from minecode_pipelines .pipelines import MineCodeBasePipeline
28- from minecode_pipelines .pipes .swift import PACKAGE_BATCH_SIZE , mine_swift_packageurls
26+ from minecode_pipelines .pipes .swift import mine_swift_packageurls
2927from minecode_pipelines .pipes .swift import load_swift_package_urls
30- from minecode_pipelines .pipelines import _mine_and_publish_packageurls
3128
3229
3330class MineSwift (MineCodeBasePipeline ):
3431 """
3532 Pipeline to mine Swift packages and publish them to FederatedCode.
3633 """
3734
38- pipeline_config_repo = "https://github.com/aboutcode-data/minecode-pipelines-config/"
39- checkpoint_path = "swift/checkpoints.json"
40- checkpoint_freq = 30
4135 swift_index_repo_url = "https://github.com/SwiftPackageIndex/PackageList"
4236
4337 @classmethod
4438 def steps (cls ):
4539 return (
4640 cls .check_federatedcode_eligibility ,
4741 cls .create_federatedcode_working_dir ,
48- cls .fetch_checkpoint_and_start_index ,
4942 cls .fetch_federation_config ,
5043 cls .clone_swift_index ,
5144 cls .mine_and_publish_packageurls ,
@@ -60,20 +53,6 @@ def clone_swift_index(self):
6053 logger = self .log ,
6154 )
6255
63- def fetch_checkpoint_and_start_index (self ):
64- self .checkpoint_config_repo = federatedcode .clone_repository (
65- repo_url = self .pipeline_config_repo ,
66- clone_path = self .working_path / "minecode-pipelines-config" ,
67- logger = self .log ,
68- )
69- checkpoint = pipes .get_checkpoint_from_file (
70- cloned_repo = self .checkpoint_config_repo ,
71- path = self .checkpoint_path ,
72- )
73-
74- self .start_index = checkpoint .get ("start_index" , 0 )
75- self .log (f"start_index: { self .start_index } " )
76-
7756 def packages_count (self ):
7857 return len (self .swift_packages_urls ) if self .swift_packages_urls else None
7958
@@ -82,35 +61,5 @@ def mine_packageurls(self):
8261 self .log (f"Total Swift packages to process: { len (self .swift_packages_urls )} " )
8362 return mine_swift_packageurls (
8463 packages_urls = self .swift_packages_urls ,
85- start_index = self .start_index ,
86- logger = self .log ,
87- )
88-
89- def mine_and_publish_packageurls (self ):
90- """Mine and publish PackageURLs."""
91- _mine_and_publish_packageurls (
92- packageurls = self .mine_packageurls (),
93- total_package_count = self .packages_count (),
94- data_cluster = self .data_cluster ,
95- checked_out_repos = self .checked_out_repos ,
96- working_path = self .working_path ,
97- append_purls = self .append_purls ,
98- commit_msg_func = self .commit_message ,
99- logger = self .log ,
100- checkpoint_func = self .save_check_point ,
101- checkpoint_freq = self .checkpoint_freq ,
102- )
103-
104- def save_check_point (self ):
105- checkpoint = {
106- "date" : str (datetime .now ()),
107- "start_index" : self .start_index + self .checkpoint_freq * PACKAGE_BATCH_SIZE ,
108- }
109-
110- self .log (f"Saving checkpoint: { checkpoint } " )
111- pipes .update_checkpoints_in_github (
112- checkpoint = checkpoint ,
113- cloned_repo = self .checkpoint_config_repo ,
114- path = self .checkpoint_path ,
11564 logger = self .log ,
11665 )
0 commit comments