From 1b637fe52737bdb74948a5deec4beb5d12962920 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sun, 15 Oct 2023 12:21:23 +0200 Subject: [PATCH 1/2] Fix get_dataset_size for datasets with null file_size column Fixes: ``` Oct 13 14:29:40 galaxy-vgp galaxyctl[2536822]: File "/cvmfs/main.galaxyproject.org/venv/lib/python3.8/site-packages/tpv/core/helpers.py", line 16, in get_dataset_size Oct 13 14:29:40 galaxy-vgp galaxyctl[2536822]: return float(dataset.file_size) Oct 13 14:29:40 galaxy-vgp galaxyctl[2536822]: TypeError: float() argument must be a string or a number, not 'NoneType' ``` There's an underlying bug as well where the job state is final but the file size is unset, but I would always consider it better to use one abstraction level above the database column. --- tpv/core/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tpv/core/helpers.py b/tpv/core/helpers.py index 898032e..3ddf504 100644 --- a/tpv/core/helpers.py +++ b/tpv/core/helpers.py @@ -13,7 +13,9 @@ def get_dataset_size(dataset): - return float(dataset.file_size) + # calculate_size would mark file_size column as dirty + # and may have unintended consequences + return float(dataset.get_size(calculate_size=False)) def sum_total(prev, current): From 9ebb84d56a579ad43a78d0d2baf7cab7b3e5e3bd Mon Sep 17 00:00:00 2001 From: nuwang <2070605+nuwang@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:48:38 +0530 Subject: [PATCH 2/2] Add get_size method to mock dataset --- tpv/commands/test/mock_galaxy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tpv/commands/test/mock_galaxy.py b/tpv/commands/test/mock_galaxy.py index 6f021e9..08deb69 100644 --- a/tpv/commands/test/mock_galaxy.py +++ b/tpv/commands/test/mock_galaxy.py @@ -43,6 +43,9 @@ def __init__(self, file_name, file_size): self.file_name = file_name self.file_size = file_size + def get_size(self, calculate_size=False): + return self.file_size + # Tool mock and helpers========================================= class Tool: