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

Fix minor bugs - dependency error #110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bdc_collection_builder/collections/landsat/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# 3rdparty
from glob import glob as resource_glob
from psycopg2 import InternalError
from requests import get as resource_get
from sqlalchemy.exc import InvalidRequestError

Expand All @@ -17,6 +16,7 @@
from bdc_collection_builder.collections.landsat.download import download_landsat_images
from bdc_collection_builder.collections.landsat.publish import publish
from bdc_collection_builder.collections.utils import get_task_activity
from bdc_collection_builder.db import db_aws


class LandsatTask(RadcorTask):
Expand Down Expand Up @@ -78,8 +78,17 @@ def publish(self, scene):

try:
assets = publish(self.get_collection_item(activity_history.activity), activity_history.activity)
except InvalidRequestError as e:
# Error related with Transacion on AWS
# TODO: Is it occurs on local instance?
logging.error("Transaction Error on activity - {}".format(activity_history.activity_id), exc_info=True)

db_aws.session.rollback()

raise e

except BaseException as e:
logging.error('An error occurred during task execution', e)
logging.error("An error occurred during task execution - {}".format(activity_history.activity_id), exc_info=True)

raise e

Expand Down Expand Up @@ -171,7 +180,7 @@ def atm_correction_landsat(scene):
return atm_correction_landsat.correction(scene)


@celery_app.task(base=LandsatTask, queue='publish', max_retries=3, autoretry_for=(InternalError, InvalidRequestError,), default_retry_delay=Config.TASK_RETRY_DELAY)
@celery_app.task(base=LandsatTask, queue='publish', max_retries=3, autoretry_for=(InvalidRequestError,), default_retry_delay=Config.TASK_RETRY_DELAY)
def publish_landsat(scene):
return publish_landsat.publish(scene)

Expand Down
14 changes: 11 additions & 3 deletions bdc_collection_builder/collections/sentinel/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from zipfile import ZipFile

# 3rdparty
from psycopg2 import InternalError
from requests.exceptions import ConnectionError, HTTPError
from sqlalchemy.exc import InvalidRequestError

Expand All @@ -27,6 +26,7 @@
from bdc_collection_builder.collections.sentinel.download import download_sentinel_images, download_sentinel_from_creodias
from bdc_collection_builder.collections.sentinel.publish import publish
from bdc_collection_builder.collections.sentinel.correction import correction_sen2cor255, correction_sen2cor280
from bdc_collection_builder.db import db_aws


lock = lock_handler.lock('sentinel_download_lock_4')
Expand Down Expand Up @@ -226,8 +226,16 @@ def publish(self, scene):

try:
assets = publish(self.get_collection_item(activity_history.activity), activity_history.activity)
except InvalidRequestError as e:
# Error related with Transacion on AWS
# TODO: Is it occurs on local instance?
logging.error("Transaction Error on activity - {}".format(activity_history.activity_id), exc_info=True)

db_aws.session.rollback()

raise e
except BaseException as e:
logging.error('An error occurred during task execution', e)
logging.error('An error occurred during task execution - {}'.format(activity_history.activity_id), exc_info=True)
raise e

# Create new activity 'uploadS2' to continue task chain
Expand Down Expand Up @@ -291,7 +299,7 @@ def atm_correction(scene):
return atm_correction.correction(scene)


@celery_app.task(base=SentinelTask, queue='publish', max_retries=3, autoretry_for=(InternalError, InvalidRequestError,), default_retry_delay=Config.TASK_RETRY_DELAY)
@celery_app.task(base=SentinelTask, queue='publish', max_retries=3, autoretry_for=(InvalidRequestError,), default_retry_delay=Config.TASK_RETRY_DELAY)
def publish_sentinel(scene):
"""
Represents a celery task definition for handling Sentinel
Expand Down
2 changes: 1 addition & 1 deletion bdc_collection_builder/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.2.0'
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
'bdc-db @ git+git://github.com/brazil-data-cube/bdc-db.git#egg=bdc-db',
'stac @ git+git://github.com/brazil-data-cube/stac.py.git#egg=stac',
'celery[librabbitmq]>=4.3.0',
# TODO: Remove werkzeug dependency when https://github.com/noirbizarre/flask-restplus/issues/777 is fixed
'Werkzeug>=0.16,<1.0'
]

g = {}
Expand Down