Skip to content

Commit

Permalink
Update client API schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Renni771 committed Feb 26, 2024
1 parent 7e1551c commit 79be5f7
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 97 deletions.
160 changes: 77 additions & 83 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,6 @@ export interface paths {
/** Marks the history with the given ID as deleted. */
delete: operations["delete_api_histories__history_id__delete"];
};
"/api/histories/{history_id}/energy_usage": {
/** Returns the energy usage of all jobs in a given history with the given ID. */
get: operations["history_api_histories__history_id__energy_usage_get"];
};
"/api/histories/{history_id}/archive": {
/**
* Archive a history.
Expand Down Expand Up @@ -815,6 +811,13 @@ export interface paths {
*/
put: operations["enable_link_access_api_histories__history_id__enable_link_access_put"];
};
"/api/histories/{history_id}/energy_usage": {
/**
* Returns the energy usage of a given history.
* @description Get the energy usage data of a history with ``history_id``.
*/
get: operations["get_energy_usage_api_histories__history_id__energy_usage_get"];
};
"/api/histories/{history_id}/exports": {
/**
* Get previous history exports.
Expand Down Expand Up @@ -994,6 +997,10 @@ export interface paths {
*/
get: operations["download_invocation_bco_api_invocations__invocation_id__biocompute_download_get"];
};
"/api/invocations/{invocation_id}/energy_usage": {
/** Get the energy usage of a workflow invocation. */
get: operations["get_energy_usage_api_invocations__invocation_id__energy_usage_get"];
};
"/api/invocations/{invocation_id}/jobs_summary": {
/**
* Get job state summary info aggregated across all current jobs of the workflow invocation.
Expand Down Expand Up @@ -1039,10 +1046,6 @@ export interface paths {
/** Prepare a workflow invocation export-style download and write to supplied URI. */
post: operations["write_store_api_invocations__invocation_id__write_store_post"];
};
"/api/invocations/{invocation_id}/energy_usage": {
/** Returns the energy usage of all jobs in a workflow invocation with the given ID. */
get: operations["invocation_energy_usage_api_invocations__invocation_id__energy_usage_get"];
};
"/api/job_lock": {
/**
* Job Lock Status
Expand Down Expand Up @@ -4598,6 +4601,15 @@ export interface components {
*/
src: components["schemas"]["DataItemSourceType"];
};
/** EnergyUsageSummary */
EnergyUsageSummary: {
/** Total Energy Needed Cpu Kwh */
total_energy_needed_cpu_kwh: number;
/** Total Energy Needed Kwh */
total_energy_needed_kwh: number;
/** Total Energy Needed Memory Kwh */
total_energy_needed_memory_kwh: number;
};
/** ExportHistoryArchivePayload */
ExportHistoryArchivePayload: {
/**
Expand Down Expand Up @@ -6571,29 +6583,6 @@ export interface components {
url: string;
[key: string]: unknown | undefined;
};
/**
* Energy Usage Summary Metrics
* @description The summary of energy usage for all jobs in a given history or a workflow invocation.
*/
EnergyUsageSummary: {
/**
* Total Energy Needed CPU (kWh)
* @description The total energy used by the CPU in kilowatt hours.
*/
total_energy_needed_cpu_kwh: number;

/**
* Total Energy Needed Memory (kWh)
* @description The total energy used by memory in kilowatt hours.
*/
total_energy_needed_memory_kwh: number;

/**
* Total Energy Needed (kWh)
* @description The total energy needed to run all jobs in kilowatt hours.
*/
total_energy_needed_kwh: number;
};
/**
* Hyperlink
* @description Represents some text with an Hyperlink.
Expand Down Expand Up @@ -14605,32 +14594,6 @@ export interface operations {
};
};
};
history_api_histories__history_id__energy_usage_get: {
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The encoded database identifier of the History. */
path: {
history_id: string;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["EnergyUsageSummary"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
archive_history_api_histories__history_id__archive_post: {
/**
* Archive a history.
Expand Down Expand Up @@ -16223,6 +16186,36 @@ export interface operations {
};
};
};
get_energy_usage_api_histories__history_id__energy_usage_get: {
/**
* Returns the energy usage of a given history.
* @description Get the energy usage data of a history with ``history_id``.
*/
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The encoded database identifier of the History. */
path: {
history_id: string;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["EnergyUsageSummary"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
get_history_exports_api_histories__history_id__exports_get: {
/**
* Get previous history exports.
Expand Down Expand Up @@ -17065,6 +17058,33 @@ export interface operations {
};
};
};
get_energy_usage_api_invocations__invocation_id__energy_usage_get: {
/** Get the energy usage of a workflow invocation. */
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The encoded database identifier of the Invocation. */
path: {
invocation_id: string;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["EnergyUsageSummary"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
invocation_jobs_summary_api_invocations__invocation_id__jobs_summary_get: {
/**
* Get job state summary info aggregated across all current jobs of the workflow invocation.
Expand Down Expand Up @@ -17249,32 +17269,6 @@ export interface operations {
};
};
};
invocation_energy_usage_api_invocations__invocation_id__energy_usage_get: {
parameters: {
/** @description The user ID that will be used to effectively make this API call. Only admins and designated users can make API calls on behalf of other users. */
header?: {
"run-as"?: string | null;
};
/** @description The encoded database identifier of the History. */
path: {
invocation_id: string;
};
};
responses: {
/** @description Successful Response */
200: {
content: {
"application/json": components["schemas"]["EnergyUsageSummary"];
};
};
/** @description Validation Error */
422: {
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
update_invocation_step_api_invocations__invocation_id__steps__step_id__put: {
/** Update state of running workflow step invocation - still very nebulous but this would be for stuff like confirming paused steps can proceed etc. */
parameters: {
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3683,3 +3683,9 @@ class DatasetSummary(Model):
file_size: int
total_size: int
uuid: UuidField


class EnergyUsageSummary(Model):
total_energy_needed_cpu_kwh: float
total_energy_needed_memory_kwh: float
total_energy_needed_kwh: float
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
DatasetSourceType,
DeleteHistoryContentPayload,
DeleteHistoryContentResult,
EnergyUsageSummary,
HistoryContentBulkOperationPayload,
HistoryContentBulkOperationResult,
HistoryContentsArchiveDryRunResult,
Expand Down Expand Up @@ -1029,6 +1030,6 @@ def get_energy_usage(
self,
history_id: HistoryIDPathParam,
trans: ProvidesHistoryContext = DependsOnTrans,
):
) -> EnergyUsageSummary:
"""Get the energy usage data of a history with ``history_id``."""
return self.service.get_energy_usage(trans, history_id)
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
from galaxy.schema.schema import (
AsyncFile,
AsyncTaskResultSummary,
EnergyUsageSummary,
InvocationSortByEnum,
InvocationsStateCounts,
SetSlugPayload,
Expand Down Expand Up @@ -1828,5 +1829,5 @@ def get_energy_usage(
self,
invocation_id: InvocationIDPathParam,
trans: ProvidesUserContext = DependsOnTrans,
):
) -> EnergyUsageSummary:
return self.invocations_service.get_energy_usage(trans, invocation_id)
13 changes: 7 additions & 6 deletions lib/galaxy/webapps/galaxy/services/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
DatasetAssociationRoles,
DeleteHistoryContentPayload,
EncodedHistoryContentItem,
EnergyUsageSummary,
HistoryContentBulkOperationPayload,
HistoryContentBulkOperationResult,
HistoryContentItem,
Expand Down Expand Up @@ -864,7 +865,7 @@ def get_energy_usage(
self,
trans,
history_id: DecodedDatabaseIdField,
):
) -> EnergyUsageSummary:
"""Get the energy usage of the history with ``history_id``.
:param history_id: the encoded id of the history whose energy usage is to be calculated
Expand Down Expand Up @@ -893,11 +894,11 @@ def get_energy_usage(

total_energy_needed_kwh = float(total_energy_needed_cpu_kwh) + float(total_energy_needed_memory_kwh)

return {
"total_energy_needed_cpu_kwh": total_energy_needed_cpu_kwh,
"total_energy_needed_memory_kwh": total_energy_needed_memory_kwh,
"total_energy_needed_kwh": total_energy_needed_kwh,
}
return EnergyUsageSummary(
total_energy_needed_cpu_kwh=total_energy_needed_cpu_kwh,
total_energy_needed_memory_kwh=total_energy_needed_memory_kwh,
total_energy_needed_kwh=total_energy_needed_kwh,
)

def __delete_dataset(
self, trans, id: DecodedDatabaseIdField, purge: bool, stop_job: bool, serialization_params: SerializationParams
Expand Down
13 changes: 7 additions & 6 deletions lib/galaxy/webapps/galaxy/services/invocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
AsyncFile,
AsyncTaskResultSummary,
BcoGenerationParametersMixin,
EnergyUsageSummary,
InvocationIndexQueryPayload,
StoreExportPayload,
WriteStoreToPayload,
Expand Down Expand Up @@ -140,7 +141,7 @@ def get_energy_usage(
self,
trans,
invocation_id: DecodedDatabaseIdField,
):
) -> EnergyUsageSummary:
workflow_invocation = self._workflows_manager.get_invocation(trans, invocation_id, eager=True)
job_ids = [step.job_id for step in workflow_invocation.steps if step.job_id is not None]

Expand All @@ -164,11 +165,11 @@ def get_energy_usage(

total_energy_needed_kwh = float(total_energy_needed_cpu_kwh) + float(total_energy_needed_memory_kwh)

return {
"total_energy_needed_cpu_kwh": total_energy_needed_cpu_kwh,
"total_energy_needed_memory_kwh": total_energy_needed_memory_kwh,
"total_energy_needed_kwh": total_energy_needed_kwh,
}
return EnergyUsageSummary(
total_energy_needed_cpu_kwh=total_energy_needed_cpu_kwh,
total_energy_needed_memory_kwh=total_energy_needed_memory_kwh,
total_energy_needed_kwh=total_energy_needed_kwh,
)

def cancel(self, trans, invocation_id, serialization_params):
wfi = self._workflows_manager.request_invocation_cancellation(trans, invocation_id)
Expand Down

0 comments on commit 79be5f7

Please sign in to comment.