Skip to content

Commit 3dc0ec3

Browse files
committed
CSCDESTINCLIMADT-794: Force the function get_in_queue_grouped_id to return a list.
- Added mypy types - Added unit and integration tests - Changed the order at which ``JobList.save_wrappers`` is called in ``autosubmit/autosubmit.py`` - Added docstrings, and fixed linter errors (to debug/see code execution)
1 parent 435d093 commit 3dc0ec3

33 files changed

+1517
-1050
lines changed

CHANGELOG.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ release.
2626
- Fixed bug where an RO-Crate file would include itself in the archive, as well as other zip files.
2727
Now Autosubmit uses the pattern $expid-crate-$date-$time-$millisecond.zip, and ignores any ZIP files
2828
in the tmp/ASLOGS that start with $expid-crate and end with .zip #2692
29+
- Fixed "Unexpected error: 'list' object has no attribute 'status'" when running experiments #2463
2930

3031
**Enhancements:**
3132

@@ -168,7 +169,7 @@ the filter the jobs. Not using any value for `-fp` still returns all jobs.
168169

169170
**Others:**
170171
- All autosubmit projects moved to Github.
171-
- Added Github actions for CI/CD.
172+
- Added GitHub actions for CI/CD.
172173

173174
4.1.11 - Enhancements, New Features, Documentation, and Bug Fixes
174175
=================================================================
@@ -240,15 +241,13 @@ Others:
240241
- Fixes an issue with dependency not being linked.
241242
- Docs improved.
242243

243-
244244
4.1.8 - Bug fixes.
245245
==================
246246
- Fixed an issue with a socket connection left open.
247247
- Fixed an issue with log recovery being disabled by default.
248248
- Added exclusive parameter
249249
- Fixed some X11 routines called by default
250250

251-
252251
4.1.7 - X11, Migrate, script and Bug fixes
253252
==========================================
254253
- Migrate added, a feature to change the ownership of the experiments (/scratch and autosubmit_data paths)
@@ -296,9 +295,6 @@ Others:
296295
- Added RO-Crate.
297296
- Added Calendar for splits.
298297

299-
300-
301-
302298
4.1.2 - Bug fixes
303299
=================
304300
- Fixed issues with version.

autosubmit/autosubmit.py

Lines changed: 346 additions & 386 deletions
Large diffs are not rendered by default.

autosubmit/config/configcommon.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,14 +1599,14 @@ def check_wrapper_conf(self, wrappers=None, no_log=False):
15991599
if 'horizontal' in self.get_wrapper_type(wrapper_values):
16001600
if not self.experiment_data["PLATFORMS"][platform_name].get('PROCESSORS_PER_NODE', None):
16011601
self.wrong_config["WRAPPERS"] += [
1602-
[wrapper_name, "PROCESSORS_PER_NODE no exist in the horizontal-wrapper platform"]]
1602+
[wrapper_name, "PROCESSORS_PER_NODE does not exist in the horizontal-wrapper platform"]]
16031603
if not self.experiment_data["PLATFORMS"][platform_name].get('MAX_PROCESSORS', ""):
16041604
self.wrong_config["WRAPPERS"] += [[wrapper_name,
1605-
"MAX_PROCESSORS no exist in the horizontal-wrapper platform"]]
1605+
"MAX_PROCESSORS does not exist in the horizontal-wrapper platform"]]
16061606
if 'vertical' in self.get_wrapper_type(wrapper_values):
16071607
if not self.experiment_data.get("PLATFORMS", {}).get(platform_name, {}).get('MAX_WALLCLOCK', ""):
16081608
self.wrong_config["WRAPPERS"] += [[wrapper_name,
1609-
"MAX_WALLCLOCK no exist in the vertical-wrapper platform"]]
1609+
"MAX_WALLCLOCK does not exist in the vertical-wrapper platform"]]
16101610
if "WRAPPERS" not in self.wrong_config:
16111611
if not no_log:
16121612
Log.result('wrappers OK')
@@ -2497,7 +2497,7 @@ def get_notifications(self) -> str:
24972497

24982498
# based on https://github.com/cbirajdar/properties-to-yaml-converter/blob/master/properties_to_yaml.py
24992499
@staticmethod
2500-
def ini_to_yaml(root_dir: Path, ini_file: str) -> None:
2500+
def ini_to_yaml(root_dir: Path, ini_file: Union[str, Path]) -> None:
25012501
# Based on http://stackoverflow.com/a/3233356
25022502
def update_dict(original_dict: dict, updated_dict: collections.abc.Mapping) -> dict:
25032503
for k, v in updated_dict.items():
@@ -2564,6 +2564,8 @@ def get_remote_dependencies(self) -> str:
25642564
"""
25652565
# Disabled, forced to "false" not working anymore in newer slurm versions.
25662566
# return str(self.get_section(['CONFIG', 'PRESUBMISSION'], "false")).lower()
2567+
# FIXME: deprecate and/or remove PRESUBMISSION as it's not working on Slurm now?
2568+
# https://github.com/BSC-ES/autosubmit/issues/2548
25672569
return "false"
25682570

25692571
def get_wrapper_type(self, wrapper=None) -> Optional[str]:

autosubmit/experiment/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2015-2025 Earth Sciences Department, BSC-CNS
2+
#
3+
# This file is part of Autosubmit.
4+
#
5+
# Autosubmit is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# Autosubmit is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with Autosubmit. If not, see <http://www.gnu.org/licenses/>.
17+
18+
"""Code to manage Autosubmit experiments."""

autosubmit/experiment/detail_updater.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
31
# Copyright 2015-2025 Earth Sciences Department, BSC-CNS
42
#
53
# This file is part of Autosubmit.
@@ -17,23 +15,22 @@
1715
# You should have received a copy of the GNU General Public License
1816
# along with Autosubmit. If not, see <http://www.gnu.org/licenses/>.
1917

20-
from abc import ABC, abstractmethod
2118
import datetime
2219
import pwd
23-
from pathlib import Path
2420
import sqlite3
21+
from abc import ABC, abstractmethod
22+
from pathlib import Path
2523
from typing import Any, Dict, Union
2624

2725
from sqlalchemy import Table
28-
from autosubmit.database.db_common import get_connection_url, get_experiment_id
29-
from autosubmit.config.configcommon import AutosubmitConfig
26+
3027
from autosubmit.config.basicconfig import BasicConfig
28+
from autosubmit.config.configcommon import AutosubmitConfig
3129
from autosubmit.config.yamlparser import YAMLParserFactory
32-
30+
from autosubmit.database.db_common import get_connection_url, get_experiment_id
3331
from autosubmit.database.session import create_engine
3432
from autosubmit.database.tables import get_table_from_name
3533

36-
3734
LOCAL_TZ = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
3835

3936

autosubmit/experiment/experiment_common.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717

1818
"""Module containing functions to manage autosubmit's experiments."""
1919

20+
import os
21+
import pwd
2022
import string
2123
from pathlib import Path
24+
from typing import Optional
2225

26+
from autosubmit.config.basicconfig import BasicConfig
2327
from autosubmit.database import db_common
2428
from autosubmit.log.log import Log, AutosubmitCritical
2529

@@ -205,3 +209,31 @@ def create_required_folders(exp_id: str, exp_folder: Path) -> None:
205209
required_dirs = ["conf", "pkl", "tmp", "tmp/ASLOGS", f"tmp/LOG_{exp_id}", "plot", "status"]
206210
for required_dir in required_dirs:
207211
Path(exp_folder / required_dir).mkdir(mode=dir_mode)
212+
213+
214+
def check_ownership(expid, raise_error=False) -> tuple[bool, bool, Optional[str]]:
215+
"""Check if the user owns and if it is eadmin.
216+
217+
:return: the owner, eadmin, and current_owner
218+
"""
219+
current_owner: Optional[str] = None
220+
current_owner_id = Path(BasicConfig.LOCAL_ROOT_DIR, expid).stat().st_uid
221+
try:
222+
current_owner = pwd.getpwuid(current_owner_id).pw_name
223+
except (TypeError, KeyError) as e:
224+
Log.warning(f"Current owner of experiment {expid} could not be retrieved. The owner is no longer in the "
225+
f"system database: {str(e)}")
226+
227+
eadmin: bool = False
228+
admin_user = "eadmin" # to be improved in #944
229+
current_user_id = os.getuid()
230+
try:
231+
eadmin = current_user_id == pwd.getpwnam(admin_user).pw_uid
232+
except Exception as e:
233+
Log.info(f"Autosubmit admin user: {admin_user} is not set: {str(e)}")
234+
235+
owner: bool = current_owner_id == current_user_id
236+
if not owner and raise_error:
237+
raise AutosubmitCritical(f"You don't own the experiment {expid}.", 7012)
238+
239+
return owner, eadmin, current_owner

0 commit comments

Comments
 (0)