ebi-eva-common-pyutils 0.7.0__py3-none-any.whl → 0.7.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,9 @@ import os
2
2
 
3
3
  import yaml
4
4
 
5
+ from ebi_eva_common_pyutils.logger import logging_config as log_cfg
6
+
7
+ logger = log_cfg.get_logger(__name__)
5
8
 
6
9
  class Configuration:
7
10
  """
@@ -120,6 +123,9 @@ class WritableConfig(Configuration):
120
123
  for p in path[:-1]:
121
124
  if p not in top_level:
122
125
  top_level[p] = {}
126
+ elif not isinstance(top_level[p], dict):
127
+ logger.warning(f'Overwriting existing config path {".".join(path)}')
128
+ top_level[p] = {}
123
129
  top_level = top_level[p]
124
130
  top_level[path[-1]] = value
125
131
 
@@ -17,17 +17,28 @@ import logging.handlers
17
17
  from sys import stdout, stderr
18
18
  from cached_property import cached_property
19
19
 
20
+ # The way Logger/Handler/Formatter works
21
+ # - Logger create the log message
22
+ # - Formatter describe what is included in the lo message
23
+ # - Handler Propagate them to where they should go (file/screen, ...)
24
+ # Logger are part of hierarchy and always have parent up to the root logger.
25
+ # The root logger is usually set to WARNING level
26
+ # When a log is emitted to a logger, the logger checks it own level and propagate to its handler.
27
+ # If it does not have any handlers it propagates to its parent (unless propagate is set to false)
28
+ #
29
+ # SPECIAL CASE: When a logger has a level set to NOTSET (0) it inherit the level from its parent
30
+
20
31
 
21
32
  class LoggingConfiguration:
22
33
  """
23
- This class provides an all in one management of all loggers in the stack. By default it pulls existing loggers,
34
+ This class provides an all in one management of all loggers in the stack. By default, it pulls existing loggers,
24
35
  stores additional ones along with handlers and formatters.
25
36
  """
26
37
 
27
38
  default_fmt = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s'
28
39
  default_datefmt = '%Y-%b-%d %H:%M:%S'
29
40
 
30
- def __init__(self, use_existing_logger=True, log_level=logging.INFO):
41
+ def __init__(self, use_existing_logger=True, log_level=logging.DEBUG):
31
42
  self.blank_formatter = logging.Formatter()
32
43
  self.handlers = set()
33
44
  if use_existing_logger:
@@ -38,6 +49,8 @@ class LoggingConfiguration:
38
49
  else:
39
50
  self.loggers = {}
40
51
  self._log_level = log_level
52
+ if log_level is not None:
53
+ self.set_log_level(log_level)
41
54
 
42
55
  @cached_property
43
56
  def formatter(self):
@@ -61,8 +74,8 @@ class LoggingConfiguration:
61
74
  else:
62
75
  logger = logging.getLogger(name)
63
76
  self.loggers[name] = logger
64
-
65
- logger.setLevel(level or self._log_level)
77
+ log_level = level if level > self._log_level else self._log_level
78
+ logger.setLevel(log_level)
66
79
  for h in self.handlers:
67
80
  logger.addHandler(h)
68
81
 
@@ -74,19 +87,20 @@ class LoggingConfiguration:
74
87
  :param logging.Handler handler:
75
88
  :param int level: Log level to assign to the created handler
76
89
  """
77
- handler.setLevel(level or self._log_level)
90
+ log_level = level if level > self._log_level else self._log_level
91
+ handler.setLevel(log_level)
78
92
  handler.setFormatter(self.formatter)
79
93
  for name in self.loggers:
80
94
  self.loggers[name].addHandler(handler)
81
95
  self.handlers.add(handler)
82
96
 
83
- def add_stdout_handler(self, level=None):
97
+ def add_stdout_handler(self, level=logging.INFO):
84
98
  self.add_handler(logging.StreamHandler(stdout), level=level or self._log_level)
85
99
 
86
- def add_stderr_handler(self, level=None):
100
+ def add_stderr_handler(self, level=logging.INFO):
87
101
  self.add_handler(logging.StreamHandler(stderr), level=level or self._log_level)
88
102
 
89
- def add_file_handler(self, filename, level=None):
103
+ def add_file_handler(self, filename, level=logging.INFO):
90
104
  self.add_handler(logging.FileHandler(filename=filename), level=level or self._log_level)
91
105
 
92
106
  def set_log_level(self, level):
@@ -236,8 +236,12 @@ class NCBIAssembly(AppLogger):
236
236
  urllib.request.urlretrieve(url, output_file)
237
237
 
238
238
  def download_or_construct(self, genbank_only=False, overwrite=False):
239
- """First download the assembly report and fasta from the FTP, then append any missing contig from
240
- the assembly report to the assembly fasta."""
239
+ """
240
+ First download the assembly report and fasta from the FTP, then append any missing contig from
241
+ the assembly report to the assembly fasta.
242
+ Setting genbank_only = True ensure that only contigs that have genbank accession will be added to the assembly fasta.
243
+ Setting overwrite = True delete any existing fasta file and assembly report. then download them again.
244
+ """
241
245
  self.download_assembly_report(overwrite)
242
246
  try:
243
247
  self.download_assembly_fasta(overwrite)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebi-eva-common-pyutils
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: EBI EVA - Common Python Utilities
5
5
  Home-page: https://github.com/EBIVariation/eva-common-pyutils
6
6
  License: Apache
@@ -12,7 +12,7 @@ Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  License-File: LICENSE
14
14
  Requires-Dist: requests (==2.*)
15
- Requires-Dist: lxml (==4.*,>4.9)
15
+ Requires-Dist: lxml (==5.*)
16
16
  Requires-Dist: pyyaml (==6.*)
17
17
  Requires-Dist: cached-property (==1.5.*)
18
18
  Requires-Dist: retry (==0.*,>0.9)
@@ -3,10 +3,10 @@ ebi_eva_common_pyutils/assembly_utils.py,sha256=CklyCGlCjlFp0e9pugg6kSsh5L0xfCe2
3
3
  ebi_eva_common_pyutils/biosamples_communicators.py,sha256=VdOVFJeNcPHGXTMiQGrMCGytKPW1RnAJ41-s6ui3eY4,7410
4
4
  ebi_eva_common_pyutils/command_utils.py,sha256=PtelWWqcC0eOwIVesjwBw3F9KaXRzEE_uAUJhQFZ4l8,2340
5
5
  ebi_eva_common_pyutils/common_utils.py,sha256=ty_glvfRa3VGhnpAht4qtVkNNmv-IYfVtO958mY-BaA,1192
6
- ebi_eva_common_pyutils/config.py,sha256=PtD2SgHf96kk21OA9tVIjEgsDXEFuAU-INy_kfQdoPw,4828
6
+ ebi_eva_common_pyutils/config.py,sha256=j0lD0mpZiQfvGemrF2PSCJuzV-5SmNdLauFssYvF6t4,5107
7
7
  ebi_eva_common_pyutils/ena_utils.py,sha256=S2MmnWQ_9MJjlkaQY_by1-GGbTyi8SKp8XRcpjWnpZs,1465
8
8
  ebi_eva_common_pyutils/file_utils.py,sha256=eIlQKSVKkEjMNX7emrDzaQyQdGvQdb64gnfEhb6uYsE,1375
9
- ebi_eva_common_pyutils/logger.py,sha256=hT20ktN_oGeB_5ofVfd_aGXB6xYOe0Y5b3EVRYCuFb8,5093
9
+ ebi_eva_common_pyutils/logger.py,sha256=2BXA-dQFkVAyLrF1kC24GcLGxRMaQhJpt41NQv7jpks,5941
10
10
  ebi_eva_common_pyutils/ncbi_utils.py,sha256=AKuNKv4ue7l-6rwuDDGubWEHGuscXWfv-Gg6o_x1hT0,5005
11
11
  ebi_eva_common_pyutils/network_utils.py,sha256=iJjs5PPzT1V4CceZnCHOTs711AmpwlDo59wb1XHdTak,2648
12
12
  ebi_eva_common_pyutils/assembly/__init__.py,sha256=KSWPwBY5nZj00odxWFntk8Sqg_rw273xH8S5D6Jo-T4,67
@@ -14,7 +14,7 @@ ebi_eva_common_pyutils/assembly/assembly.py,sha256=Lf-3Gs4E8hReqQA0roGLiT6nEaz67
14
14
  ebi_eva_common_pyutils/contig_alias/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ebi_eva_common_pyutils/contig_alias/contig_alias.py,sha256=7tQXljEJtRCMs_JPrglYvTEZ-fJvzl8txwnCvqRB3Ck,5214
16
16
  ebi_eva_common_pyutils/reference/__init__.py,sha256=NsDjGCu2H2CZLOPaEL6GCoZo5ND_EA9RFmbzGfpSXRQ,134
17
- ebi_eva_common_pyutils/reference/assembly.py,sha256=FK4zsvg4_GDeKd9z2z5ZeM9R84TsusgQYdMOGuggQU0,12162
17
+ ebi_eva_common_pyutils/reference/assembly.py,sha256=FG_APZ8AL_R70t6UEgSft3uN-0IjZwBMt25JtLd6bN0,12417
18
18
  ebi_eva_common_pyutils/reference/sequence.py,sha256=bg96QcuB-oytQYpaUkV10OzM_RIFhxsy6t3PQOg2Gy0,3911
19
19
  ebi_eva_common_pyutils/spreadsheet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  ebi_eva_common_pyutils/spreadsheet/metadata_xlsx_utils.py,sha256=0yOoV5rfLc5IWPAShSClaAOmaGfJuGZjJOnREfZBtFQ,540
@@ -22,7 +22,7 @@ ebi_eva_common_pyutils/taxonomy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
22
22
  ebi_eva_common_pyutils/taxonomy/taxonomy.py,sha256=aXmRQ3NAaJotwmmOA2-u2XtcUT6iih-0_e-3QOxynoA,2578
23
23
  ebi_eva_common_pyutils/variation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  ebi_eva_common_pyutils/variation/contig_utils.py,sha256=kMNEW_P2yPnd8Xx1tep19hy5ee7ojxz6ZOO1grTQsRQ,5230
25
- ebi_eva_common_pyutils-0.7.0.data/scripts/archive_directory.py,sha256=0lWJ0ju_AB2ni7lMnJXPFx6U2OdTGbe-WoQs-4BfKOM,4976
25
+ ebi_eva_common_pyutils-0.7.2.data/scripts/archive_directory.py,sha256=0lWJ0ju_AB2ni7lMnJXPFx6U2OdTGbe-WoQs-4BfKOM,4976
26
26
  ebi_eva_internal_pyutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  ebi_eva_internal_pyutils/archive_directory.py,sha256=IxVEfh_gaCiT652k0Q_-58fonRusy1yzXu7BCO8yVLo,4989
28
28
  ebi_eva_internal_pyutils/config_utils.py,sha256=EGRC5rsmU_ug7OY9-t1UW1XZXRsauSyZB9xPcBux8ts,7909
@@ -34,8 +34,8 @@ ebi_eva_internal_pyutils/mongodb/__init__.py,sha256=0oyTlkYZCV7udlPl09Zl-sDyE3c9
34
34
  ebi_eva_internal_pyutils/mongodb/mongo_database.py,sha256=kesaJaaxYFeF_uYZBgL8tbufGKUXll7bXb4WlOS9vKM,9596
35
35
  ebi_eva_internal_pyutils/nextflow/__init__.py,sha256=OOiJS8jZOz98q0t77NNog7aI_fFrVxi4kGmiSskuAqM,122
36
36
  ebi_eva_internal_pyutils/nextflow/nextflow_pipeline.py,sha256=ew623hhK8jmFLQjJwLZbgBmW9RTiJBEULVqHfIUv_dc,10114
37
- ebi_eva_common_pyutils-0.7.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
- ebi_eva_common_pyutils-0.7.0.dist-info/METADATA,sha256=5VMbdT4gEyEIvgeXhixwWNfJRMsvuLjED4fZrdcY0pc,908
39
- ebi_eva_common_pyutils-0.7.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
40
- ebi_eva_common_pyutils-0.7.0.dist-info/top_level.txt,sha256=sXoiqiGU8vlMQpFWDlKrekxhlusk06AhkOH3kSvDT6c,48
41
- ebi_eva_common_pyutils-0.7.0.dist-info/RECORD,,
37
+ ebi_eva_common_pyutils-0.7.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
+ ebi_eva_common_pyutils-0.7.2.dist-info/METADATA,sha256=x87lMqM27okxZ4fQD4aLKR5yUhvRKZcA_mBPdIwJzkI,903
39
+ ebi_eva_common_pyutils-0.7.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
40
+ ebi_eva_common_pyutils-0.7.2.dist-info/top_level.txt,sha256=sXoiqiGU8vlMQpFWDlKrekxhlusk06AhkOH3kSvDT6c,48
41
+ ebi_eva_common_pyutils-0.7.2.dist-info/RECORD,,