Skip to content

Commit 41349d6

Browse files
authored
Merge pull request #55 from MetaSys-LISBP/dev
Dev
2 parents d0d85f2 + eda57c7 commit 41349d6

File tree

5 files changed

+37
-35
lines changed

5 files changed

+37
-35
lines changed

physiofit/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import importlib.metadata
2+
import logging
23

3-
__version__ = importlib.metadata.version("physiofit")
4+
__version__ = importlib.metadata.version("physiofit")
5+
logger = logging.getLogger("physiofit")
6+
logger.setLevel(logging.DEBUG)

physiofit/base/fitter.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
from physiofit.models.base_model import Model
1313

14-
logger = logging.getLogger(__name__)
15-
logger.setLevel(logging.INFO)
14+
logger = logging.getLogger(f"physiofit.{__name__}")
15+
1616

1717

1818
# TODO: add estimate deg function (eq 6) with plot of best fit and measured values
@@ -320,15 +320,13 @@ def _run_optimization(
320320
"""
321321

322322
if method == "differential_evolution":
323-
logger.debug(f"Optimization method = {method}")
324323
optimize_results = differential_evolution(
325324
PhysioFitter._calculate_cost, bounds=bounds,
326325
args=(
327326
func, exp_data_matrix, time_vector, non_opt_params, sd_matrix),
328327
polish=True, x0=np.array(params)
329328
)
330329
elif method == "L-BFGS-B":
331-
logger.debug(f"Optimization method = {method}")
332330
optimize_results = minimize(
333331
PhysioFitter._calculate_cost, x0=np.array(params),
334332
args=(

physiofit/base/io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
# Switch matplotlib logger to higher level to not get debug logs in root logger
2323
logging.getLogger("matplotlib").setLevel(logging.WARNING)
2424

25-
logger = logging.getLogger(__name__)
26-
logger.setLevel(logging.DEBUG)
25+
logger = logging.getLogger(f"physiofit.{__name__}")
2726

2827

2928
class IoHandler:

physiofit/ui/cli.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from physiofit.base.io import IoHandler, StandardDevs, ConfigParser
2121

22+
logger = logging.getLogger(f"physiofit")
23+
2224
def args_parse():
2325
"""
2426
Parse arguments from user input.
@@ -59,18 +61,18 @@ def args_parse():
5961
)
6062

6163
# Parse selective output path arguments (for galaxy implementation mostly)
62-
parser.add_argument(
63-
"-op", "--output_pdf", type=str,
64-
help="Path to output the pdf file containing plots"
65-
)
66-
parser.add_argument(
67-
"-of", "--output_fluxes", type=str,
68-
help="Path to output the flux results"
69-
)
70-
parser.add_argument(
71-
"-os", "--output_stats", type=str,
72-
help="Path to output the khi² test"
73-
)
64+
# parser.add_argument(
65+
# "-op", "--output_pdf", type=str,
66+
# help="Path to output the pdf file containing plots"
67+
# )
68+
# parser.add_argument(
69+
# "-of", "--output_fluxes", type=str,
70+
# help="Path to output the flux results"
71+
# )
72+
# parser.add_argument(
73+
# "-os", "--output_stats", type=str,
74+
# help="Path to output the khi² test"
75+
# )
7476
parser.add_argument(
7577
"-oc", "--output_config", type=str,
7678
help="Path to output the yaml config file"
@@ -88,11 +90,11 @@ def args_parse():
8890

8991
def run(data, args, logger, experiments):
9092

93+
io = IoHandler()
9194
for exp in experiments:
92-
io = IoHandler()
9395
exp_data = data.loc[exp, :].sort_values("time").copy()
9496
logger.info(f"Input Data: \n{exp_data}")
95-
if hasattr(args, 'galaxy'):
97+
if args.galaxy:
9698
io.wkdir = Path('.')
9799
else:
98100
io.wkdir = Path(args.data).parent
@@ -129,10 +131,7 @@ def run(data, args, logger, experiments):
129131
if not io.multiple_experiments:
130132
io.multiple_experiments = []
131133
io.multiple_experiments.append(df)
132-
if exp is not None:
133-
res_path = io.wkdir / (io.wkdir.name + "_res") / exp
134-
else:
135-
res_path = io.wkdir / (io.wkdir.name + "_res")
134+
res_path = io.wkdir / (io.wkdir.name + "_res") / exp
136135
logger.info(res_path)
137136
if not res_path.is_dir():
138137
res_path.mkdir(parents=True)
@@ -149,13 +148,17 @@ def run(data, args, logger, experiments):
149148
# for line in dir.rglob("*"):
150149
# print(line)
151150
generate_zips(str(dir), args.output_zip, logger)
151+
logger.debug(f"Dataframes to concatenate:\n{io.multiple_experiments}")
152152

153153
# shutil.make_archive(
154154
# args.output_zip,
155155
# format='zip',
156156
# root_dir=str(io.home_path / (io.home_path.name + "_res"))
157157
# )
158-
io.output_recap(export_path=args.output_recap, galaxy=True)
158+
if args.galaxy:
159+
io.output_recap(export_path=args.output_recap, galaxy=args.galaxy)
160+
else:
161+
io.output_recap(export_path=str(res_path.parent), galaxy=False)
159162

160163
def generate_zips(path_to_data_folder, output_path, logger):
161164
"""Generate output zip file containing results
@@ -221,16 +224,15 @@ def generate_config(args, data, logger):
221224

222225
def process(args):
223226

224-
logger = logging.getLogger()
225-
logger.setLevel(logging.DEBUG)
226-
out_stream = logging.StreamHandler()
227-
formatter = logging.Formatter()
228-
out_stream.setFormatter(formatter)
227+
cli_handle = logging.StreamHandler()
228+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
229+
cli_handle.setFormatter(formatter)
229230
if args.debug_mode:
230-
out_stream.setLevel(logging.DEBUG)
231+
cli_handle.setLevel(logging.DEBUG)
231232
else:
232-
out_stream.setLevel(logging.INFO)
233-
logger.addHandler(out_stream)
233+
cli_handle.setLevel(logging.INFO)
234+
logger.addHandler(cli_handle)
235+
234236

235237
if args.list:
236238
IoHandler.get_model_list()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "physiofit"
3-
version = "3.3.4"
3+
version = "3.3.5"
44
description = "Calculate extracellular fluxes from metabolite concentrations and biomass data"
55
authors = ["llegregam <legregam@insa-toulouse.fr>"]
66
license = "GNU General Public License (GPL)"

0 commit comments

Comments
 (0)