Skip to content

Commit

Permalink
Merge pull request #643 from fractal-analytics-platform/2.9.0-alignment
Browse files Browse the repository at this point in the history
More fractal-server 2.9.0 alignments
  • Loading branch information
zonia3000 authored Nov 20, 2024
2 parents ee08ef0 + a55afd7 commit 2d13474
Show file tree
Hide file tree
Showing 19 changed files with 227 additions and 26 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

# Unreleased

* Alignment with fractal-server 2.9.0 (\#640):
* Alignment with fractal-server 2.9.0 (\#640, \#643):
* Updated task collections logic and created task-group activities pages for standard users and administrators (\#640);
* Removed active checkbox from task group edit modal (\#640);
* Added Manage button to deactivate and reactivate task groups (\#640);
* Removed usage of DB_ENGINE and SQLITE_PATH variables (\#643);
* Displayed `timestamp_last_used` property in task-group info modal (\#643);
* Viewer paths page improvements (\#643);
* Added manage buttons on admin task-groups page (\#643);
* Added last used timestamp filter to task-group admin page (\#643);

# 1.10.1

Expand Down
3 changes: 0 additions & 3 deletions examples/config_1/fractal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ FRACTAL_TASKS_DIR=tasks
FRACTAL_LOGGING_LEVEL=00
FRACTAL_RUNNER_BACKEND=local
FRACTAL_RUNNER_WORKING_BASE_DIR=artifacts
DB_ENGINE=sqlite
SQLITE_PATH=fractal_server.db
```

Set-up and start-up command:
Expand All @@ -24,7 +22,6 @@ Logs include
```
INFO: Started server process [32331]
INFO: Waiting for application startup.
2023-05-18 07:55:41,391 - fractal_server.app.db - WARNING - SQLite is supported but discouraged in production. Given its partial support for ForeignKey constraints, consistency of the database cannot be guaranteed.
2023-05-18 07:55:41,742 - fractal_server.main - INFO - User [email protected] created
INFO: Application startup complete.
INFO: Uvicorn running on http://X.X.X.X:8000 (Press CTRL+C to quit)
Expand Down
3 changes: 0 additions & 3 deletions examples/config_2_with_domain/fractal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ FRACTAL_TASKS_DIR=tasks
FRACTAL_LOGGING_LEVEL=00
FRACTAL_RUNNER_BACKEND=local
FRACTAL_RUNNER_WORKING_BASE_DIR=artifacts
DB_ENGINE=sqlite
SQLITE_PATH=fractal_server.db
```

Set-up and start-up command:
Expand All @@ -27,7 +25,6 @@ Logs include
fractal_server.app.db
INFO: Started server process [32375]
INFO: Waiting for application startup.
2023-06-13 08:23:13,678 - fractal_server.app.db - WARNING - SQLite is supported but discouraged in production. Given its partial support for ForeignKey constraints, consistency of the database cannot be guaranteed.
2023-06-13 08:23:13,736 - fractal_server.main - WARNING - User [email protected] already exists
INFO: Application startup complete.
INFO: Uvicorn running on http://fractal.XXX.ch:8000 (Press CTRL+C to quit)
Expand Down
1 change: 0 additions & 1 deletion examples/config_3_with_domain_and_https/fractal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
DEPLOYMENT_TYPE=testing
JWT_SECRET_KEY=XXX
JWT_EXPIRE_SECONDS=80000
DB_ENGINE=postgres-psycopg
POSTGRES_USER=XXX
POSTGRES_HOST=XXX
POSTGRES_DB=XXX
Expand Down
1 change: 0 additions & 1 deletion examples/config_4_with_domain_and_https/fractal_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
DEPLOYMENT_TYPE=testing
JWT_SECRET_KEY=XXX
JWT_EXPIRE_SECONDS=80000
DB_ENGINE=postgres-psycopg
POSTGRES_USER=XXX
POSTGRES_HOST=XXX
POSTGRES_DB=XXX
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineConfig({

webServer: [
{
command: './tests/start-test-server.sh 2.9.0a0',
command: './tests/start-test-server.sh 2.9.0a5',
port: 8000,
waitForPort: true,
stdout: 'pipe',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/v2/tasks/TaskGroupActivities.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
if (activityId && !isNaN(Number(activityId))) {
task_group_activity_id = Number(activityId);
}
if (!admin) {
if (!admin || task_group_activity_id !== null) {
await searchActivities();
}
updateTasksCollectionTimeout = setTimeout(
Expand Down
9 changes: 8 additions & 1 deletion src/lib/components/v2/tasks/TaskGroupInfoModal.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import BooleanIcon from '$lib/components/common/BooleanIcon.svelte';
import TimestampCell from '$lib/components/jobs/TimestampCell.svelte';
import Modal from '../../common/Modal.svelte';
/** @type {import('$lib/types').User} */
Expand Down Expand Up @@ -61,9 +62,15 @@
<li class="list-group-item list-group-item-light fw-bold">Number of files</li>
<li class="list-group-item">{taskGroup.venv_file_number || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Size (MB)</li>
<li class="list-group-item">{(taskGroup.venv_size_in_kB / 1000).toFixed(2)}</li>
<li class="list-group-item">
{taskGroup.venv_size_in_kB ? (taskGroup.venv_size_in_kB / 1000).toFixed(2) : '-'}
</li>
<li class="list-group-item list-group-item-light fw-bold">Pip extras</li>
<li class="list-group-item">{taskGroup.pip_extras || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Last used</li>
<li class="list-group-item">
<TimestampCell timestamp={taskGroup.timestamp_last_used} />
</li>
</ul>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions src/lib/components/v2/tasks/TaskGroupManageModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import { displayStandardErrorAlert, getAlertErrorFromResponse } from '$lib/common/errors';
import Modal from '../../common/Modal.svelte';
/** @type {boolean} */
export let admin;
/** @type {Modal} */
let modal;
Expand Down Expand Up @@ -36,7 +39,9 @@
headers.append('Content-Type', 'application/json');
const response = await fetch(
`/api/v2/task-group/${taskGroup?.id}/${active ? 'reactivate' : 'deactivate'}/`,
`/api/${admin ? 'admin/' : ''}v2/task-group/${taskGroup?.id}/${
active ? 'reactivate' : 'deactivate'
}/`,
{
method: 'POST',
credentials: 'include',
Expand All @@ -48,7 +53,8 @@
if (response.ok) {
const result = await response.json();
goto(`/v2/tasks/activities?activity_id=${result.id}`);
const page = admin ? `/v2/admin/task-groups/activities` : `/v2/tasks/activities`;
goto(`${page}?activity_id=${result.id}`);
modal.hide();
} else {
errorAlert = displayStandardErrorAlert(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/v2/tasks/TaskGroupsTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
{updateEditedTaskGroup}
groupIdsNames={user.group_ids_names || []}
/>
<TaskGroupManageModal bind:this={taskGroupManageModal} />
<TaskGroupManageModal bind:this={taskGroupManageModal} admin={false} />
<TaskInfoModal bind:this={taskInfoModal} />
<TaskEditModal bind:this={taskEditModal} {updateEditedTask} />
Expand Down
1 change: 1 addition & 0 deletions src/lib/types-v2.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export type TaskGroupV2 = {
pip_extras: string;
active: boolean;
timestamp_created: string;
timestamp_last_used: string;
};

export type WorkflowTasksTableRowGroup = {
Expand Down
88 changes: 86 additions & 2 deletions src/routes/v2/admin/task-groups/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script>
import { page } from '$app/stores';
import { getTimestamp } from '$lib/common/component_utilities';
import { displayStandardErrorAlert, getAlertErrorFromResponse } from '$lib/common/errors';
import BooleanIcon from '$lib/components/common/BooleanIcon.svelte';
import ConfirmActionButton from '$lib/components/common/ConfirmActionButton.svelte';
import Modal from '$lib/components/common/Modal.svelte';
import TimestampCell from '$lib/components/jobs/TimestampCell.svelte';
import TaskGroupEditModal from '$lib/components/v2/tasks/TaskGroupEditModal.svelte';
import TaskGroupManageModal from '$lib/components/v2/tasks/TaskGroupManageModal.svelte';
/** @type {Array<import('$lib/types').User>} */
const users = $page.data.users;
Expand All @@ -19,6 +22,10 @@
let privateGroup = null;
/** @type {boolean|null} */
let active = null;
let lastUsedDateMin;
let lastUsedTimeMin = '';
let lastUsedDateMax = '';
let lastUsedTimeMax = '';
let searched = false;
let searching = false;
Expand All @@ -35,6 +42,8 @@
/** @type {import('$lib/components/v2/tasks/TaskGroupEditModal.svelte').default} */
let taskGroupEditModal;
/** @type {import('$lib/components/v2/tasks/TaskGroupManageModal.svelte').default} */
let taskGroupManageModal;
async function searchTaskGroups() {
searching = true;
Expand All @@ -61,6 +70,14 @@
if (active !== null) {
url.searchParams.append('active', active.toString());
}
const lasUsedTimestampMin = getTimestamp(lastUsedDateMin, lastUsedTimeMin);
if (lasUsedTimestampMin) {
url.searchParams.append('timestamp_last_used_min', lasUsedTimestampMin);
}
const lasUsedTimestampMax = getTimestamp(lastUsedDateMax, lastUsedTimeMax);
if (lasUsedTimestampMax) {
url.searchParams.append('timestamp_last_used_max', lasUsedTimestampMax);
}
const response = await fetch(url);
if (!response.ok) {
searchErrorAlert = displayStandardErrorAlert(
Expand All @@ -84,6 +101,10 @@
user_group_id = '';
pkg_name = '';
origin = '';
lastUsedDateMin = '';
lastUsedTimeMin = '';
lastUsedDateMax = '';
lastUsedTimeMax = '';
privateGroup = null;
active = null;
searched = false;
Expand Down Expand Up @@ -233,6 +254,48 @@
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-md-3 col-lg-2 mt-2">Last used</div>
<div class="col-md-9 col-lg-10">
<div class="row row-cols-md-auto">
<div class="col-12 mt-1">
<div class="input-group">
<div class="input-group-text">Min</div>
<input
type="date"
class="form-control"
bind:value={lastUsedDateMin}
id="last_used_date_min"
/>
<input
type="time"
class="form-control"
bind:value={lastUsedTimeMin}
id="last_used_time_min"
/>
</div>
</div>
<div class="col-12 mt-1">
<div class="input-group">
<div class="input-group-text">Max</div>
<input
type="date"
class="form-control"
bind:value={lastUsedDateMax}
id="last_used_date_max"
/>
<input
type="time"
class="form-control"
bind:value={lastUsedTimeMax}
id="last_used_time_max"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -266,7 +329,7 @@
<col width="90" />
<col width="90" />
<col width="90" />
<col width="270" />
<col width="400" />
</colgroup>
<thead>
<tr>
Expand Down Expand Up @@ -303,6 +366,10 @@
<i class="bi bi-pencil" />
Edit
</button>
<button class="btn btn-info" on:click={() => taskGroupManageModal.open(taskGroup)}>
<i class="bi bi-gear" />
Manage
</button>
<ConfirmActionButton
modalId="confirmTaskGroupDeleteModal{taskGroup.pkg_name}"
style={'danger'}
Expand Down Expand Up @@ -330,8 +397,9 @@
updateEditedTaskGroup={searchTaskGroups}
groupIdsNames={groups.map((g) => [g.id, g.name])}
/>
<TaskGroupManageModal bind:this={taskGroupManageModal} admin={true} />
<Modal id="taskInfoModal" bind:this={infoModal} size="lg" onClose={onInfoModalClose}>
<Modal id="taskInfoModal" bind:this={infoModal} size="xl" onClose={onInfoModalClose}>
<svelte:fragment slot="header">
<h1 class="h5 modal-title flex-grow-1">Task-group info</h1>
</svelte:fragment>
Expand Down Expand Up @@ -360,8 +428,20 @@
<li class="list-group-item">{selectedTaskGroup.path || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Venv path</li>
<li class="list-group-item">{selectedTaskGroup.venv_path || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Number of files</li>
<li class="list-group-item">{selectedTaskGroup.venv_file_number || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Size (MB)</li>
<li class="list-group-item">
{selectedTaskGroup.venv_size_in_kB
? (selectedTaskGroup.venv_size_in_kB / 1000).toFixed(2)
: '-'}
</li>
<li class="list-group-item list-group-item-light fw-bold">Pip extras</li>
<li class="list-group-item">{selectedTaskGroup.pip_extras || '-'}</li>
<li class="list-group-item list-group-item-light fw-bold">Last used</li>
<li class="list-group-item">
<TimestampCell timestamp={selectedTaskGroup.timestamp_last_used} />
</li>
</ul>
{/if}
</svelte:fragment>
Expand All @@ -384,4 +464,8 @@
.row-grey {
background-color: #f2f2f2;
}
input[type='date'] {
min-width: 190px;
}
</style>
6 changes: 4 additions & 2 deletions src/routes/viewer-paths/+page.server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentUserViewerPaths } from '$lib/server/api/auth_api.js';
import { getCurrentUserSettings, getCurrentUserViewerPaths } from '$lib/server/api/auth_api.js';
import { getLogger } from '$lib/server/logger.js';

const logger = getLogger('viewer paths page');
Expand All @@ -7,8 +7,10 @@ export async function load({ fetch }) {
logger.trace('Load viewer paths page');

const viewerPaths = await getCurrentUserViewerPaths(fetch);
const settings = await getCurrentUserSettings(fetch);

return {
viewerPaths
viewerPaths,
settings
};
}
29 changes: 28 additions & 1 deletion src/routes/viewer-paths/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,40 @@
import { page } from '$app/stores';
/** @type {string[]} */
let viewerPaths = $page.data.viewerPaths;
const viewerPaths = $page.data.viewerPaths;
/** @type {import('$lib/types').UserSettings} */
const settings = $page.data.settings;
</script>

<h1 class="fw-light mb-3">Viewer paths</h1>

<p>
This Fractal instance includes an online viewer for OME-Zarrs, based on
<a href="https://github.com/hms-dbmi/vizarr" target="_blank">vizarr</a>. Browse to a dataset page,
and you will find links to view the available images in the browser.
</p>

<p>
Note that access to image data is restricted to OME-Zarrs within certain paths (and their
subfolders).
{#if settings.project_dir || viewerPaths.length > 0}
The list of paths accessible to the current user includes:
{:else}
The list of paths accessible to the current user is empty.
{/if}
</p>

<ul>
{#if settings.project_dir}
<li><code>{settings.project_dir}</code></li>
{/if}
{#each viewerPaths as viewerPath}
<li><code>{viewerPath}</code></li>
{/each}
</ul>

<p>
Depending on the Fractal configuration, you may also have access to additional paths.<br />
Please contact an admin if you see an error message like <code>403 Forbidden</code> when opening the
image viewer.
</p>
1 change: 0 additions & 1 deletion tests/.fractal_server.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DEPLOYMENT_TYPE=testing
JWT_SECRET_KEY=somethingverysecret
DB_ENGINE=postgres-psycopg
POSTGRES_DB=fractal_test
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Expand Down
Loading

0 comments on commit 2d13474

Please sign in to comment.