-
Notifications
You must be signed in to change notification settings - Fork 0
User level resources #3
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
Changes from all commits
536a5d4
01826b4
4d1d9ca
3ea256c
baf76b0
fb438bd
7226be5
6b4093a
4334764
7743c72
8a4418b
672402b
f50a64a
7b905bc
01b4fa0
d0ba5e2
0edd8ac
9bd8de4
8945267
d8ff3d2
5c60d08
585fd56
9eb4841
bb4ab26
9148f88
e3d287a
944f768
e16fb65
a4737b2
94eef49
0616bd0
8a57758
513ebe8
d521277
3bf144e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,5 @@ | |
| ^LICENSE\.md$ | ||
| ^\.github$ | ||
| ^README\.Rmd$ | ||
| ^[\.]?air\.toml$ | ||
| ^\.vscode$ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "recommendations": [ | ||
| "Posit.air-vscode" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "[r]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.defaultFormatter": "Posit.air-vscode" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,26 @@ | ||
| # Generated by roxygen2: do not edit by hand | ||
|
|
||
| S3method(format_prom_result,default) | ||
| S3method(format_prom_result,prom_instant) | ||
| S3method(format_prom_result,prom_range) | ||
| export(aws_ce_palette) | ||
| export(ce_categories) | ||
| export(ce_to_df) | ||
| export(create_range_df) | ||
| export(dir_sizes) | ||
| export(format_prom_result) | ||
| export(get_daily_usage_costs) | ||
| export(get_daily_users) | ||
| export(get_hourly_users) | ||
| export(get_prometheus_labels) | ||
| export(get_prometheus_metrics) | ||
| export(query_hub_names) | ||
| export(query_prometheus_instant) | ||
| export(query_prometheus_range) | ||
| export(unsanitize_dir_names) | ||
| export(user_cpu_requests) | ||
| export(user_cpu_usage) | ||
| export(user_dir_snapshot) | ||
| export(user_mem_requests) | ||
| export(user_mem_usage) | ||
| importFrom(rlang,":=") | ||
| importFrom(rlang,.data) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # jupycost 0.1.0 | ||
|
|
||
| ## New Features | ||
|
|
||
| * Added `user_dir_snapshot()` function for retrieving user directory information at a point in time | ||
|
|
||
| * Added `dir_sizes()` function to query home directory sizes over time | ||
|
|
||
| * Added functions to track user CPU and memory requests and usage | ||
|
|
||
| * Added ability to query hub names and filter hubs by tags | ||
|
|
||
| * Improved Prometheus query handling with S3 classes and methods for range and instant queries | ||
|
|
||
| * Removed `create_range_df()` and use `format_prom_result()` to format results from the various prometheus query functions | ||
|
|
||
| ## Minor Improvements | ||
|
|
||
| * Updated NASA hub names | ||
|
|
||
| * Improved documentation |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |||||
| #' @param end_date A Date object representing the end of the desired date range. | ||||||
| #' @param months_back Optional. A single integer specifying how many months back to query. | ||||||
| #' @param cost_type The type of costs. "unblended" (default), "blended", or "all" | ||||||
| #' @param hub which hub (or "all") you want costs for | ||||||
| #' @param cluster which cluster ("openscapeshub" or "nmfs-openscapes") you want information for. Ensure that you are authenticated to the correct AWS account using the appropriate API keys. | ||||||
| #' | ||||||
| #' @returns | ||||||
| #' A data frame of AWS usage costs. | ||||||
|
|
@@ -11,10 +13,16 @@ | |||||
| get_daily_usage_costs <- function( | ||||||
| end_date = Sys.Date(), | ||||||
| months_back = 6, | ||||||
| cost_type = c("unblended", "blended", "all") | ||||||
| cost_type = c("unblended", "blended", "all"), | ||||||
| hub = c("all", "prod", "staging", "workshop", "support"), | ||||||
| cluster = c("openscapeshub", "nmfs-openscapes") | ||||||
| ) { | ||||||
| end_date <- check_valid_date(end_date) | ||||||
|
|
||||||
| hub <- match.arg(hub) | ||||||
|
|
||||||
| cluster = match.arg(cluster) | ||||||
|
|
||||||
| if (!rlang::is_integerish(months_back) || months_back > 12) { | ||||||
| cli::cli_abort("{.arg months_back} must be an integer <= 12.") | ||||||
| } | ||||||
|
|
@@ -26,21 +34,61 @@ get_daily_usage_costs <- function( | |||||
| unit = "month" | ||||||
| ) | ||||||
|
|
||||||
| filter_list <- list( | ||||||
| And = list( | ||||||
| list( | ||||||
| Dimensions = list( | ||||||
| Key = "RECORD_TYPE", | ||||||
| Values = list("Usage") | ||||||
| ) | ||||||
| ), | ||||||
| # TODO: figure out why attributable costs aren't being filtered for shared and individual hubs (only for all) | ||||||
| # https://github.com/2i2c-org/jupyterhub-cost-monitoring/blob/main/src/jupyterhub_cost_monitoring/query_usage.py | ||||||
| ce_filter_attributable_costs(cluster) | ||||||
| ) | ||||||
| ) | ||||||
|
|
||||||
| if (hub == "support") { | ||||||
| filter_list = list( | ||||||
|
||||||
| And = list( | ||||||
| filter_list[["And"]][[1]], | ||||||
| list( | ||||||
| Tags = list( | ||||||
| Key = "2i2c:hub-name", | ||||||
| MatchOptions = list("ABSENT") | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| ) | ||||||
| } else if (hub != "all") { | ||||||
| filter_list = list( | ||||||
|
||||||
| filter_list = list( | |
| filter_list <- list( |
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.
Assignment operator should be '<-' instead of '=' for consistency with R style guidelines.