Skip to content

Commit 772c3c1

Browse files
author
shrey
committed
add: docstrings to setup connection functions; remove: aws region class
1 parent e53984b commit 772c3c1

4 files changed

Lines changed: 24 additions & 48 deletions

File tree

datashuttle/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from datashuttle.datashuttle_class import DataShuttle
44
from datashuttle.datashuttle_functions import quick_validate_project
5-
from datashuttle.configs.aws_regions import AWS_REGION
65

76

87
try:

datashuttle/configs/aws_regions.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,3 @@ def get_aws_regions() -> Dict[str, str]:
4141

4242
def get_aws_regions_list() -> List[str]:
4343
return list(get_aws_regions().values())
44-
45-
46-
AWS_REGIONS_DICT = get_aws_regions() # runtime constant
47-
48-
49-
class AWS_REGION:
50-
"""
51-
A class to represent AWS regions as constants.
52-
It is used to provide intellisense for AWS regions in IDEs.
53-
"""
54-
55-
US_EAST_1 = AWS_REGIONS_DICT["US_EAST_1"]
56-
US_EAST_2 = AWS_REGIONS_DICT["US_EAST_2"]
57-
US_WEST_1 = AWS_REGIONS_DICT["US_WEST_1"]
58-
US_WEST_2 = AWS_REGIONS_DICT["US_WEST_2"]
59-
CA_CENTRAL_1 = AWS_REGIONS_DICT["CA_CENTRAL_1"]
60-
EU_WEST_1 = AWS_REGIONS_DICT["EU_WEST_1"]
61-
EU_WEST_2 = AWS_REGIONS_DICT["EU_WEST_2"]
62-
EU_WEST_3 = AWS_REGIONS_DICT["EU_WEST_3"]
63-
EU_NORTH_1 = AWS_REGIONS_DICT["EU_NORTH_1"]
64-
EU_SOUTH_1 = AWS_REGIONS_DICT["EU_SOUTH_1"]
65-
EU_CENTRAL_1 = AWS_REGIONS_DICT["EU_CENTRAL_1"]
66-
AP_SOUTHEAST_1 = AWS_REGIONS_DICT["AP_SOUTHEAST_1"]
67-
AP_SOUTHEAST_2 = AWS_REGIONS_DICT["AP_SOUTHEAST_2"]
68-
AP_NORTHEAST_1 = AWS_REGIONS_DICT["AP_NORTHEAST_1"]
69-
AP_NORTHEAST_2 = AWS_REGIONS_DICT["AP_NORTHEAST_2"]
70-
AP_NORTHEAST_3 = AWS_REGIONS_DICT["AP_NORTHEAST_3"]
71-
AP_SOUTH_1 = AWS_REGIONS_DICT["AP_SOUTH_1"]
72-
AP_EAST_1 = AWS_REGIONS_DICT["AP_EAST_1"]
73-
SA_EAST_1 = AWS_REGIONS_DICT["SA_EAST_1"]
74-
IL_CENTRAL_1 = AWS_REGIONS_DICT["IL_CENTRAL_1"]
75-
ME_SOUTH_1 = AWS_REGIONS_DICT["ME_SOUTH_1"]
76-
AF_SOUTH_1 = AWS_REGIONS_DICT["AF_SOUTH_1"]
77-
CN_NORTH_1 = AWS_REGIONS_DICT["CN_NORTH_1"]
78-
CN_NORTHWEST_1 = AWS_REGIONS_DICT["CN_NORTHWEST_1"]
79-
US_GOV_EAST_1 = AWS_REGIONS_DICT["US_GOV_EAST_1"]
80-
US_GOV_WEST_1 = AWS_REGIONS_DICT["US_GOV_WEST_1"]
81-
82-
@classmethod
83-
def get_all_regions(cls):
84-
return [
85-
value
86-
for key, value in vars(cls).items()
87-
if not key.startswith("__") and isinstance(value, str)
88-
]

datashuttle/configs/canonical_configs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def get_canonical_configs() -> dict:
4949
"gdrive_root_folder_id": Optional[str],
5050
"aws_access_key_id": Optional[str],
5151
"aws_region": Optional[Literal[*get_aws_regions_list()]],
52-
# "aws_s3_endpoint_url": Optional[str],
5352
}
5453

5554
return canonical_configs

datashuttle/datashuttle_class.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,20 @@ def write_public_key(self, filepath: str) -> None:
901901

902902
@check_configs_set
903903
def setup_google_drive_connection(self) -> None:
904+
"""
905+
Setup a connection to Google Drive using the provided credentials.
906+
Assumes `gdrive_root_folder_id` is set in configs.
907+
908+
First, the user will be prompted to enter their Google Drive client
909+
secret if `gdrive_client_id` is set in the configs.
910+
911+
Next, the user will be asked if their machine has access to a browser.
912+
If not, they will be prompted to input a config_token after running an
913+
rclone command displayed to the user on a machine with access to a browser.
914+
915+
Next, with the provided credentials, the final setup will be done. This
916+
opens up a browser if the user confirmed access to a browser.
917+
"""
904918
self._start_log(
905919
"setup-google-drive-connection-to-central-server",
906920
local_vars=locals(),
@@ -912,7 +926,6 @@ def setup_google_drive_connection(self) -> None:
912926
gdrive_client_secret = None
913927

914928
browser_available = gdrive.ask_user_for_browser(log=True)
915-
config_token = None
916929

917930
if not browser_available:
918931
config_token = gdrive.prompt_and_get_config_token(
@@ -921,6 +934,8 @@ def setup_google_drive_connection(self) -> None:
921934
self.cfg.get_rclone_config_name("gdrive"),
922935
log=True,
923936
)
937+
else:
938+
config_token = None
924939

925940
self._setup_rclone_gdrive_config(
926941
gdrive_client_secret, config_token, log=True
@@ -937,6 +952,14 @@ def setup_google_drive_connection(self) -> None:
937952
@requires_aws_configs
938953
@check_configs_set
939954
def setup_aws_connection(self) -> None:
955+
"""
956+
Setup a connection to AWS S3 buckets using the provided credentials.
957+
Assumes `aws_access_key_id` and `aws_region` are set in configs.
958+
959+
First, the user will be prompted to input their AWS secret access key.
960+
961+
Next, with the provided credentials, the final connection setup will be done.
962+
"""
940963
self._start_log(
941964
"setup-aws-connection-to-central-server",
942965
local_vars=locals(),

0 commit comments

Comments
 (0)