From a05cca5828bf47eda00cae9cb8e759d3de3f796d Mon Sep 17 00:00:00 2001 From: jepegit Date: Fri, 8 Dec 2023 20:44:35 +0100 Subject: [PATCH] possible fix for filefinder ('find') --- cellpy/readers/filefinder.py | 25 ++++++++++++++++++------- cellpy/utils/batch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/cellpy/readers/filefinder.py b/cellpy/readers/filefinder.py index cd098a4b..fd69a349 100644 --- a/cellpy/readers/filefinder.py +++ b/cellpy/readers/filefinder.py @@ -5,6 +5,7 @@ import logging import os import pathlib +import sys import time from typing import Optional, Union, List, Tuple import warnings @@ -91,18 +92,28 @@ def find_in_raw_file_directory( glob_txt = f"{glob_txt}{extension}" else: glob_txt = f"{glob_txt}.{extension}" + + platform = sys.platform logging.info(f"Searching for files matching: {glob_txt}") for d in raw_file_dir: connect_kwargs, host = d.connection_info() - with fabric.Connection(host, connect_kwargs=connect_kwargs) as conn: - out = conn.run(f'find -L {d.raw_path} -name "{glob_txt}"', hide="both", warn=True) - if out.return_code != 0: - warnings.warn(f"Could not find any files in {d.raw_path} -> {out.stderr}") - warnings.warn(f"Most likely the OS does not have the 'find' command") - continue - _file_list = out.stdout.splitlines() + if not host and platform == "win32": + logging.info("Windows platform detected - assuming 'find' is not available") + _file_list = glob.glob(f"{d.raw_path}/**/{glob_txt}", recursive=True) + f = _file_list[0] + else: + with fabric.Connection(host, connect_kwargs=connect_kwargs) as conn: + out = conn.run(f'find -L {d.raw_path} -name "{glob_txt}"', hide="both", warn=True) + if out.return_code != 0: + logging.critical(f"Searching in: {d}") + warnings.warn(f"Could not find any files in {d.raw_path} -> {out.stderr}") + warnings.warn(f"Most likely the OS does not have the 'find' command") + continue + _file_list = out.stdout.splitlines() file_list += list(map(lambda x: f"{d.uri_prefix}{host}"+x, _file_list)) number_of_files = len(file_list) + if number_of_files == 0: + logging.critical("No files found") logging.info(f"Found {number_of_files} files") return file_list diff --git a/cellpy/utils/batch.py b/cellpy/utils/batch.py index b9ac4932..87916778 100644 --- a/cellpy/utils/batch.py +++ b/cellpy/utils/batch.py @@ -937,6 +937,38 @@ def combine_summaries(self, export_to_csv=True, **kwargs) -> None: else: self.summary_collector.do(**kwargs) + def plot(self, output_filename=None, backend=None, reload_data=False, **kwargs): + """Plot the summaries (new version)""" + + if reload_data or ("summary_engine" not in self.experiment.memory_dumped): + logging.debug("running summary_collector") + self.summary_collector.do(reset=True) + + if backend is None: + backend = prms.Batch.backend + + if backend in ["bokeh", "matplotlib", "plotly"]: + prms.Batch.backend = backend + + if backend == "bokeh": + print("...Using old plotter - this will soon change") + self.plot_summaries( + output_filename=output_filename, + backend="bokeh", + reload_data=reload_data, + **kwargs) + + if backend == "matplotlib": + print("...Using old plotter - this will soon change") + self.plot_summaries( + output_filename=output_filename, + backend="matplotlib", + reload_data=reload_data, + **kwargs) + + else: + print(f"backend {backend} not supported yet") + def plot_summaries( self, output_filename=None, backend=None, reload_data=False, **kwargs ) -> None: