Skip to content

Commit 8cceed7

Browse files
committed
fix the imports
Signed-off-by: Varsha U N <[email protected]>
1 parent aefd069 commit 8cceed7

File tree

3 files changed

+3
-49
lines changed

3 files changed

+3
-49
lines changed

scanpipe/pipelines/__init__.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -180,51 +180,6 @@ def download_missing_inputs(self):
180180
if error_tracebacks:
181181
raise InputFilesError(error_tracebacks)
182182

183-
def archive_downloads(self):
184-
"""
185-
Archive downloaded inputs to the centralized DownloadStore if not already
186-
archived.Updates InputSource with archiving metadata (sha256, download_date).
187-
"""
188-
logger.info(f"Archiving downloads for project {self.project.name}")
189-
for input_source in self.project.inputsources.filter(
190-
sha256__isnull=True, is_uploaded=False
191-
):
192-
if input_source.download_url:
193-
logger.warning(
194-
f"No download URL for input {input_source.filename}, "
195-
"skipping archiving"
196-
)
197-
continue
198-
199-
if not input_source.file_path:
200-
logger.warning(
201-
f"No file_path for input {input_source.download_url}, "
202-
"skipping archiving"
203-
)
204-
continue
205-
try:
206-
with open(input_source.file_path, "rb") as f:
207-
content = f.read()
208-
filename = (
209-
input_source.filename or input_source.download_url.split("/")[-1]
210-
)
211-
download = download_store.put(
212-
content=content,
213-
download_url=input_source.download_url,
214-
download_date=datetime.now().isoformat(),
215-
filename=filename,
216-
)
217-
input_source.sha256 = download.sha256
218-
input_source.download_date = download.download_date
219-
input_source.file_path = str(download.path)
220-
input_source.save()
221-
except Exception as e:
222-
self.add_error(
223-
exception=e,
224-
message=f"Failed to archive {input_source.download_url}",
225-
)
226-
227-
228183
class ProjectPipeline(CommonStepsMixin, BasePipeline):
229184
"""Main class for all project related pipelines including common steps methods."""
230185

@@ -258,7 +213,6 @@ def get_initial_steps(cls):
258213
steps = []
259214
if cls.download_inputs:
260215
steps.append(cls.download_missing_inputs)
261-
steps.append(cls.archive_downloads)
262216
return tuple(steps)
263217

264218
@classmethod

scanpipe/tests/test_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
from django.core.files.uploadedfile import SimpleUploadedFile
3131
from django.test import TestCase
32+
from django.conf import settings
3233

33-
from scancodeio.settings import settings
3434
from scanpipe.models import InputSource
3535
from scanpipe.pipes.input import add_input_from_upload
3636
from scanpipe.pipes.input import add_input_from_url

scanpipe/tests/test_pipelines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_scanpipe_pipeline_class_download_inputs_attribute(self):
185185
run = project1.add_pipeline("download_inputs")
186186
pipeline = run.make_pipeline_instance()
187187
self.assertTrue(pipeline.download_inputs)
188-
expected = (CommonStepsMixin.download_missing_inputs,)
188+
expected = (CommonStepsMixin.download_missing_inputs)
189189
self.assertEqual(expected, pipeline.get_initial_steps())
190190
expected = (CommonStepsMixin.download_missing_inputs, DownloadInput.step1)
191191
self.assertEqual(expected, pipeline.get_steps())
@@ -301,7 +301,7 @@ def test_archive_downloads(self, mock_get):
301301

302302
input_source = InputSource.objects.create(
303303
InputSource.objects.create(
304-
project=project1,
304+
project1=project1,
305305
filename=test_filename,
306306
download_url=test_url,
307307
is_uploaded=False,

0 commit comments

Comments
 (0)