Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f2ebabf
In test instances host is not False since it has http:// prefixed to …
glormph Apr 27, 2026
fdc114b
Barebones TUI client for uploads using Textual
glormph Apr 28, 2026
54be47e
First try at gha for building client pkg
glormph Apr 28, 2026
d507ea2
Add pr trigger to be able to test outside master
glormph Apr 28, 2026
f9809ea
Typos in building yml
glormph Apr 28, 2026
f7d0118
Correct path in win TUI builder, add upload of artfact
glormph Apr 28, 2026
11ac9c8
correct path
glormph Apr 28, 2026
23b8820
Try overwriting artifact to see if we can list downloads of it withou…
glormph Apr 29, 2026
d318cf0
Have one release and one testing action for client building.
glormph Apr 30, 2026
5dd3a05
Release upload client when its code changed on master, by creating a …
glormph May 4, 2026
fdf40a8
Soft closing of projects implementation - now you can press a button …
glormph May 5, 2026
3a9c7d3
Expiring projects need to be shown in table, and need to be able to u…
glormph May 6, 2026
9b5715e
Add external ref to CF swimmer plot, and fix usernames not there when…
glormph May 6, 2026
efc6fd3
Use username when showing analysis/dataset table default
glormph May 6, 2026
eef7aba
Delete empty directory is also run when running auto-deleter
glormph May 6, 2026
a7a302e
Ordered stages in CF plots so Acquisition is not first, added a proje…
glormph May 6, 2026
0cb5795
Fix phase out/close in corefac, fix some cf plots problems
glormph May 7, 2026
da35d96
Somehow could not resume held jobs. Fixed that
glormph May 7, 2026
381162e
Migrations and README update
glormph May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/package_upload_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: build-upload-uploadclient
run-name: Build and upload client TUI executables
on:
pull_request:
branches:
- master

workflow_call:
outputs:
macos_client:
description: "Artifact ID for macOS client"
value: ${{ jobs.macos.outputs.client-artifact-id }}
win_client:
description: "Artifact ID for windows client"
value: ${{ jobs.windows.outputs.client-artifact-id }}

jobs:
windows:
runs-on: windows-latest
outputs:
client-artifact-id: ${{ steps.upload-windows.outputs.artifact-id }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.13'

- name: Build win TUI client
run: |
cd src/backend/rawstatus/file_inputs/tui/
python -m venv buildvenv
buildvenv/Scripts/Activate.ps1
python -m pip install -r requirements.txt
pyinstaller --path buildvenv/Lib/site-packages --add-data kantele_uploads.css:. --onefile kantele_client.py
mv dist/kantele_client.exe dist/kantele_client_win.exe

- name: Upload artifact
id: upload-windows
uses: actions/upload-artifact@v4
with:
name: kantele_client_win.exe
path: src/backend/rawstatus/file_inputs/tui/dist/kantele_client_win.exe
archive: false
retention-days: 1


macos:
runs-on: macos-26
outputs:
client-artifact-id: ${{ steps.upload-macos.outputs.artifact-id }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.13'

- name: Build mac TUI client
run: |
cd src/backend/rawstatus/file_inputs/tui/
python -m venv buildvenv
source buildvenv/bin/activate
python -m pip install -r requirements.txt
pyinstaller --path buildvenv/lib/python3.13/site-packages --add-data kantele_uploads.css:. --onefile kantele_client.py
mv dist/kantele_client dist/kantele_client_macos

- name: Upload artifact
id: upload-macos
uses: actions/upload-artifact@v4
with:
name: kantele_client_macos
path: src/backend/rawstatus/file_inputs/tui/dist/kantele_client_macos
archive: false
retention-days: 1
38 changes: 38 additions & 0 deletions .github/workflows/release_upload_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: release-uploadclient
run-name: Build upload client TUI executables, delete old ones, and keep new ones
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'src/backend/rawstatus/file_inputs/tui/*'

jobs:
package-client:
uses: ./.github/workflows/package_upload_client.yml

release-client:
runs-on: ubuntu-latest
needs: package-client
steps:
- name: Download artifacts to runner
uses: actions/download-artifact@v8
with:
artifact-ids: "${{ needs.package-client.outputs.macos_client }},${{ needs.package-client.outputs.macos_client }}"
merge-multiple: true

- name: Get date for release, latest commit
shell: bash
run: |
echo "COMMIT_DATE=$(git show -s --format=%cd --date=short)"

- name: Release client and upload artifacts
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: false
tag: "uploadclient-release-${{ env.COMMIT_DATE }}"
name: "Upload client package ${{ env.COMMIT_DATE }}"
artifacts: 'kantele_client_macos,kantele_client_win.exe'

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Kantele

## Core facility
Core facility has its own top level page, where projects are plotted that are of core facility
type. These plots are populated with data selected from a project table, which functions as in
the home page, i.e. one can filter on user, name, dates, type, activity, expiration, etc.
It is possible to close projects in this page, as well as phasing out of projects (i.e. closes
and sets an expiration date). In the default table all open CF projects are shown. Closing or phasing out a project will mark them with a ✅ in the plots.

## Auto-deletion
A cron job exists (TODO, currently not running) for a custom Django command to delete expired files.
This can be run by hand as well, like this:
```
docker compose [options] exec web python manage.py delete_expired_files --help
```
Using `--dry-run` will only show the potential files to be deleted, otherwise one can also specify
e.g. `--analysis`, `--datasets`, etc. The command will queue files for deletion:
- files in INBOX which are also in a dataset
- files in datasets on shares with an expiry time (e.g. sensitive data, space-constrained analysis cluster)
- Also other files in shares with an expiry time, e.g. analysis output, library files, web-served report files
- mzML converted files which have a configured lifespan in `settings.py`


## Development, before starting
Prerequisites:

Expand Down
2 changes: 1 addition & 1 deletion src/backend/analysis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ def renew_token(request):
rm.UploadFileType.ANALYSIS)
analysis.externalanalysis.last_token = new_token
analysis.externalanalysis.save()
host = settings.KANTELEHOST or request.build_absolute_uri('/')
host = settings.KANTELEHOST if settings.KANTELEHOST_NOPROTO else request.build_absolute_uri('/')
api_token = new_token.parse_token_for_frontend(host)
return JsonResponse({'error': False, 'token': api_token})

Expand Down
67 changes: 36 additions & 31 deletions src/backend/corefac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from corefac import models as cm
from rawstatus import models as rm
from datasets import models as dm
from datasets import views as dv
from analysis import models as am
from jobs import models as jm
from jobs import jobs as jj
Expand Down Expand Up @@ -64,18 +63,24 @@ class Stages(StrEnum):
closeprojdates[closeplog['project_id']] = datetime.strftime(closeplog['lastclose'], datefmt)

perprojects = []
# Firstdate is first date in entire plot
firstdate = timezone.now()
today = timezone.now()
ds_owners = {}
for dp in dm.Dataset.objects.filter(runname__experiment__project_id__in=data['proj_ids']
).values('pk', 'locked', 'runname__experiment__project__registered',
).values('pk', 'locked', 'deleted', 'runname__experiment__project__registered',
'runname__name', 'runname__experiment__name',
'runname__experiment__project__externalref',
'runname__experiment__project__name', 'runname__experiment__project_id',
'runname__experiment__project__active'):
bartext = (f'{dp["runname__experiment__project__name"]} / {dp["runname__experiment__name"]} '
f'/ {dp["runname__name"]}')
if dp['runname__experiment__project__externalref']:
bartext = f'{dp["runname__experiment__project__externalref"]} - {bartext}'
projid = dp['runname__experiment__project_id']
owner_q = dm.DatasetOwner.objects.filter(dataset_id=dp['pk']).values('user__username')
ds_owners[dp['pk']] = owner_q.first()['user__username']
ana_pp = False
if anas := am.Analysis.objects.filter(datasetanalysis__dataset_id=dp['pk']).values('date',
'pk').order_by('date'):
# Create a "search" bar segment
Expand All @@ -92,9 +97,9 @@ class Stages(StrEnum):
end = lastjob['timestamp']
else:
end = today
perprojects.append({'proj': bartext, 'dset': dp['pk'],
'stage': Stages.SEARCH, 'start': anadate, 'end': end})

ana_pp = {'proj': bartext, 'projid': projid, 'dset': dp['pk'],
'stage': Stages.SEARCH, 'start': anadate, 'end': end}
perprojects.append(ana_pp)
# Raws can come way before project opening, so lets start with them
firstfile_date = False
if raws := rm.RawFile.objects.filter(datasetrawfile__dataset_id=dp['pk']).order_by('date'
Expand All @@ -103,8 +108,8 @@ class Stages(StrEnum):
if firstfile_date < firstdate:
firstdate = firstfile_date
rawpp = {'proj': bartext, 'dset': dp['pk'], 'stage': Stages.MS, 'start': firstfile_date,
}
if dp['locked'] or anas:
'projid': projid, }
if anas or dp['locked'] or dp['deleted'] or not dp['runname__experiment__project__active']:
sf = rm.StoredFile.objects.values('regdate').get(rawfile_id=raws.last()['pk'],
mzmlfile__isnull=True)
# Use regdate on last file to include the time spent transferring
Expand All @@ -115,55 +120,54 @@ class Stages(StrEnum):
openpp = False
opendate = dp['runname__experiment__project__registered']
if not firstfile_date or opendate < firstfile_date:
# Normal, opening of project before acquisition of files
if opendate < firstdate:
firstdate = opendate
firstbar_start = opendate
openpp = {'proj': bartext, 'dset': dp['pk'],
openpp = {'proj': bartext, 'projid': projid, 'dset': dp['pk'],
'open': dp['runname__experiment__project__active'],
'pid': dp['runname__experiment__project_id'],
'stage': Stages.OPENED, 'start': opendate,
'first': True}
else:
elif raws:
# The opening of project was done after acquisition of files
rawpp.update({'first': True, 'pid': dp['runname__experiment__project_id'],
'open': dp['runname__experiment__project__active'],
})
# We dont put a project opened bar
rawpp.update({'first': True, 'open': dp['runname__experiment__project__active']})
firstbar_start = firstfile_date
if raws:
perprojects.append(rawpp)

track_pipeline = False
if openpp:
firststage = openpp['start']
elif firstfile_date:
firststage = firstfile_date

for tr in cm.DatasetPrepTracking.objects.filter(dspipe__dataset_id=dp['pk']).order_by(
'timestamp'):
track_pipeline = True
if tr.stage == cm.TrackingStages.SAMPLESREADY and tr.timestamp > firstbar_start:
if tr.stage == cm.TrackingStages.SAMPLESREADY and (tr.timestamp - firstbar_start).days >= 0:
# Normal, i.e first opened proj, then samples arrive
# compare days >= 0 since one can open project (timestamped with actuaal time) and
# press samples ready (only timestamped with day, 0:00, as it is picked in calendar)
if openpp:
openpp['end'] = tr.timestamp
pp = {'proj': bartext, 'dset': dp['pk'],
pp = {'proj': bartext, 'projid': projid, 'dset': dp['pk'],
'stage': Stages.SAMPLES, 'start': tr.timestamp}

elif tr.stage == cm.TrackingStages.SAMPLESREADY:
# Samples ready before opening project
pp = {'proj': bartext, 'dset': dp['pk'],
'stage': Stages.SAMPLES, 'start': tr.timestamp}
# Samples ready before opening project, backdated by user
# we dont do open project bar
openpp = False
pp = {'proj': bartext, 'first': True, 'projid': projid, 'dset': dp['pk'],
'open': dp['runname__experiment__project__active'], 'stage': Stages.SAMPLES,
'start': tr.timestamp}

elif tr.stage == cm.TrackingStages.PREPSTARTED and pp['stage'] == Stages.SAMPLES:
pp['end'] = tr.timestamp
perprojects.append(pp)
pp = {'proj': bartext, 'dset': dp['pk'],
pp = {'proj': bartext, 'projid': projid, 'dset': dp['pk'],
'stage': Stages.PREP, 'start': tr.timestamp}
elif tr.stage == cm.TrackingStages.PREPFINISHED and pp['stage'] == Stages.PREP:
pp['end'] = tr.timestamp
perprojects.append(pp)

elif tr.stage == cm.TrackingStages.MSQUEUED:
pp = {'proj': bartext, 'dset': dp['pk'],
pp = {'proj': bartext, 'projid': projid, 'dset': dp['pk'],
'stage': Stages.QUEUE, 'start': tr.timestamp}

if track_pipeline:
Expand All @@ -173,10 +177,9 @@ class Stages(StrEnum):
else:
pp['end'] = today
elif 'end' not in pp:
if dp['locked']:
lockdate = dm.ProjectLog.objects.filter(project_id=dp['runname__experiment__project_id'],
level=dm.ProjLogLevels.INFO, message__endswith=f'locked dataset {dp["pk"]}')
pp['end'] = lockdate.values('date').last()['date']
possible_tracking_end = []
if raws:
pp['end'] = rawpp['start']
else:
pp['end'] = today
perprojects.append(pp)
Expand All @@ -202,11 +205,13 @@ class Stages(StrEnum):
pp['fsize'] = files.aggregate(Sum('size'))['size__sum']
pp['mstime'] = msfiles.aggregate(Sum('mstime'))['mstime__sum'] or 0
mstimes[pp['dset']] = pp['mstime']
pp['owner'] = ds_owners[pp['dset']]

for pp in perprojects:
# Mark last segments in dset, add open/owner and start of dset there
if lastdates[pp['dset']] == pp['end']:
pp['last'] = True
pp['duration'] = (lastdates[pp['dset']] - firstdates_open[pp['dset']][0]).days
pp['startdset'] = firstdates_open[pp['dset']][0]
pp['open'] = firstdates_open[pp['dset']][1]
pp['owner'] = ds_owners[pp['dset']]
Expand All @@ -216,8 +221,8 @@ class Stages(StrEnum):
'end': datetime.strftime(x['end'], datefmt)}) for x in perprojects]

return JsonResponse({'per_proj': perprojects, 'closedates': closeprojdates, 'today': today,
'firstdate': datetime.strftime(firstdate, datefmt)})

'firstdate': datetime.strftime(firstdate, datefmt), 'stage_order': [
Stages.OPENED, Stages.SAMPLES, Stages.PREP, Stages.QUEUE, Stages.MS, Stages.SEARCH]})

@login_required
def find_sampleprep_method(request):
Expand Down
23 changes: 23 additions & 0 deletions src/backend/datasets/migrations/0027_projectexpiry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2 on 2026-05-06 10:17

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('datasets', '0026_alter_dataset_securityclass'),
]

operations = [
migrations.CreateModel(
name='ProjectExpiry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateTimeField()),
('active', models.BooleanField(default=True)),
('project', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='datasets.project')),
],
),
]
20 changes: 20 additions & 0 deletions src/backend/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ class ProjectLog(models.Model):
message = models.TextField()


class ProjectExpiry(models.Model):
'''When project is set to expire, it will behave as a closed project, i.e.
active=False
- it is not possible to make new datasets,
- it is not possible to add files to existing datasets
But, its data will be available until the expiry date is finished
- Raws are still on disk
- You can still run an analysis on the datasets
A record in this table is treated as a job, not a log, so changes to expiry, or
expiry/reopen/new expire will not be tracked
'''
project = models.OneToOneField(Project, on_delete=models.CASCADE)
date = models.DateTimeField()
# active is basically now() < date, but its fast and easy to do a boolean lookup
# and also need to know if an expired project has been cleaned up
# active is updated in a cron job that runs delete_expired_files
# so if that is not running, it will never update
active = models.BooleanField(default=True)


class UserPtype(models.Model):
# FIXME deprecate, we dont use this? is_staff now is used for CF users
# probably not a good idea anyway
Expand Down
Loading
Loading