Skip to content

Commit

Permalink
fix misunderstanding in implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Isaac Milarsky <[email protected]>
  • Loading branch information
IsaacMilarky committed Feb 8, 2024
1 parent 801e5e0 commit 9a76471
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
7 changes: 3 additions & 4 deletions augur/tasks/github/detect_move/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def ping_github_for_repo_move(augur_db, key_auth, repo, logger,collection_hook='

owner, name = get_owner_repo(repo.repo_git)
url = f"https://api.github.com/repos/{owner}/{name}"
current_repo_dict = repo.__dict__

attempts = 0
while attempts < 10:
Expand Down Expand Up @@ -108,16 +107,16 @@ def ping_github_for_repo_move(augur_db, key_auth, repo, logger,collection_hook='

collectionRecord = execute_session_query(statusQuery,'one')
if collection_hook == 'core':
collectionRecord.core_status = CollectionState.STANDBY.value
collectionRecord.core_status = CollectionState.IGNORE.value
collectionRecord.core_task_id = None
collectionRecord.core_data_last_collected = datetime.today().strftime('%Y-%m-%dT%H:%M:%SZ')
elif collection_hook == 'secondary':
collectionRecord.secondary_status = CollectionState.STANDBY.value
collectionRecord.secondary_status = CollectionState.IGNORE.value
collectionRecord.secondary_task_id = None
collectionRecord.secondary_data_last_collected = datetime.today().strftime('%Y-%m-%dT%H:%M:%SZ')

augur_db.session.commit()

raise Exception("ERROR: Repo has moved! Marked repo as standby and stopped collection")
raise Exception("ERROR: Repo has moved! Marked repo as IGNORE and stopped collection!")


4 changes: 2 additions & 2 deletions augur/tasks/init/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def setup_periodic_tasks(sender, **kwargs):
"""
from celery.schedules import crontab
from augur.tasks.start_tasks import augur_collection_monitor, augur_collection_update_weights
from augur.tasks.start_tasks import non_repo_domain_tasks, retry_404_repos
from augur.tasks.start_tasks import non_repo_domain_tasks, retry_errored_repos
from augur.tasks.git.facade_tasks import clone_repos
from augur.tasks.db.refresh_materialized_views import refresh_materialized_views
from augur.tasks.data_analysis.contributor_breadth_worker.contributor_breadth_worker import contributor_breadth_model
Expand All @@ -227,7 +227,7 @@ def setup_periodic_tasks(sender, **kwargs):
sender.add_periodic_task(crontab(hour=0, minute=0),augur_collection_update_weights.s())

logger.info(f"Setting 404 repos to be marked for retry on midnight each day")
sender.add_periodic_task(crontab(hour=0, minute=0),retry_404_repos.s())
sender.add_periodic_task(crontab(hour=0, minute=0),retry_errored_repos.s())

logger.info(f"Scheduling contributor breadth every 30 days")
thirty_days_in_seconds = 30*24*60*60
Expand Down
10 changes: 5 additions & 5 deletions augur/tasks/start_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ def augur_collection_update_weights():
#git_update_commit_count_weight(repo_git)

@celery.task
def retry_404_repos():
def retry_errored_repos():
from augur.tasks.init.celery_app import engine
logger = logging.getLogger(create_collection_status_records.__name__)

with DatabaseSession(logger,engine) as session:
query = s.sql.text(f"""UPDATE repo SET secondary_staus = {CollectionState.STANDBY.value}"""
f""" WHERE secondary_status = '{CollectionState.PENDING.value}' ;"""
f"""UPDATE repo SET core_status = {CollectionState.STANDBY.value}"""
f""" WHERE core_status = '{CollectionState.PENDING.value}' ;"""
query = s.sql.text(f"""UPDATE repo SET secondary_staus = {CollectionState.PENDING.value}"""
f""" WHERE secondary_status = '{CollectionState.ERROR.value}' ;"""
f"""UPDATE repo SET core_status = {CollectionState.PENDING.value}"""
f""" WHERE core_status = '{CollectionState.ERROR.value}' ;"""
)

session.execute_sql(query)
Expand Down
1 change: 1 addition & 0 deletions augur/tasks/util/collection_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ class CollectionState(Enum):
UPDATE = "Update"
FAILED_CLONE = "Failed Clone"
STANDBY = "Standby"
IGNORE = "Ignore"

0 comments on commit 9a76471

Please sign in to comment.