annet 0.12.8__py3-none-any.whl → 0.12.9__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.

Potentially problematic release.


This version of annet might be problematic. Click here for more details.

annet/gen.py CHANGED
@@ -79,6 +79,19 @@ class DeviceGenerators:
79
79
  for gen in gen_list:
80
80
  yield gen
81
81
 
82
+ def for_devices(self, devices: Iterable[Device]) -> "DeviceGenerators":
83
+ result = DeviceGenerators()
84
+ for device in devices:
85
+ if device in self.partial:
86
+ result.partial[device] = self.partial[device]
87
+ if device in self.ref:
88
+ result.ref[device] = self.ref[device]
89
+ if device in self.entire:
90
+ result.entire[device] = self.entire[device]
91
+ if device in self.json_fragment:
92
+ result.json_fragment[device] = self.json_fragment[device]
93
+ return result
94
+
82
95
  def file_gens(self, device: Any) -> Iterator[Union[Entire, JSONFragment]]:
83
96
  """Iterate over generators that generate files or file parts."""
84
97
  yield from itertools.chain(
@@ -514,7 +527,7 @@ def worker(device_id, args: ShowGenOptions, stdin, loader: "Loader", filterer: F
514
527
 
515
528
 
516
529
  def old_new_worker(device_id, args: DeployOptions, config, stdin, loader: "Loader", filterer: Filterer):
517
- yield from old_new(
530
+ for res in old_new(
518
531
  args,
519
532
  config=config,
520
533
  loader=loader,
@@ -523,7 +536,10 @@ def old_new_worker(device_id, args: DeployOptions, config, stdin, loader: "Loade
523
536
  device_ids=[device_id],
524
537
  no_new=args.clear,
525
538
  do_files_download=True,
526
- )
539
+ ):
540
+ if res.err is not None and not args.tolerate_fails:
541
+ raise res.err
542
+ yield res
527
543
 
528
544
 
529
545
  class OldNewParallel(Parallel):
@@ -538,12 +554,13 @@ class OldNewParallel(Parallel):
538
554
  filterer=filterer,
539
555
  )
540
556
  self.tune_args(args)
557
+ self.tolerate_fails = args.tolerate_fails
541
558
 
542
559
  def generated_configs(self, devices: List[Device]) -> Generator[OldNewResult, None, None]:
543
560
  devices_by_id = {device.id: device for device in devices}
544
561
  device_ids = list(devices_by_id)
545
562
 
546
- for task_result in self.irun(device_ids):
563
+ for task_result in self.irun(device_ids, self.tolerate_fails):
547
564
  if task_result.exc is not None:
548
565
  device = devices_by_id.pop(task_result.device_id)
549
566
  yield OldNewResult(device=device, err=task_result.exc)
@@ -868,8 +885,4 @@ class Loader:
868
885
  return []
869
886
 
870
887
  def resolve_gens(self, devices: Iterable[Device]) -> DeviceGenerators:
871
- if self._gens is not None:
872
- return self._gens
873
-
874
- with tracing_connector.get().start_as_current_span("Resolve gens"):
875
- return _old_resolve_gens(self._args, self._storage, devices)
888
+ return self._gens.for_devices(devices)
annet/lib.py CHANGED
@@ -84,6 +84,7 @@ def get_context_path(touch: Optional[bool] = False) -> str:
84
84
  return str(path)
85
85
 
86
86
 
87
+ @lru_cache(maxsize=1)
87
88
  def get_context() -> dict:
88
89
  with open(get_context_path()) as f:
89
90
  raw = yaml.safe_load(f)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.12.8
3
+ Version: 0.12.9
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -8,10 +8,10 @@ annet/deploy.py,sha256=B8E0P_VvCrS2URjFvgmUiIkHp95g7pAWfmT34igaDeo,18893
8
8
  annet/diff.py,sha256=zLcaCnb4lZRUb7frpH1CstQ3kacRcCblZs1uLG8J5lk,3391
9
9
  annet/executor.py,sha256=EaeQ_JeRFuUUHUoR2LXDcNvY7IVg0eA2d6zSmQVJt-M,19216
10
10
  annet/filtering.py,sha256=F4ZKUCU3Yb1RlL2zKdyHtVUaWPzjWF4vWyMcdygKNYk,852
11
- annet/gen.py,sha256=J3TKaD61HzHo2etEpStpTFcC19pbVwYUNSKX5YycpHg,32795
11
+ annet/gen.py,sha256=Gl2-6A1ekuz4mDf7SjGAmI8CMoLXoOtjNcgOvY3SoP0,33376
12
12
  annet/hardware.py,sha256=HYPDfji_GdRn5S0_0fl4rvM7byOY9aHxG6VMAtsLaxE,1090
13
13
  annet/implicit.py,sha256=QigK4uoxvrFho2h9yFjOq1d9rLsC5xFlAU4bKkCuMWk,5139
14
- annet/lib.py,sha256=zQIfNBg7fAAk2BHbHAqy_McAiXhz0RqpBAcfdU-6pAA,3742
14
+ annet/lib.py,sha256=tQQlxZg1A2Q-tp18PoqBuORQmvP5dAAmAPvP6bBA6a0,3764
15
15
  annet/output.py,sha256=hJNGzL4Z3KgvqaCBkkmuuiXPhb64F1QV8YHkwnfhaaI,6852
16
16
  annet/parallel.py,sha256=hLkzEht0KhzmzUWDdO4QFYQHzhxs3wPlTA8DxbB2ziw,17160
17
17
  annet/patching.py,sha256=nILbY5oJajN0b1j3f0HEJm05H3HVThnWvB7vDVh7UQw,559
@@ -128,10 +128,10 @@ annet/rulebook/texts/routeros.rul,sha256=ipfxjj0mjFef6IsUlupqx4BY_Je_OUb8u_U1019
128
128
  annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
129
  annet_generators/example/__init__.py,sha256=zVd8_DrXuOASrNzg2Ab94rPyvJff83L-_HppDFxnUjM,228
130
130
  annet_generators/example/lldp.py,sha256=68CLrK7vxTQQy9XIBxtywuEdBNlIlfXGYj8_wYWs5UI,1146
131
- annet-0.12.8.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
132
- annet-0.12.8.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
133
- annet-0.12.8.dist-info/METADATA,sha256=QV1U3C_eS9t_pCWA0arAfZqULlZCqE9_oteoCCv68vc,694
134
- annet-0.12.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
135
- annet-0.12.8.dist-info/entry_points.txt,sha256=yHimujIzR2bwNIbb--MTs_GpXiAve89Egpu2LlgTEkg,119
136
- annet-0.12.8.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
137
- annet-0.12.8.dist-info/RECORD,,
131
+ annet-0.12.9.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
132
+ annet-0.12.9.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
133
+ annet-0.12.9.dist-info/METADATA,sha256=hjKE9aLTjcAEbaFDVvQOgNyOgL7NXHwT5l-7KNoK0SI,694
134
+ annet-0.12.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
135
+ annet-0.12.9.dist-info/entry_points.txt,sha256=yHimujIzR2bwNIbb--MTs_GpXiAve89Egpu2LlgTEkg,119
136
+ annet-0.12.9.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
137
+ annet-0.12.9.dist-info/RECORD,,
File without changes