Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add s3 to DESY spider instead of FTP #284

Merged

Conversation

pazembrz
Copy link
Contributor

@pazembrz pazembrz commented Sep 7, 2020

Currently all additional files for record are intentionally ignored. (After discussion with Micha)

ref:inspirehep/inspirehep#1245

self.logger.error("Cannot connect to s3.", exc)
raise
return connections
def get_s3_url_for_key(self, key, bucket=None, expire=86400):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it looks like this method is not used at all. Could you check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right. It's leftover from processing additional files I did at first.

)
def crawl_s3_bucket(self):
input_bucket = self.s3_resource.Bucket(self.s3_input_bucket)
existing_files = os.listdir(self.destination_folder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would forget about the local files handling, it's not needed if you move the source files to a different bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to leave local part of spider intact, as it's not part of this task.

url=response.url
)
self.logger.info('Got %d hep records' % len(parsed_items))

if self.s3_enabled:
s3_file = response.meta['s3_file']
self.logger.info("Moving {file} to {processed} bucket and deleting {file} from {incoming} bucket.".format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.logger.info("Moving {file} to {processed} bucket and deleting {file} from {incoming} bucket.".format(
self.logger.info("Moving {file} from {incoming} bucket to {processed} bucket.".format(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pazembrz pazembrz force-pushed the #1243-add-s3-support--to-desy-spider branch from dc669ea to adaaed8 Compare September 8, 2020 09:20
@pazembrz pazembrz force-pushed the #1243-add-s3-support--to-desy-spider branch from adaaed8 to 6c78cd2 Compare September 9, 2020 08:26
@pazembrz pazembrz merged commit 1d6c9c7 into inspirehep:master Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants