Skip to content
Snippets Groups Projects
Commit 5e8fe540 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '3279-default-scan_saving-base_path-points-to-tmp-scans' into 'master'

Resolve "Default SCAN_SAVING.base_path points to /tmp/scans"

Closes #3279

See merge request bliss/bliss!4619
parents 153857bb 3e1c79f7
No related branches found
No related tags found
No related merge requests found
......@@ -1257,8 +1257,8 @@ class ParametersWardrobe(metaclass=ParametersType):
**keys: other key,value pairs will be directly passed to Redis proxy
"""
logger.debug(
"""In %s.__init__(%s,
default_values=%s,
"""In %s.__init__(%s,
default_values=%s,
property_attributes=%s,
not_removable=%s
)""",
......@@ -1581,7 +1581,7 @@ class ParametersWardrobe(metaclass=ParametersType):
def _repr(self, d):
rep_str = (
f"Parameters ({self.current_instance}) - "
f"Parameters ({self.current_instance}) -"
+ " | ".join(self.instances[1:])
+ "\n\n"
)
......
......@@ -20,6 +20,8 @@ from functools import wraps
import logging
import datetime
import enum
from tempfile import gettempdir
from pathlib import Path
from typing import Optional, Tuple, Union
from bliss import current_session
......@@ -314,7 +316,7 @@ class BasicScanSaving(EvalParametersWardrobe):
DEFAULT_VALUES = {
# default and not removable values
"base_path": "/tmp/scans",
"base_path": gettempdir() + "/scans",
"data_filename": "data",
"template": "{session}/",
"images_path_relative": True,
......@@ -731,7 +733,10 @@ class BasicScanSaving(EvalParametersWardrobe):
def on_scan_run(self, save):
"""Called at the start of a scan (in Scan.run)"""
pass
if Path(gettempdir()) in Path(self.root_path).parents:
logtools.user_warning(
f"Scan data are currently saved under {gettempdir()}, where files are volatile."
)
def set_expiration_time(self, data_db_names, parent_db_names):
"""Set the expiration time of all Redis keys associated to this scan"""
......
......@@ -5,6 +5,8 @@
# Copyright (c) 2015-2022 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from tempfile import gettempdir
from bliss.common.session import set_current_session
from bliss.scanning.scan_saving import ESRFScanSaving, ESRFDataPolicyEvent
......@@ -16,6 +18,7 @@ def set_esrf_config(scan_saving, base_path):
assert isinstance(scan_saving, ESRFScanSaving)
scan_saving_config = scan_saving.scan_saving_config
roots = ["inhouse_data_root", "visitor_data_root", "tmp_data_root"]
default_path = gettempdir() + "/scans"
for root in roots:
for prefix in ["", "icat_"]:
key = prefix + root
......@@ -23,10 +26,10 @@ def set_esrf_config(scan_saving, base_path):
if mount_points is None:
continue
elif isinstance(mount_points, str):
scan_saving_config[key] = mount_points.replace("/tmp/scans", base_path)
scan_saving_config[key] = mount_points.replace(default_path, base_path)
else:
for mp in mount_points:
mount_points[mp] = mount_points[mp].replace("/tmp/scans", base_path)
mount_points[mp] = mount_points[mp].replace(default_path, base_path)
def set_esrf_data_policy(session):
......
......@@ -69,7 +69,7 @@ def test_broken_metadata_doesnt_prevent_scan(
with mock.patch.object(machinfo, "scan_metadata", side_effect=RuntimeError("abc")):
s = loopscan(1, 0.1, machinfo)
expected = "ERROR: error in generating metadata from controller 'machinfo'\n"
assert capsys.readouterr().err == expected
assert capsys.readouterr().err.endswith(expected)
assert s.get_data()
......
......@@ -74,7 +74,7 @@ def test_scan_saving_path(writer, session):
}
assert getdict == expected
scan_saving_repr = """Parameters (default) -
scan_saving_repr = """Parameters (default) -
.base_path = '{base_path}'
.data_filename = '{{session}}_{{scan_name}}_data'
......@@ -331,3 +331,11 @@ def test_scan_saving_writer_options(session):
},
"separate_scan_files": True,
}
def test_scan_saving_warning_tmpdir(session, capsys, log_shell_mode):
sct(session.env_dict["diode"])
expected = (
"WARNING: Scan data are currently saved under /tmp, where files are volatile.\n"
)
assert expected in capsys.readouterr().err
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment