Skip to content
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
31 changes: 1 addition & 30 deletions augur/application/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Any, Optional
import os
from augur.application.db.models import Config
from augur.application.db.util import execute_session_query
from augur.application.db.util import execute_session_query, convert_type_of_value

def get_development_flag_from_config():

Expand Down Expand Up @@ -109,35 +109,6 @@ def get_development_flag():
}


def convert_type_of_value(config_dict, logger=None):

data_type = config_dict["type"]

if data_type == "str" or data_type is None:
return config_dict

elif data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict

class AugurConfig():

from augur.application.db.session import DatabaseSession
Expand Down
32 changes: 1 addition & 31 deletions augur/application/db/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,11 @@
from augur.application.db.models import Config, Repo, Commit, WorkerOauth, Issue, PullRequest, PullRequestReview, ContributorsAlias,UnresolvedCommitEmail, Contributor, CollectionStatus, UserGroup, RepoGroup
from augur.tasks.util.collection_state import CollectionState
from augur.application.db import get_session, get_engine
from augur.application.db.util import execute_session_query
from augur.application.db.util import execute_session_query, convert_type_of_value
from augur.application.db.session import remove_duplicates_by_uniques, remove_null_characters_from_list_of_dicts

logger = logging.getLogger("db_lib")

def convert_type_of_value(config_dict, logger=None):


data_type = config_dict["type"]

if data_type == "str" or data_type is None:
return config_dict

if data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict


def get_section(section_name) -> dict:
"""Get a section of data from the config.
Expand Down Expand Up @@ -197,7 +167,7 @@

try:
working_commits = fetchall_data_from_sql_text(query)
except:

Check warning on line 170 in augur/application/db/lib.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0702: No exception type(s) specified (bare-except) Raw Output: augur/application/db/lib.py:170:4: W0702: No exception type(s) specified (bare-except)
working_commits = []

return working_commits
Expand All @@ -213,7 +183,7 @@

try:
missing_commit_hashes = fetchall_data_from_sql_text(fetch_missing_hashes_sql)
except:

Check warning on line 186 in augur/application/db/lib.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0702: No exception type(s) specified (bare-except) Raw Output: augur/application/db/lib.py:186:4: W0702: No exception type(s) specified (bare-except)
missing_commit_hashes = []

return missing_commit_hashes
Expand All @@ -233,7 +203,7 @@
return session.query(CollectionStatus).filter(getattr(CollectionStatus,f"{collection_type}_status" ) == CollectionState.COLLECTING.value).count()


def facade_bulk_insert_commits(logger, records):

Check warning on line 206 in augur/application/db/lib.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name) Raw Output: augur/application/db/lib.py:206:31: W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name)

with get_session() as session:

Expand Down Expand Up @@ -283,7 +253,7 @@
raise e


def batch_insert_contributors(logger, data: Union[List[dict], dict]) -> Optional[List[dict]]:

Check warning on line 256 in augur/application/db/lib.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name) Raw Output: augur/application/db/lib.py:256:30: W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name)

batch_size = 1000

Expand All @@ -294,7 +264,7 @@



def bulk_insert_dicts(logger, data: Union[List[dict], dict], table, natural_keys: List[str], return_columns: Optional[List[str]] = None, string_fields: Optional[List[str]] = None, on_conflict_update:bool = True) -> Optional[List[dict]]:

Check warning on line 267 in augur/application/db/lib.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name) Raw Output: augur/application/db/lib.py:267:22: W0621: Redefining name 'logger' from outer scope (line 19) (redefined-outer-name)

if isinstance(data, list) is False:

Expand Down
30 changes: 30 additions & 0 deletions augur/application/db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,40 @@
row_dict = row.__dict__
try:
del row_dict['_sa_instance_state']
except:

Check warning on line 54 in augur/application/db/util.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0702: No exception type(s) specified (bare-except) Raw Output: augur/application/db/util.py:54:8: W0702: No exception type(s) specified (bare-except)
pass

new_list.append(row_dict)

return new_list



def convert_type_of_value(config_dict, logger=None):

data_type = config_dict["type"]

if data_type == "str" or data_type is None:

Check warning on line 67 in augur/application/db/util.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return) Raw Output: augur/application/db/util.py:67:4: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
return config_dict

elif data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict
2 changes: 1 addition & 1 deletion augur/application/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def get_all_repos_count(**kwargs):

result = controller.get_repo_count(source="all", **kwargs)

return result
return result
Loading