Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exception chaining logic to remove long traceback #661

Merged
merged 1 commit into from
Nov 4, 2022
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
2 changes: 1 addition & 1 deletion skyplane/api/impl/transfer_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _transfer_pair_generator(self) -> Generator[Tuple[ObjectStoreObject, ObjectS
dest_key = self._map_object_key_prefix(self.src_prefix, obj.key, self.dst_prefix, recursive=self.recursive)
except exceptions.MissingObjectException as e:
logger.fs.exception(e)
raise e
raise e from None

# make destination object
dest_provider, dest_region = self.dst_iface.region_tag().split(":")
Expand Down
2 changes: 1 addition & 1 deletion skyplane/compute/aws/aws_cloud_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def start_instance(subnet_id: str):
break
except exceptions.ClientError as e:
if i == max_retries - 1:
raise e
raise
elif "VcpuLimitExceeded" in str(e):
raise skyplane_exceptions.InsufficientVCPUException() from e
elif "Invalid IAM Instance Profile name" not in str(e):
Expand Down
4 changes: 2 additions & 2 deletions skyplane/compute/aws/aws_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_ips_to_security_group(exceptions, self, aws_region: str, ips: Optional[L
else:
logger.error(f"[aws_network]:{aws_region} Error adding IPs {ips} to security group {sg.group_name}")
logger.fs.exception(e)
raise e
raise e from None

@imports.inject("botocore.exceptions", pip_extra="aws")
def remove_ips_from_security_group(exceptions, self, aws_region: str, ips: List[str]):
Expand Down Expand Up @@ -218,4 +218,4 @@ def add_ssh_to_security_group(exceptions, self, aws_region: str, ip: str = "0.0.
else:
logger.error(f"[aws_network]:{aws_region} Error adding SSH port {port} for IPs {ip} to security group {sg.group_name}")
logger.fs.exception(e)
raise e
raise e from None
12 changes: 6 additions & 6 deletions skyplane/compute/gcp/gcp_cloud_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def configure_skyplane_network(errors, self):
)
self.wait_for_operation_to_complete("global", op["name"])
else:
raise e
raise

@imports.inject("googleapiclient.errors", pip_extra="gcp")
def configure_skyplane_firewall(errors, self, ip="0.0.0.0/0"):
Expand All @@ -191,7 +191,7 @@ def create_firewall(body, update_firewall=False):
if e.resp.status == 404:
current_firewall = None
else:
raise e
raise

fw_body = {
"name": "skyplanessh",
Expand Down Expand Up @@ -262,7 +262,7 @@ def create_firewall(body, update_firewall=False):
if e.resp.status == 404:
current_firewall = None
else:
raise e
raise
if current_firewall is None:
create_firewall(fw_body, update_firewall=False)
logger.fs.debug(f"[GCP] Created new firewall {firewall_name}")
Expand All @@ -282,7 +282,7 @@ def remove_ips_from_firewall(errors, self, ips: List[str]):
if e.resp.status == 404: # Firewall doesnt exist. Continue
logger.fs.warning(f"[GCP] Unable to delete {firewall_name}, does not exist.")
else:
raise e
raise

def get_operation_state(self, zone, operation_name):
compute = self.auth.get_gcp_client()
Expand Down Expand Up @@ -393,9 +393,9 @@ def provision_instance(
raise exceptions.InsufficientVCPUException(f"Got QUOTA_EXCEEDED in region {region}") from e
elif "QUOTA_LIMIT" in e.content:
raise exceptions.InsufficientVCPUException(f"Got QUOTA_LIMIT in region {region}") from e
raise e
raise
except KeyboardInterrupt as e:
logger.fs.info(f"Keyboard interrupt, deleting instance {name}")
op = compute.instances().delete(project=self.auth.project_id, zone=region, instance=name).execute()
self.wait_for_operation_to_complete(region, op["name"])
raise e
raise
2 changes: 1 addition & 1 deletion skyplane/compute/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def is_api_ready():
logs, err = self.run_command(f"sudo docker logs skyplane_gateway --tail=100")
logger.fs.error(f"Docker logs: {logs}\nerr: {err}")
logger.fs.exception(e)
raise e
raise e from None
finally:
logging.disable(logging.NOTSET)

Expand Down
2 changes: 1 addition & 1 deletion skyplane/obj_store/azure_blob_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def list_objects(exceptions, self, prefix="") -> Iterator[AzureBlobObject]:
logger.error(
f"Unable to list objects in container {self.container_name} as you don't have permission to access it. You need the 'Storage Blob Data Contributor' and 'Storage Account Contributor' roles: {e}"
)
raise e
raise e from None

def delete_objects(self, keys: List[str]):
for key in keys:
Expand Down
2 changes: 1 addition & 1 deletion skyplane/obj_store/gcs_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def bucket_exists(self):
except Exception as e:
if "The specified bucket does not exist" in str(e):
return False
raise e
raise

def exists(self, obj_name):
try:
Expand Down
2 changes: 1 addition & 1 deletion skyplane/obj_store/s3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def bucket_exists(botocore_exceptions, self):
except botocore_exceptions.ClientError as e:
if e.response["Error"]["Code"] == "NoSuchBucket" or e.response["Error"]["Code"] == "AccessDenied":
return False
raise e
raise

def create_bucket(self, aws_region):
s3_client = self._s3_client(aws_region)
Expand Down
2 changes: 1 addition & 1 deletion skyplane/utils/fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def wrapped_fn(args):
return args, func(args)
except Exception as e:
logger.error(f"Error running {func.__name__}: {e}")
raise e
raise

results = []
with Progress(
Expand Down
2 changes: 1 addition & 1 deletion skyplane/utils/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def retry_backoff(
return fn()
except exception_class as e:
if i == max_retries - 1 or type(e) in always_raise_exceptions:
raise e
raise
else:
# ignore retries due to IAM instance profile propagation
if log_errors:
Expand Down