-
Notifications
You must be signed in to change notification settings - Fork 62
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
[API] Performance Logging #669
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ee35cd5
modify api code to incorporate usage
JasonDing0401 406b9fa
add api usage
JasonDing0401 8712609
add requirement for gateway
JasonDing0401 a61d251
add extra test
JasonDing0401 f5cafda
better error report
JasonDing0401 8a2b2a1
change based on the request
JasonDing0401 9e42bae
reformat code
JasonDing0401 cdb7dce
change env to api
JasonDing0401 2d5bba0
store uuid locally
JasonDing0401 ba655b2
reformat code
JasonDing0401 b0322d0
remove demo copy
JasonDing0401 889b383
type check
JasonDing0401 c938fd0
minor changes
JasonDing0401 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ google-cloud-storage | |
cachetools | ||
paramiko | ||
rich | ||
typer | ||
# gateway dependencies | ||
flask | ||
lz4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,7 @@ def __init__(self, dataplane, jobs: List["TransferJob"], transfer_config: Transf | |
self.dataplane = dataplane | ||
self.type_list = set([job.type for job in jobs]) | ||
self.recursive_list = set([str(job.recursive) for job in jobs]) | ||
self.size = sum([job.calculate_size() for job in jobs]) | ||
|
||
|
||
self.jobs = {job.uuid: job for job in jobs} | ||
self.transfer_config = transfer_config | ||
|
||
|
@@ -51,7 +50,7 @@ def __str__(self): | |
def run(self): | ||
src_cloud_provider = self.dataplane.src_region_tag.split(":")[0] | ||
dst_cloud_provider = self.dataplane.dst_region_tag.split(":")[0] | ||
|
||
args = { | ||
"cmd": ",".join(self.type_list), | ||
"recursive": ",".join(self.recursive_list), | ||
|
@@ -73,51 +72,61 @@ def run(self): | |
f"[TransferProgressTracker] Job {job.uuid} dispatched with {len(self.job_chunk_requests[job_uuid])} chunk requests" | ||
) | ||
except Exception as e: | ||
UsageClient.log_exception("dispatch job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
UsageClient.log_exception( | ||
"dispatch job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, session_start_timestamp_ms | ||
) | ||
raise e | ||
|
||
# Record only the transfer time | ||
start_time = int(time.time()) | ||
try: | ||
try: | ||
self.monitor_transfer() | ||
except exceptions.SkyplaneGatewayException as err: | ||
reformat_err = Exception(err.pretty_print_str()) | ||
UsageClient.log_exception("monitor transfer", reformat_err, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
reformat_err = Exception(err.pretty_print_str()[37:]) | ||
UsageClient.log_exception( | ||
"monitor transfer", | ||
reformat_err, | ||
args, | ||
self.dataplane.src_region_tag, | ||
self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms, | ||
) | ||
raise err | ||
except Exception as e: | ||
UsageClient.log_exception("monitor transfer", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
UsageClient.log_exception( | ||
"monitor transfer", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, session_start_timestamp_ms | ||
) | ||
raise e | ||
end_time = int(time.time()) | ||
|
||
try: | ||
for job in self.jobs.values(): | ||
logger.fs.debug(f"[TransferProgressTracker] Finalizing job {job.uuid}") | ||
job.finalize() | ||
except Exception as e: | ||
UsageClient.log_exception("finalize job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
UsageClient.log_exception( | ||
"finalize job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, session_start_timestamp_ms | ||
) | ||
raise e | ||
|
||
try: | ||
for job in self.jobs.values(): | ||
logger.fs.debug(f"[TransferProgressTracker] Verifying job {job.uuid}") | ||
job.verify() | ||
except Exception as e: | ||
UsageClient.log_exception("verify job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
UsageClient.log_exception( | ||
"verify job", e, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, session_start_timestamp_ms | ||
) | ||
raise e | ||
|
||
# transfer successfully completed | ||
transfer_stats = { | ||
"total_runtime_s": end_time - start_time, | ||
"throughput_gbits": self.size / (end_time - start_time), | ||
"throughput_gbits": self.calculate_size() / (end_time - start_time), | ||
} | ||
UsageClient.log_transfer(transfer_stats, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, | ||
session_start_timestamp_ms) | ||
|
||
UsageClient.log_transfer( | ||
transfer_stats, args, self.dataplane.src_region_tag, self.dataplane.dst_region_tag, session_start_timestamp_ms | ||
) | ||
|
||
@imports.inject("pandas") | ||
def monitor_transfer(pd, self): | ||
|
@@ -203,3 +212,17 @@ def query_bytes_remaining(self): | |
) | ||
logger.fs.debug(f"[TransferProgressTracker] Bytes remaining per job: {bytes_remaining_per_job}") | ||
return sum(bytes_remaining_per_job.values()) | ||
|
||
def calculate_size(self): | ||
if len(self.job_chunk_requests) == 0: | ||
return 0 | ||
bytes_total_per_job = {} | ||
for job_uuid in self.job_complete_chunk_ids.keys(): | ||
bytes_total_per_job[job_uuid] = sum( | ||
[ | ||
cr.chunk.chunk_length_bytes | ||
for cr in self.job_chunk_requests[job_uuid] | ||
if cr.chunk.chunk_id in self.job_complete_chunk_ids[job_uuid] | ||
] | ||
) | ||
return sum(bytes_total_per_job.values()) / (2**30) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory there shouldn't be collisions between clouds but maybe should we index it as ("aws", "us-east-1") instead?