cloudos-cli 2.61.2__tar.gz → 2.62.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/PKG-INFO +149 -1
  2. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/README.md +148 -0
  3. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/__main__.py +87 -2
  4. cloudos_cli-2.62.1/cloudos_cli/_version.py +1 -0
  5. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/clos.py +0 -1
  6. cloudos_cli-2.62.1/cloudos_cli/cost/__init__.py +8 -0
  7. cloudos_cli-2.62.1/cloudos_cli/cost/cost.py +259 -0
  8. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/datasets/datasets.py +15 -14
  9. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/PKG-INFO +149 -1
  10. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/SOURCES.txt +4 -0
  11. cloudos_cli-2.62.1/tests/test_cost/test_job_cost.py +394 -0
  12. cloudos_cli-2.62.1/tests/test_logging/__init__.py +0 -0
  13. cloudos_cli-2.61.2/cloudos_cli/_version.py +0 -1
  14. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/LICENSE +0 -0
  15. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/__init__.py +0 -0
  16. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/configure/__init__.py +0 -0
  17. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/configure/configure.py +0 -0
  18. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/datasets/__init__.py +0 -0
  19. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/import_wf/__init__.py +0 -0
  20. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/import_wf/import_wf.py +0 -0
  21. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/jobs/__init__.py +0 -0
  22. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/jobs/job.py +0 -0
  23. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/link/__init__.py +0 -0
  24. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/link/link.py +0 -0
  25. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/logging/__init__.py +0 -0
  26. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/logging/logger.py +0 -0
  27. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/procurement/__init__.py +0 -0
  28. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/procurement/images.py +0 -0
  29. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/queue/__init__.py +0 -0
  30. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/queue/queue.py +0 -0
  31. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/__init__.py +0 -0
  32. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/array_job.py +0 -0
  33. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/cloud.py +0 -0
  34. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/details.py +0 -0
  35. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/errors.py +0 -0
  36. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/last_wf.py +0 -0
  37. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/requests.py +0 -0
  38. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli/utils/resources.py +0 -0
  39. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/dependency_links.txt +0 -0
  40. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/entry_points.txt +0 -0
  41. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/requires.txt +0 -0
  42. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/cloudos_cli.egg-info/top_level.txt +0 -0
  43. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/setup.cfg +0 -0
  44. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/setup.py +0 -0
  45. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/tests/__init__.py +0 -0
  46. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/tests/functions_for_pytest.py +0 -0
  47. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/tests/test_cli_project_create.py +0 -0
  48. {cloudos_cli-2.61.2/tests/test_logging → cloudos_cli-2.62.1/tests/test_cost}/__init__.py +0 -0
  49. {cloudos_cli-2.61.2 → cloudos_cli-2.62.1}/tests/test_logging/test_logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.61.2
3
+ Version: 2.62.1
4
4
  Summary: Python package for interacting with CloudOS
5
5
  Home-page: https://github.com/lifebit-ai/cloudos-cli
6
6
  Author: David Piñeyro
@@ -79,6 +79,7 @@ Python package for interacting with CloudOS
79
79
  - [Get Job Details](#get-job-details)
80
80
  - [Get Job Workdir](#get-job-workdir)
81
81
  - [List Jobs](#list-jobs)
82
+ - [Get Job Costs](#get-job-costs)
82
83
  - [Bash Jobs](#bash-jobs)
83
84
  - [Send Array Job](#send-array-job)
84
85
  - [Submit a Bash Array Job](#submit-a-bash-array-job)
@@ -1029,6 +1030,153 @@ cloudos job list --profile my_profile --last-n-jobs 'all' --filter-workflow rnat
1029
1030
  > - Job name filtering is case insensitive and supports partial matches
1030
1031
  > - The `--last` flag can be used with `--filter-workflow` when multiple workflows have the same name
1031
1032
 
1033
+ #### Get Job Costs
1034
+
1035
+ You can retrieve detailed cost information for any job in your CloudOS workspace using the `job cost` command. This provides insights into compute costs, storage usage, and runtime metrics to help optimize workflows and manage expenses.
1036
+
1037
+ The cost information is retrieved from CloudOS and can be displayed in multiple formats:
1038
+
1039
+ - **Console display**: Rich formatted tables with pagination for easy viewing
1040
+ - **CSV**: Structured data for analysis and reporting
1041
+ - **JSON**: Complete cost data for programmatic processing
1042
+
1043
+ To get cost information for a specific job:
1044
+
1045
+ ```bash
1046
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355
1047
+ ```
1048
+
1049
+ The expected output is a formatted table showing:
1050
+
1051
+ ```console
1052
+ Job Cost Details - Job ID: 62c83a1191fe06013b7ef355
1053
+ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
1054
+ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Compute ┃ ┃
1055
+ ┃ ┃ Instance ┃ ┃ Life-cycle ┃ ┃ Compute ┃ Instance ┃ storage ┃ ┃
1056
+ ┃ Type ┃ id ┃ Instance ┃ type ┃ Run time ┃ storage ┃ price ┃ price ┃ Total ┃
1057
+ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
1058
+ │ Worker │ pgti_mediu │ standard_d │ spot │ 2m 12s │ 500 Gb │ $0.0888/hr │ $0.0298/hr │ $0.0043 │
1059
+ │ │ m_pool/tvm │ 8a_v4 │ │ │ │ │ │ │
1060
+ │ │ ps_e57148f │ │ │ │ │ │ │ │
1061
+ │ │ f29a2186e2 │ │ │ │ │ │ │ │
1062
+ │ │ ba07c0566c │ │ │ │ │ │ │ │
1063
+ │ │ a7d494148a │ │ │ │ │ │ │ │
1064
+ │ │ 7f8d9d547d │ │ │ │ │ │ │ │
1065
+ │ │ 8fdbb71ead │ │ │ │ │ │ │ │
1066
+ │ │ 4355497_p │ │ │ │ │ │ │ │
1067
+ │ Worker │ pgti_mediu │ standard_d │ spot │ 7m 48s │ 500 Gb │ $0.0888/hr │ $0.0298/hr │ $0.0154 │
1068
+ │ │ m_pool/tvm │ 8a_v4 │ │ │ │ │ │ │
1069
+ │ │ ps_acc84ab │ │ │ │ │ │ │ │
1070
+ │ │ 980b9bd654 │ │ │ │ │ │ │ │
1071
+ │ │ b690de025a │ │ │ │ │ │ │ │
1072
+ │ │ 7abab8c5e2 │ │ │ │ │ │ │ │
1073
+ │ │ 7fe60e80c7 │ │ │ │ │ │ │ │
1074
+ │ │ 34d65f6519 │ │ │ │ │ │ │ │
1075
+ │ │ 5a56c26_p │ │ │ │ │ │ │ │
1076
+ └────────┴────────────┴────────────┴────────────┴──────────┴─────────────┴────────────┴─────────────┴─────────┘
1077
+ On page 1/2: n = next, p = prev, q = quit
1078
+
1079
+ By pressing 'n', it will show the next page or the last if it is the case.
1080
+
1081
+ Job Cost Details - Job ID: 62c83a1191fe06013b7ef355
1082
+ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
1083
+ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Compute ┃ ┃
1084
+ ┃ ┃ Instance ┃ ┃ Life-cycle ┃ ┃ Compute ┃ Instance ┃ storage ┃ ┃
1085
+ ┃ Type ┃ id ┃ Instance ┃ type ┃ Run time ┃ storage ┃ price ┃ price ┃ Total ┃
1086
+ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
1087
+ │ Worker │ pgti_large │ standard_d │ spot │ 1m 24s │ 500 Gb │ $0.1780/hr │ $0.0298/hr │ $0.0049 │
1088
+ │ │ _pool/tvmp │ 16a_v4 │ │ │ │ │ │ │
1089
+ │ │ s_fde00bd8 │ │ │ │ │ │ │ │
1090
+ │ │ b7b0c2fd49 │ │ │ │ │ │ │ │
1091
+ │ │ c24a9f2d29 │ │ │ │ │ │ │ │
1092
+ │ │ c2958994d8 │ │ │ │ │ │ │ │
1093
+ │ │ 125708b7d2 │ │ │ │ │ │ │ │
1094
+ │ │ ab2309c419 │ │ │ │ │ │ │ │
1095
+ │ │ 747a8a_p │ │ │ │ │ │ │ │
1096
+ │ Worker │ pgti_large │ standard_d │ spot │ 1m 20s │ 500 Gb │ $0.1780/hr │ $0.0298/hr │ $0.0046 │
1097
+ │ │ _pool/tvmp │ 16a_v4 │ │ │ │ │ │ │
1098
+ │ │ s_abe5f8f5 │ │ │ │ │ │ │ │
1099
+ │ │ afe98535d3 │ │ │ │ │ │ │ │
1100
+ │ │ a74a73a9e5 │ │ │ │ │ │ │ │
1101
+ │ │ e2e2d1c181 │ │ │ │ │ │ │ │
1102
+ │ │ a6b1056a17 │ │ │ │ │ │ │ │
1103
+ │ │ 6ecaacdb65 │ │ │ │ │ │ │ │
1104
+ │ │ 0737b7_p │ │ │ │ │ │ │ │
1105
+ │ │ │ │ │ │ │ │ │ │
1106
+ ├────────┼────────────┼────────────┼────────────┼──────────┼─────────────┼────────────┼─────────────┼─────────┤
1107
+ │ │ │ │ │ │ │ │ │ $0.5563 │
1108
+ └────────┴────────────┴────────────┴────────────┴──────────┴─────────────┴────────────┴─────────────┴─────────┘
1109
+
1110
+ In the last page, the total job cost will be in the last row.
1111
+ ```
1112
+
1113
+ **Export options:**
1114
+
1115
+ Save cost data to CSV for further analysis:
1116
+
1117
+ ```bash
1118
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355 --output-format csv
1119
+
1120
+ cat 62c83a1191fe06013b7ef355_costs.csv
1121
+ Type,Instance id,Instance,Life-cycle type,Run time,Compute storage,Instance price,Compute storage price,Total
1122
+ Master,186b12c2-a518-40de-8bef-7c43f9adcfce,Standard_D4as_v4,on demand,39m 43s,1000 Gb,$0.2220/hr,$0.0561/hr,$0.1841
1123
+ Worker,pgti_large_pool/tvmps_e739a24d7e64e06f1006d3410ee74c7929388fb1146231d4be84ecdb2c39db0f_p,standard_d16a_v4,spot,1m 26s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0050
1124
+ Worker,pgti_large_pool/tvmps_abe5f8f5afe98535d3a74a73a9e5e2e2d1c181a6b1056a176ecaacdb650737b7_p,standard_d16a_v4,spot,1m 20s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0046
1125
+ Worker,pgti_large_pool/tvmps_dad8c86e744056f581e9298273ff7df99d2f9f2b5dc8f706037b1a8b61c4ce0b_p,standard_d16a_v4,spot,5m 10s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0179
1126
+ ...
1127
+ ```
1128
+
1129
+ Save complete cost data to JSON:
1130
+
1131
+ ```bash
1132
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355 --output-format json
1133
+
1134
+ cat 62c83a1191fe06013b7ef355_costs.json
1135
+ {
1136
+ "job_id": "688ade923643c2454f5ac77d",
1137
+ "cost_table": [
1138
+ {
1139
+ "Type": "Master",
1140
+ "Instance id": "186b12c2-a518-40de-8bef-7c43f9adcfce",
1141
+ "Instance": "Standard_D4as_v4",
1142
+ "Life-cycle type": "on demand",
1143
+ "Run time": "39m 43s",
1144
+ "Compute storage": "1000 Gb",
1145
+ "Instance price": "$0.2220/hr",
1146
+ "Compute storage price": "$0.0561/hr",
1147
+ "Total": "$0.1841"
1148
+ },
1149
+ {
1150
+ "Type": "Worker",
1151
+ "Instance id": "pgti_medium_pool/tvmps_ba00d365ca2b35cce93b2853480be9afc0202bf2f5633648f2dd576414dd8987_p
1152
+ ",
1153
+ "Instance": "standard_d8a_v4",
1154
+ "Life-cycle type": "spot",
1155
+ "Run time": "19m 55s",
1156
+ "Compute storage": "500 Gb",
1157
+ "Instance price": "$0.0888/hr",
1158
+ "Compute storage price": "$0.0298/hr",
1159
+ "Total": "$0.0394"
1160
+ },
1161
+ ...
1162
+ {
1163
+ "Type": "Worker",
1164
+ "Instance id": "pgti_large_pool/tvmps_abe5f8f5afe98535d3a74a73a9e5e2e2d1c181a6b1056a176ecaacdb650737b7_p"
1165
+ ,
1166
+ "Instance": "standard_d16a_v4",
1167
+ "Life-cycle type": "spot",
1168
+ "Run time": "1m 20s",
1169
+ "Compute storage": "500 Gb",
1170
+ "Instance price": "$0.1780/hr",
1171
+ "Compute storage price": "$0.0298/hr",
1172
+ "Total": "$0.0046"
1173
+ }
1174
+ ],
1175
+ "final_cost": "$0.5563"
1176
+ }
1177
+
1178
+ ```
1179
+
1032
1180
  ### Bash Jobs
1033
1181
  Execute bash scripts on CloudOS for custom processing workflows. Bash jobs allow you to run shell commands with custom parameters and are ideal for data preprocessing or simple computational tasks.
1034
1182
 
@@ -44,6 +44,7 @@ Python package for interacting with CloudOS
44
44
  - [Get Job Details](#get-job-details)
45
45
  - [Get Job Workdir](#get-job-workdir)
46
46
  - [List Jobs](#list-jobs)
47
+ - [Get Job Costs](#get-job-costs)
47
48
  - [Bash Jobs](#bash-jobs)
48
49
  - [Send Array Job](#send-array-job)
49
50
  - [Submit a Bash Array Job](#submit-a-bash-array-job)
@@ -994,6 +995,153 @@ cloudos job list --profile my_profile --last-n-jobs 'all' --filter-workflow rnat
994
995
  > - Job name filtering is case insensitive and supports partial matches
995
996
  > - The `--last` flag can be used with `--filter-workflow` when multiple workflows have the same name
996
997
 
998
+ #### Get Job Costs
999
+
1000
+ You can retrieve detailed cost information for any job in your CloudOS workspace using the `job cost` command. This provides insights into compute costs, storage usage, and runtime metrics to help optimize workflows and manage expenses.
1001
+
1002
+ The cost information is retrieved from CloudOS and can be displayed in multiple formats:
1003
+
1004
+ - **Console display**: Rich formatted tables with pagination for easy viewing
1005
+ - **CSV**: Structured data for analysis and reporting
1006
+ - **JSON**: Complete cost data for programmatic processing
1007
+
1008
+ To get cost information for a specific job:
1009
+
1010
+ ```bash
1011
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355
1012
+ ```
1013
+
1014
+ The expected output is a formatted table showing:
1015
+
1016
+ ```console
1017
+ Job Cost Details - Job ID: 62c83a1191fe06013b7ef355
1018
+ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
1019
+ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Compute ┃ ┃
1020
+ ┃ ┃ Instance ┃ ┃ Life-cycle ┃ ┃ Compute ┃ Instance ┃ storage ┃ ┃
1021
+ ┃ Type ┃ id ┃ Instance ┃ type ┃ Run time ┃ storage ┃ price ┃ price ┃ Total ┃
1022
+ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
1023
+ │ Worker │ pgti_mediu │ standard_d │ spot │ 2m 12s │ 500 Gb │ $0.0888/hr │ $0.0298/hr │ $0.0043 │
1024
+ │ │ m_pool/tvm │ 8a_v4 │ │ │ │ │ │ │
1025
+ │ │ ps_e57148f │ │ │ │ │ │ │ │
1026
+ │ │ f29a2186e2 │ │ │ │ │ │ │ │
1027
+ │ │ ba07c0566c │ │ │ │ │ │ │ │
1028
+ │ │ a7d494148a │ │ │ │ │ │ │ │
1029
+ │ │ 7f8d9d547d │ │ │ │ │ │ │ │
1030
+ │ │ 8fdbb71ead │ │ │ │ │ │ │ │
1031
+ │ │ 4355497_p │ │ │ │ │ │ │ │
1032
+ │ Worker │ pgti_mediu │ standard_d │ spot │ 7m 48s │ 500 Gb │ $0.0888/hr │ $0.0298/hr │ $0.0154 │
1033
+ │ │ m_pool/tvm │ 8a_v4 │ │ │ │ │ │ │
1034
+ │ │ ps_acc84ab │ │ │ │ │ │ │ │
1035
+ │ │ 980b9bd654 │ │ │ │ │ │ │ │
1036
+ │ │ b690de025a │ │ │ │ │ │ │ │
1037
+ │ │ 7abab8c5e2 │ │ │ │ │ │ │ │
1038
+ │ │ 7fe60e80c7 │ │ │ │ │ │ │ │
1039
+ │ │ 34d65f6519 │ │ │ │ │ │ │ │
1040
+ │ │ 5a56c26_p │ │ │ │ │ │ │ │
1041
+ └────────┴────────────┴────────────┴────────────┴──────────┴─────────────┴────────────┴─────────────┴─────────┘
1042
+ On page 1/2: n = next, p = prev, q = quit
1043
+
1044
+ By pressing 'n', it will show the next page or the last if it is the case.
1045
+
1046
+ Job Cost Details - Job ID: 62c83a1191fe06013b7ef355
1047
+ ┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━┓
1048
+ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Compute ┃ ┃
1049
+ ┃ ┃ Instance ┃ ┃ Life-cycle ┃ ┃ Compute ┃ Instance ┃ storage ┃ ┃
1050
+ ┃ Type ┃ id ┃ Instance ┃ type ┃ Run time ┃ storage ┃ price ┃ price ┃ Total ┃
1051
+ ┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━┩
1052
+ │ Worker │ pgti_large │ standard_d │ spot │ 1m 24s │ 500 Gb │ $0.1780/hr │ $0.0298/hr │ $0.0049 │
1053
+ │ │ _pool/tvmp │ 16a_v4 │ │ │ │ │ │ │
1054
+ │ │ s_fde00bd8 │ │ │ │ │ │ │ │
1055
+ │ │ b7b0c2fd49 │ │ │ │ │ │ │ │
1056
+ │ │ c24a9f2d29 │ │ │ │ │ │ │ │
1057
+ │ │ c2958994d8 │ │ │ │ │ │ │ │
1058
+ │ │ 125708b7d2 │ │ │ │ │ │ │ │
1059
+ │ │ ab2309c419 │ │ │ │ │ │ │ │
1060
+ │ │ 747a8a_p │ │ │ │ │ │ │ │
1061
+ │ Worker │ pgti_large │ standard_d │ spot │ 1m 20s │ 500 Gb │ $0.1780/hr │ $0.0298/hr │ $0.0046 │
1062
+ │ │ _pool/tvmp │ 16a_v4 │ │ │ │ │ │ │
1063
+ │ │ s_abe5f8f5 │ │ │ │ │ │ │ │
1064
+ │ │ afe98535d3 │ │ │ │ │ │ │ │
1065
+ │ │ a74a73a9e5 │ │ │ │ │ │ │ │
1066
+ │ │ e2e2d1c181 │ │ │ │ │ │ │ │
1067
+ │ │ a6b1056a17 │ │ │ │ │ │ │ │
1068
+ │ │ 6ecaacdb65 │ │ │ │ │ │ │ │
1069
+ │ │ 0737b7_p │ │ │ │ │ │ │ │
1070
+ │ │ │ │ │ │ │ │ │ │
1071
+ ├────────┼────────────┼────────────┼────────────┼──────────┼─────────────┼────────────┼─────────────┼─────────┤
1072
+ │ │ │ │ │ │ │ │ │ $0.5563 │
1073
+ └────────┴────────────┴────────────┴────────────┴──────────┴─────────────┴────────────┴─────────────┴─────────┘
1074
+
1075
+ In the last page, the total job cost will be in the last row.
1076
+ ```
1077
+
1078
+ **Export options:**
1079
+
1080
+ Save cost data to CSV for further analysis:
1081
+
1082
+ ```bash
1083
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355 --output-format csv
1084
+
1085
+ cat 62c83a1191fe06013b7ef355_costs.csv
1086
+ Type,Instance id,Instance,Life-cycle type,Run time,Compute storage,Instance price,Compute storage price,Total
1087
+ Master,186b12c2-a518-40de-8bef-7c43f9adcfce,Standard_D4as_v4,on demand,39m 43s,1000 Gb,$0.2220/hr,$0.0561/hr,$0.1841
1088
+ Worker,pgti_large_pool/tvmps_e739a24d7e64e06f1006d3410ee74c7929388fb1146231d4be84ecdb2c39db0f_p,standard_d16a_v4,spot,1m 26s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0050
1089
+ Worker,pgti_large_pool/tvmps_abe5f8f5afe98535d3a74a73a9e5e2e2d1c181a6b1056a176ecaacdb650737b7_p,standard_d16a_v4,spot,1m 20s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0046
1090
+ Worker,pgti_large_pool/tvmps_dad8c86e744056f581e9298273ff7df99d2f9f2b5dc8f706037b1a8b61c4ce0b_p,standard_d16a_v4,spot,5m 10s,500 Gb,$0.1780/hr,$0.0298/hr,$0.0179
1091
+ ...
1092
+ ```
1093
+
1094
+ Save complete cost data to JSON:
1095
+
1096
+ ```bash
1097
+ cloudos job cost --profile my_profile --job-id 62c83a1191fe06013b7ef355 --output-format json
1098
+
1099
+ cat 62c83a1191fe06013b7ef355_costs.json
1100
+ {
1101
+ "job_id": "688ade923643c2454f5ac77d",
1102
+ "cost_table": [
1103
+ {
1104
+ "Type": "Master",
1105
+ "Instance id": "186b12c2-a518-40de-8bef-7c43f9adcfce",
1106
+ "Instance": "Standard_D4as_v4",
1107
+ "Life-cycle type": "on demand",
1108
+ "Run time": "39m 43s",
1109
+ "Compute storage": "1000 Gb",
1110
+ "Instance price": "$0.2220/hr",
1111
+ "Compute storage price": "$0.0561/hr",
1112
+ "Total": "$0.1841"
1113
+ },
1114
+ {
1115
+ "Type": "Worker",
1116
+ "Instance id": "pgti_medium_pool/tvmps_ba00d365ca2b35cce93b2853480be9afc0202bf2f5633648f2dd576414dd8987_p
1117
+ ",
1118
+ "Instance": "standard_d8a_v4",
1119
+ "Life-cycle type": "spot",
1120
+ "Run time": "19m 55s",
1121
+ "Compute storage": "500 Gb",
1122
+ "Instance price": "$0.0888/hr",
1123
+ "Compute storage price": "$0.0298/hr",
1124
+ "Total": "$0.0394"
1125
+ },
1126
+ ...
1127
+ {
1128
+ "Type": "Worker",
1129
+ "Instance id": "pgti_large_pool/tvmps_abe5f8f5afe98535d3a74a73a9e5e2e2d1c181a6b1056a176ecaacdb650737b7_p"
1130
+ ,
1131
+ "Instance": "standard_d16a_v4",
1132
+ "Life-cycle type": "spot",
1133
+ "Run time": "1m 20s",
1134
+ "Compute storage": "500 Gb",
1135
+ "Instance price": "$0.1780/hr",
1136
+ "Compute storage price": "$0.0298/hr",
1137
+ "Total": "$0.0046"
1138
+ }
1139
+ ],
1140
+ "final_cost": "$0.5563"
1141
+ }
1142
+
1143
+ ```
1144
+
997
1145
  ### Bash Jobs
998
1146
  Execute bash scripts on CloudOS for custom processing workflows. Bash jobs allow you to run shell commands with custom parameters and are ideal for data preprocessing or simple computational tasks.
999
1147
 
@@ -21,6 +21,7 @@ from rich.style import Style
21
21
  from cloudos_cli.utils.array_job import generate_datasets_for_project
22
22
  from cloudos_cli.utils.details import create_job_details
23
23
  from cloudos_cli.link import Link
24
+ from cloudos_cli.cost.cost import CostViewer
24
25
  from cloudos_cli.logging.logger import setup_logging, update_command_context_from_click
25
26
  import logging
26
27
 
@@ -163,7 +164,8 @@ def run_cloudos_cli(ctx):
163
164
  'results': shared_config,
164
165
  'details': shared_config,
165
166
  'clone': shared_config,
166
- 'resume': shared_config
167
+ 'resume': shared_config,
168
+ 'cost': shared_config
167
169
  },
168
170
  'workflow': {
169
171
  'list': shared_config,
@@ -227,7 +229,8 @@ def run_cloudos_cli(ctx):
227
229
  'results': shared_config,
228
230
  'details': shared_config,
229
231
  'clone': shared_config,
230
- 'resume': shared_config
232
+ 'resume': shared_config,
233
+ 'cost': shared_config
231
234
  },
232
235
  'workflow': {
233
236
  'list': shared_config,
@@ -1529,6 +1532,88 @@ def abort_jobs(ctx,
1529
1532
  click.secho(f"Job '{job}' aborted successfully.", fg='green', bold=True)
1530
1533
 
1531
1534
 
1535
+ @job.command('cost')
1536
+ @click.option('-k',
1537
+ '--apikey',
1538
+ help='Your CloudOS API key',
1539
+ required=True)
1540
+ @click.option('-c',
1541
+ '--cloudos-url',
1542
+ help=(f'The CloudOS url you are trying to access to. Default={CLOUDOS_URL}.'),
1543
+ default=CLOUDOS_URL,
1544
+ required=True)
1545
+ @click.option('--workspace-id',
1546
+ help='The specific CloudOS workspace id.',
1547
+ required=True)
1548
+ @click.option('--job-id',
1549
+ help='The job id in CloudOS to get costs for.',
1550
+ required=True)
1551
+ @click.option('--output-format',
1552
+ help='The desired file format (file extension) for the output. For json option --all-fields will be automatically set to True. Default=csv.',
1553
+ type=click.Choice(['stdout', 'csv', 'json'], case_sensitive=False),
1554
+ default='stdout')
1555
+ @click.option('--verbose',
1556
+ help='Whether to print information messages or not.',
1557
+ is_flag=True)
1558
+ @click.option('--disable-ssl-verification',
1559
+ help=('Disable SSL certificate verification. Please, remember that this option is ' +
1560
+ 'not generally recommended for security reasons.'),
1561
+ is_flag=True)
1562
+ @click.option('--ssl-cert',
1563
+ help='Path to your SSL certificate file.')
1564
+ @click.option('--profile', help='Profile to use from the config file', default=None)
1565
+ @click.pass_context
1566
+ def job_cost(ctx,
1567
+ apikey,
1568
+ cloudos_url,
1569
+ workspace_id,
1570
+ job_id,
1571
+ output_format,
1572
+ verbose,
1573
+ disable_ssl_verification,
1574
+ ssl_cert,
1575
+ profile):
1576
+ """Retrieve job cost information in CloudOS."""
1577
+ profile = profile or ctx.default_map['job']['cost']['profile']
1578
+ # Create a dictionary with required and non-required params
1579
+ required_dict = {
1580
+ 'apikey': True,
1581
+ 'workspace_id': True,
1582
+ 'workflow_name': False,
1583
+ 'session_id': False,
1584
+ 'project_name': False,
1585
+ 'procurement_id': False
1586
+ }
1587
+ # determine if the user provided all required parameters
1588
+ config_manager = ConfigurationProfile()
1589
+ user_options = (
1590
+ config_manager.load_profile_and_validate_data(
1591
+ ctx,
1592
+ INIT_PROFILE,
1593
+ CLOUDOS_URL,
1594
+ profile=profile,
1595
+ required_dict=required_dict,
1596
+ apikey=apikey,
1597
+ cloudos_url=cloudos_url,
1598
+ workspace_id=workspace_id,
1599
+ session_id=None
1600
+ )
1601
+ )
1602
+ apikey = user_options['apikey']
1603
+ cloudos_url = user_options['cloudos_url']
1604
+ workspace_id = user_options['workspace_id']
1605
+
1606
+ print('Retrieving cost information...')
1607
+ verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
1608
+ if verbose:
1609
+ print('\t...Preparing objects')
1610
+ cost_viewer = CostViewer(cloudos_url, apikey)
1611
+ if verbose:
1612
+ print(f'\tSearching for cost data for job id: {job_id}')
1613
+ # Display costs with pagination
1614
+ cost_viewer.display_costs(job_id, workspace_id, output_format, verify_ssl)
1615
+
1616
+
1532
1617
  @click.command()
1533
1618
  @click.option('-k',
1534
1619
  '--apikey',
@@ -0,0 +1 @@
1
+ __version__ = '2.62.1'
@@ -2,7 +2,6 @@
2
2
  This is the main class of the package.
3
3
  """
4
4
 
5
- from numpy import r_
6
5
  import requests
7
6
  import time
8
7
  import json
@@ -0,0 +1,8 @@
1
+ """
2
+ Functions and classes related to cost.
3
+ """
4
+
5
+ from .cost import CostViewer
6
+
7
+
8
+ __all__ = ['cost']