Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into graph_view_invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Apr 30, 2024
2 parents 0ce7488 + fd4165f commit d3b11e6
Show file tree
Hide file tree
Showing 178 changed files with 909 additions and 650 deletions.
2 changes: 1 addition & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19403,7 +19403,7 @@ export interface operations {
* @description Allows remote job running mechanisms to get a fresh OIDC token that can be used on remote side to authorize user. It is not meant to represent part of Galaxy's stable, user facing API
*/
parameters: {
/** @description A key used to authenticate this request as acting onbehalf or a job runner for the specified job */
/** @description A key used to authenticate this request as acting on behalf or a job runner for the specified job */
/** @description OIDC provider name */
query: {
job_key: string;
Expand Down
40 changes: 36 additions & 4 deletions client/src/components/Common/Heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,27 @@ interface Props {
size?: "xl" | "lg" | "md" | "sm" | "text";
icon?: string | [string, string];
truncate?: boolean;
collapse?: "open" | "closed" | "none";
}
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
collapse: "none",
});
defineEmits(["click"]);
const sizeClass = computed(() => {
return `h-${props.size ?? "lg"}`;
});
const collapsible = computed(() => {
return props.collapse !== "none";
});
const collapsed = computed(() => {
return props.collapse === "closed";
});
const element = computed(() => {
for (const key of ["h1", "h2", "h3", "h4", "h5", "h6"]) {
if (props[key as keyof typeof props]) {
Expand All @@ -35,10 +48,15 @@ const element = computed(() => {

<template>
<div v-if="props.separator" class="separator heading">
<div class="stripe"></div>
<b-button v-if="collapsible" variant="link" size="sm" @click="$emit('click')">
<FontAwesomeIcon v-if="collapsed" fixed-width :icon="faAngleDoubleDown" />
<FontAwesomeIcon v-else fixed-width :icon="faAngleDoubleUp" />
</b-button>
<div v-else class="stripe"></div>
<component
:is="element"
:class="[sizeClass, props.bold ? 'font-weight-bold' : '', props.truncate ? 'truncate' : '']">
:class="[sizeClass, props.bold ? 'font-weight-bold' : '', collapsible ? 'collapsible' : '', props.truncate ? 'truncate' : '']">
@click="$emit('click')">
<slot />
</component>
<div class="stripe"></div>
Expand All @@ -47,7 +65,17 @@ const element = computed(() => {
:is="element"
v-else
class="heading"
:class="[sizeClass, props.bold ? 'font-weight-bold' : '', props.inline ? 'inline' : '']">
:class="[
sizeClass,
props.bold ? 'font-weight-bold' : '',
props.inline ? 'inline' : '',
collapsible ? 'collapsible' : '',
]"
@click="$emit('click')">
<b-button v-if="collapsible" variant="link" size="sm">
<icon v-if="collapsed" fixed-width icon="angle-double-down" />
<icon v-else fixed-width icon="angle-double-up" />
</b-button>
<FontAwesomeIcon v-if="props.icon" :icon="props.icon" />
<slot />
</component>
Expand Down Expand Up @@ -80,6 +108,10 @@ h1, h2, h3, h4, h5, h6 {
}
}
.collapsible {
cursor: pointer;
}
.separator {
display: grid;
grid-template-columns: 1rem auto 1fr;
Expand Down
36 changes: 23 additions & 13 deletions client/src/components/JobMetrics/AwsEstimate.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<script setup lang="ts">
import { computed } from "vue";
import { usePersistentToggle } from "@/composables/persistentToggle";
import Heading from "@/components/Common/Heading.vue";
const props = defineProps<{
jobRuntimeInSeconds: number;
coresAllocated: number;
Expand All @@ -20,6 +24,8 @@ const props = defineProps<{
}[];
}>();
const { toggled, toggle } = usePersistentToggle("aws-estimate");
const computedAwsEstimate = computed(() => {
const { coresAllocated, jobRuntimeInSeconds, memoryAllocatedInMebibyte } = props;
Expand Down Expand Up @@ -50,24 +56,28 @@ const computedAwsEstimate = computed(() => {

<template>
<div v-if="computedAwsEstimate" id="aws-estimate" class="mt-4">
<h2>AWS estimate</h2>
<Heading h2 size="md" separator :collapse="toggled ? 'closed' : 'open'" @click="toggle()">
AWS estimate
</Heading>

<strong id="aws-cost">{{ computedAwsEstimate.price }} USD</strong>
<template v-if="!toggled">
<strong id="aws-cost">{{ computedAwsEstimate.price }} USD</strong>

<br />
<br />

This job requested {{ computedAwsEstimate.requestedVCpuCount }} core(s) and
{{ computedAwsEstimate.memory.toFixed(3) }} GiB of memory. Given this information, the smallest EC2 machine we
could find is:
This job requested {{ computedAwsEstimate.requestedVCpuCount }} core(s) and
{{ computedAwsEstimate.memory.toFixed(3) }} GiB of memory. Given this information, the smallest EC2 machine
we could find is:

<span id="aws-name">{{ computedAwsEstimate.instance.name }}</span>
(<span id="aws-mem">{{ computedAwsEstimate.instance.mem }}</span> GB /
<span id="aws-vcpus">{{ computedAwsEstimate.instance.vCpuCount }}</span> vCPUs /
<span id="aws-cpu">{{ computedAwsEstimate.instance.cpu.map(({ cpuModel }) => cpuModel).join(", ") }}</span
>). This instance is priced at {{ computedAwsEstimate.instance.price }} USD/hour.
<span id="aws-name">{{ computedAwsEstimate.instance.name }}</span>
(<span id="aws-mem">{{ computedAwsEstimate.instance.mem }}</span> GB /
<span id="aws-vcpus">{{ computedAwsEstimate.instance.vCpuCount }}</span> vCPUs /
<span id="aws-cpu">{{ computedAwsEstimate.instance.cpu.map(({ cpuModel }) => cpuModel).join(", ") }}</span
>). This instance is priced at {{ computedAwsEstimate.instance.price }} USD/hour.

<br />
<br />

&ast;Please note, that these numbers are only estimates, all jobs are always free of charge for all users.
&ast;Please note, that these numbers are only estimates, all jobs are always free of charge for all users.
</template>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import type { GetComponentPropTypes } from "types/utilityTypes";
import { computed, unref } from "vue";
import { usePersistentToggle } from "@/composables/persistentToggle";
import * as carbonEmissionsConstants from "./carbonEmissionConstants.js";
import BarChart from "./BarChart.vue";
Expand Down Expand Up @@ -34,6 +36,8 @@ const props = withDefaults(defineProps<CarbonEmissionsProps>(), {
memoryAllocatedInMebibyte: 0,
});
const { toggled, toggle } = usePersistentToggle("carbonEmissions");
const carbonEmissions = computed(() => {
const memoryPowerUsed = carbonEmissionsConstants.memoryPowerUsage;
const runtimeInHours = props.jobRuntimeInSeconds / (60 * 60); // Convert to hours
Expand Down Expand Up @@ -270,9 +274,11 @@ function getEnergyNeededText(energyNeededInKiloWattHours: number) {

<template v-if="carbonEmissions && carbonEmissionsComparisons">
<div class="mt-4">
<Heading h2 separator inline bold> Carbon Footprint </Heading>
<Heading h2 separator size="md" inline :collapse="toggled ? 'closed' : 'open'" @click="toggle()">
Carbon Footprint
</Heading>

<section class="carbon-emission-values my-4">
<section v-if="!toggled" class="carbon-emission-values my-4">
<div class="emissions-grid">
<!-- Carbon Footprint Totals -->
<CarbonEmissionsCard
Expand Down
1 change: 0 additions & 1 deletion client/src/components/JobMetrics/JobMetrics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ const estimatedServerInstance = computed(() => {
<AwsEstimate
v-if="jobRuntimeInSeconds && coresAllocated && ec2Instances && shouldShowAwsEstimate"
:ec2-instances="ec2Instances"
:should-show-aws-estimate="shouldShowAwsEstimate"
:job-runtime-in-seconds="jobRuntimeInSeconds"
:cores-allocated="coresAllocated"
:memory-allocated-in-mebibyte="memoryAllocatedInMebibyte" />
Expand Down
23 changes: 23 additions & 0 deletions client/src/composables/persistentToggle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { type Ref } from "vue";

import { useUserLocalStorage } from "./userLocalStorage";

interface ToggleStateInterface {
toggled: Ref<boolean>;
toggle: () => void;
}

export function usePersistentToggle(uniqueId: string): ToggleStateInterface {
const localStorageKey = `toggle-state-${uniqueId}`;
const toggled = useUserLocalStorage(localStorageKey, false);

// Expose a function for toggling state
const toggle = () => {
toggled.value = !toggled.value;
};

return {
toggled,
toggle,
};
}
28 changes: 14 additions & 14 deletions config/plugins/webhooks/demo/tour_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _upload_test_data(self):
filename = test_datasets[input_name]
input_path = self._tool.test_data_path(filename)
if not input_path:
raise ValueError('Test dataset "%s" doesn\'t exist.' % input_name)
raise ValueError(f'Test dataset "{input_name}" doesn\'t exist.')
upload_tool = self._trans.app.toolbox.get_tool("upload1")
filename = os.path.basename(input_path)
with open(input_path, "rb") as f:
Expand Down Expand Up @@ -92,12 +92,12 @@ def _upload_test_data(self):

def _generate_tour(self):
"""Generate a tour."""
tour_name = self._tool.name + " Tour"
tour_name = f"{self._tool.name} Tour"
test_inputs = self._test.inputs.keys()
steps = [
{
"title": tour_name,
"content": "This short tour will guide you through the <b>" + self._tool.name + "</b> tool.",
"content": f"This short tour will guide you through the <b>{self._tool.name}</b> tool.",
"orphan": True,
}
]
Expand All @@ -107,26 +107,26 @@ def _generate_tour(self):
continue
step = {
"title": input.label,
"element": "[id='form-element-%s']" % name,
"element": f"[id='form-element-{name}']",
"placement": "right",
"content": "",
}
if input.type == "text":
if name in test_inputs:
param = self._test.inputs[name]
step["content"] = "Enter value(s): <b>%s</b>" % param
step["content"] = f"Enter value(s): <b>{param}</b>"
else:
step["content"] = "Enter a value"
elif input.type == "integer" or input.type == "float":
if name in test_inputs:
num_param = self._test.inputs[name][0]
step["content"] = "Enter number: <b>%s</b>" % num_param
step["content"] = f"Enter number: <b>{num_param}</b>"
else:
step["content"] = "Enter a number"
elif input.type == "boolean":
if name in test_inputs:
choice = "Yes" if self._test.inputs[name][0] is True else "No"
step["content"] = "Choose <b>%s</b>" % choice
step["content"] = f"Choose <b>{choice}</b>"
else:
step["content"] = "Choose Yes/No"
elif input.type == "select":
Expand All @@ -138,7 +138,7 @@ def _generate_tour(self):
params.append(option[0])
if params:
select_param = ", ".join(params)
step["content"] = "Select parameter(s): <b>%s</b>" % select_param
step["content"] = f"Select parameter(s): <b>{select_param}</b>"
else:
step["content"] = "Select a parameter"
elif input.type == "data":
Expand All @@ -151,7 +151,7 @@ def _generate_tour(self):
elif input.type == "conditional":
param_id = f"{input.name}|{input.test_param.name}"
step["title"] = input.test_param.label
step["element"] = "[id='form-element-%s']" % param_id
step["element"] = f"[id='form-element-{param_id}']"
params = []
if param_id in self._test.inputs.keys():
for option in input.test_param.static_options:
Expand All @@ -173,24 +173,24 @@ def _generate_tour(self):
step_msg = f"Select dataset: <b>{hid}: {dataset}</b>"
else:
case_params = ", ".join(self._test.inputs[tour_id])
step_msg = "Select parameter(s): " + "<b>%s</b>" % case_params
step_msg = f"Select parameter(s): <b>{case_params}</b>"
cond_case_steps.append(
{
"title": case_title,
"element": "[id='form-element-%s']" % tour_id,
"element": f"[id='form-element-{tour_id}']",
"placement": "right",
"content": step_msg,
}
)
if params:
cond_param = ", ".join(params)
step["content"] = "Select parameter(s): <b>%s</b>" % cond_param
step["content"] = f"Select parameter(s): <b>{cond_param}</b>"
else:
step["content"] = "Select a parameter"
elif input.type == "data_column":
if name in test_inputs:
column_param = self._test.inputs[name][0]
step["content"] = "Select <b>Column: %s</b>" % column_param
step["content"] = f"Select <b>Column: {column_param}</b>"
else:
step["content"] = "Select a column"
else:
Expand All @@ -210,7 +210,7 @@ def _generate_tour(self):
self._tour = {
"title_default": tour_name,
"name": tour_name,
"description": self._tool.name + " " + self._tool.description,
"description": f"{self._tool.name} {self._tool.description}",
"steps": steps,
}

Expand Down
Loading

0 comments on commit d3b11e6

Please sign in to comment.