def main(): # print(json.load(Path("/github/workspace/files.json").open("r"))) # print(os.environ.get("INPUT_PROJECT_ID")) print(Path.home()) print("#==========================================#") print(os.getenv("WORKSPACE")) print("#==========================================#") # requirements_path = str(Path("/github/workspace/requirements-dev.txt")) # subprocess.call(f"pip install -r {requirements_path}", shell=True) ### json with information of .basedosdados/config.toml config_dict = { "metadata_path": str(Path("/github") / "workspace" / "bases"), "templates_path": str(Path.home() / ".basedosdados" / "templates"), "bucket_name": "basedosdados-dev", "gcloud-projects": { "staging": { "name": "basedosdados-dev", "credentials_path": str(Path.home() / ".basedosdados" / "credentials" / "staging.json"), }, "prod": { "name": "basedosdados-dev", "credentials_path": str(Path.home() / ".basedosdados" / "credentials" / "prod.json"), }, }, } print("####===================================================###") print(config_dict) print("####===================================================###") # ### load the secret of prod and staging data env_prod = os.getenv("DEV_PROD") env_staging = os.getenv("DEV_STAG") # ### create config and credential folders create_config_tree(env_prod, env_staging, config_dict) ### create templates at config path Base()._refresh_templates() print( "\n", Path(Path.home() / ".basedosdados" / "config.toml").open(mode="r").read(), "\n", ) ### Assert config files have been created assert (Path.home() / ".basedosdados" / "config.toml").is_file() assert (Path.home() / ".basedosdados" / "credentials" / "prod.json").is_file() assert (Path.home() / ".basedosdados" / "credentials" / "staging.json").is_file()
def load_configs(dataset_id, table_id): ### get the config file in .basedosdados/config.toml configs_path = Base()._load_config() ### get the path to metadata_path, where the folder bases with metadata information metadata_path = configs_path["metadata_path"] ### get the path to table_config.yaml table_path = f"{metadata_path}/{dataset_id}/{table_id}" return ( ### load the table_config.yaml yaml.load(open(f"{table_path}/table_config.yaml", "r"), Loader=yaml.FullLoader), ### return the path to .basedosdados configs configs_path, )
def credentials(from_file=False, reauth=False): SCOPES = [ "https://www.googleapis.com/auth/cloud-platform", ] if from_file: return Base()._load_credentials(mode="prod") else: if reauth: return pydata_google_auth.get_user_credentials( SCOPES, credentials_cache=pydata_google_auth.cache.REAUTH) else: return pydata_google_auth.get_user_credentials(SCOPES, )
def init_refresh_templates(ctx): Base(**ctx.obj)._refresh_templates()
def init_overwrite_cli_config(ctx): Base(overwrite_cli_config=True, **ctx.obj)