Skip to content

Commit

Permalink
feat(connector): do not update local config if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dovahcrow committed Oct 17, 2020
1 parent 9e77c52 commit cd675f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dataprep/connector/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ def config_directory() -> Path:
return Path(tmp) / "dataprep" / "connector"


def ensure_config(impdb: str) -> bool:
def ensure_config(impdb: str, update: bool) -> bool:
"""
Ensure the config for `impdb` is downloaded
"""
path = config_directory()
if (path / impdb).exists() and not update:
return True

obsolete = is_obsolete(impdb)

if (path / impdb).exists() and not obsolete:
Expand Down
6 changes: 5 additions & 1 deletion dataprep/connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Connector:
The parameters for authentication, e.g. OAuth2
_concurrency: int = 5
The concurrency setting. By default it is 1 reqs/sec.
update: bool = True
Force update the config file even if the local version exists.
**kwargs
Parameters that shared by different queries.
Expand All @@ -82,6 +84,8 @@ class Connector:
def __init__(
self,
config_path: str,
*,
update: bool = False,
_auth: Optional[Dict[str, Any]] = None,
_concurrency: int = 1,
**kwargs: Any,
Expand All @@ -94,7 +98,7 @@ def __init__(
path = Path(config_path).resolve()
else:
# From Github!
ensure_config(config_path)
ensure_config(config_path, update)
path = config_directory() / config_path

self._impdb = ImplicitDatabase(path)
Expand Down

0 comments on commit cd675f3

Please sign in to comment.