flamapy 2.9.0.dev1__py3-none-any.whl → 2.9.0.dev3__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.
- flamapy/interfaces/python/flamapy_feature_model.py +59 -18
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/METADATA +12 -12
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/RECORD +7 -7
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/WHEEL +0 -0
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/entry_points.txt +0 -0
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/licenses/LICENSE +0 -0
- {flamapy-2.9.0.dev1.dist-info → flamapy-2.9.0.dev3.dist-info}/top_level.txt +0 -0
|
@@ -32,6 +32,7 @@ from flamapy.core.operations import (
|
|
|
32
32
|
from flamapy.core.planner import Plan, plan as plan_backend
|
|
33
33
|
from flamapy.metamodels.configuration_metamodel.models import Configuration
|
|
34
34
|
from flamapy.metamodels.fm_metamodel.models import FeatureModel
|
|
35
|
+
from flamapy.metamodels.fm_metamodel.transformations import FlatFM
|
|
35
36
|
from flamapy.metamodels.fm_metamodel.operations.fm_language_level import (
|
|
36
37
|
calculate_language_level,
|
|
37
38
|
)
|
|
@@ -63,6 +64,19 @@ class Backend(str, Enum):
|
|
|
63
64
|
# Facade backend name -> fm-to-backend transformation extension (the only non-identity mapping).
|
|
64
65
|
_BACKEND_ALIAS = {"sat": "pysat"}
|
|
65
66
|
|
|
67
|
+
# The solver libraries are not thread-safe: Z3 shares one global context, and dd parses
|
|
68
|
+
# every BDD expression with one module-level parser, so two threads building or querying the
|
|
69
|
+
# same kind of backend model corrupt each other (wrong results, or a crash of the whole
|
|
70
|
+
# interpreter). One process-wide lock per backend serialises that work; jobs on different
|
|
71
|
+
# backends still run concurrently.
|
|
72
|
+
_BACKEND_LOCKS: Dict[str, threading.RLock] = {}
|
|
73
|
+
_BACKEND_LOCKS_GUARD = threading.Lock()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _backend_lock(extension: str) -> threading.RLock:
|
|
77
|
+
with _BACKEND_LOCKS_GUARD:
|
|
78
|
+
return _BACKEND_LOCKS.setdefault(extension, threading.RLock())
|
|
79
|
+
|
|
66
80
|
# Operations that ran on a fixed backend in 2.6 and accept ``backend=`` since 2.9. In 2.x only a
|
|
67
81
|
# per-call ``backend=`` changes them: the workspace default and FLAMAPY_BACKEND do not, so code
|
|
68
82
|
# that set a default backend in 2.6 keeps the same results (the default would otherwise move
|
|
@@ -162,6 +176,16 @@ class FLAMAFeatureModel:
|
|
|
162
176
|
self.model_path = model_path
|
|
163
177
|
self.discover_metamodel = DiscoverMetamodels()
|
|
164
178
|
self.fm_model = self._read(model_path)
|
|
179
|
+
# The backends identify a feature by its name, so two features with one name are
|
|
180
|
+
# analysed as a single feature: no result on such a model can be trusted. The result
|
|
181
|
+
# envelopes still say exact=True, which only tells whether the backend approximates.
|
|
182
|
+
repeated = self._repeated_names()
|
|
183
|
+
if repeated:
|
|
184
|
+
warnings.warn(
|
|
185
|
+
f"The model has {len(repeated)} feature name(s) used by more than one "
|
|
186
|
+
f"feature ({', '.join(repeated)}). Features are identified by name, so the "
|
|
187
|
+
"analysis results on this model cannot be guaranteed.",
|
|
188
|
+
UserWarning, stacklevel=2)
|
|
165
189
|
self.backend = Backend(backend) if backend is not None else None
|
|
166
190
|
self.allow_approximate = allow_approximate
|
|
167
191
|
self.raise_errors = raise_errors
|
|
@@ -173,7 +197,16 @@ class FLAMAFeatureModel:
|
|
|
173
197
|
self._model_language_level: Optional[LanguageLevel] = None
|
|
174
198
|
|
|
175
199
|
def _read(self, model_path: str) -> FeatureModel:
|
|
176
|
-
|
|
200
|
+
model = self.discover_metamodel.use_transformation_t2m(model_path, "fm")
|
|
201
|
+
if getattr(model, 'imports', None):
|
|
202
|
+
# The analyses work on one tree: without this the imported models would count
|
|
203
|
+
# as leaf features, and their features and constraints would be ignored.
|
|
204
|
+
model = FlatFM(model).transform()
|
|
205
|
+
return model
|
|
206
|
+
|
|
207
|
+
def _repeated_names(self) -> list[str]:
|
|
208
|
+
names = [feature.name for feature in self.fm_model.get_features()]
|
|
209
|
+
return sorted({name for name in names if names.count(name) > 1})
|
|
177
210
|
|
|
178
211
|
def _as_configuration(
|
|
179
212
|
self, configuration: Union[str, Dict[str, Any], Configuration]
|
|
@@ -266,10 +299,15 @@ class FLAMAFeatureModel:
|
|
|
266
299
|
def _backend_model(self, extension: str) -> VariabilityModel:
|
|
267
300
|
if extension == self.fm_model.get_extension():
|
|
268
301
|
return self.fm_model
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
302
|
+
return self._transformed(self.fm_model, extension)
|
|
303
|
+
|
|
304
|
+
def _transformed(self, source: VariabilityModel, extension: str) -> VariabilityModel:
|
|
305
|
+
"""The cached ``extension`` model, built from ``source`` once even under concurrency."""
|
|
306
|
+
with _backend_lock(extension):
|
|
307
|
+
if extension not in self._backend_models:
|
|
308
|
+
self._backend_models[extension] = (
|
|
309
|
+
self.discover_metamodel.use_transformation_m2m(source, extension))
|
|
310
|
+
return self._backend_models[extension]
|
|
273
311
|
|
|
274
312
|
def _language_level(self) -> LanguageLevel:
|
|
275
313
|
if self._model_language_level is None:
|
|
@@ -326,10 +364,7 @@ class FLAMAFeatureModel:
|
|
|
326
364
|
route = dataclasses.replace(route, planner=f'auto: {chosen.rationale}')
|
|
327
365
|
model = self.fm_model
|
|
328
366
|
for _, destination in chosen.transformation_chain:
|
|
329
|
-
|
|
330
|
-
self._backend_models[destination] = (
|
|
331
|
-
self.discover_metamodel.use_transformation_m2m(model, destination))
|
|
332
|
-
model = self._backend_models[destination]
|
|
367
|
+
model = self._transformed(model, destination)
|
|
333
368
|
return model, route
|
|
334
369
|
|
|
335
370
|
def _prepare_operation(
|
|
@@ -377,10 +412,11 @@ class FLAMAFeatureModel:
|
|
|
377
412
|
descriptor, backend_arg, call_kwargs, allow_approximate)
|
|
378
413
|
# The hash is always the source feature model's (memoized there), whichever
|
|
379
414
|
# backend model the operation actually runs on.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
415
|
+
with _backend_lock(model.get_extension()):
|
|
416
|
+
envelope = run_and_wrap(
|
|
417
|
+
operation, model,
|
|
418
|
+
operation_name=descriptor.name, plugin=self._plugin_name_for(model),
|
|
419
|
+
model_hash=self.fm_model.canonical_hash())
|
|
384
420
|
if descriptor.result_adapter is not None:
|
|
385
421
|
envelope = dataclasses.replace(
|
|
386
422
|
envelope, value=descriptor.result_adapter(envelope.value))
|
|
@@ -441,10 +477,14 @@ class FLAMAFeatureModel:
|
|
|
441
477
|
f"'{descriptor.name}' was cancelled before execution started.")
|
|
442
478
|
if isinstance(prepared, Interruptible):
|
|
443
479
|
prepared.set_interrupt_event(interrupt_event)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
480
|
+
with _backend_lock(model.get_extension()):
|
|
481
|
+
if interrupt_event.is_set(): # gave up while waiting for the backend
|
|
482
|
+
raise OperationTimeout(
|
|
483
|
+
f"'{descriptor.name}' was cancelled before execution started.")
|
|
484
|
+
envelope = run_and_wrap(
|
|
485
|
+
prepared, model,
|
|
486
|
+
operation_name=descriptor.name, plugin=self._plugin_name_for(model),
|
|
487
|
+
model_hash=self.fm_model.canonical_hash())
|
|
448
488
|
return _stamp(envelope, job_route, model)
|
|
449
489
|
|
|
450
490
|
return default_engine().submit_call(task, result_adapter=descriptor.result_adapter)
|
|
@@ -461,7 +501,8 @@ class FLAMAFeatureModel:
|
|
|
461
501
|
operation, model, _ = self._prepare_operation(descriptor, backend or 'sat', {})
|
|
462
502
|
if isinstance(operation, StreamingOperation):
|
|
463
503
|
return operation.iter_execute(model)
|
|
464
|
-
|
|
504
|
+
with _backend_lock(model.get_extension()):
|
|
505
|
+
operation.execute(model)
|
|
465
506
|
return iter(operation.get_result())
|
|
466
507
|
|
|
467
508
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flamapy
|
|
3
|
-
Version: 2.9.0.
|
|
3
|
+
Version: 2.9.0.dev3
|
|
4
4
|
Summary: Flamapy feature model is a distribution of the flama framework containing all plugins required to analyze feature models. It also offers a richer API and a complete command line interface and documentation.
|
|
5
5
|
Author-email: Flamapy <flamapy@us.es>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -8,21 +8,21 @@ Project-URL: Homepage, https://github.com/flamapy/flamapy-feature-model
|
|
|
8
8
|
Requires-Python: >=3.11
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Requires-Dist: flamapy-fw~=2.9.0.
|
|
12
|
-
Requires-Dist: flamapy-fm~=2.9.0.
|
|
13
|
-
Requires-Dist: flamapy-sat~=2.9.0.
|
|
14
|
-
Requires-Dist: flamapy-bdd~=2.9.0.
|
|
15
|
-
Requires-Dist: flamapy-z3~=2.9.0.
|
|
11
|
+
Requires-Dist: flamapy-fw~=2.9.0.dev3
|
|
12
|
+
Requires-Dist: flamapy-fm~=2.9.0.dev3
|
|
13
|
+
Requires-Dist: flamapy-sat~=2.9.0.dev3
|
|
14
|
+
Requires-Dist: flamapy-bdd~=2.9.0.dev3
|
|
15
|
+
Requires-Dist: flamapy-z3~=2.9.0.dev3
|
|
16
16
|
Provides-Extra: sharpsat
|
|
17
|
-
Requires-Dist: flamapy-sharpsat~=2.9.0.
|
|
17
|
+
Requires-Dist: flamapy-sharpsat~=2.9.0.dev3; extra == "sharpsat"
|
|
18
18
|
Provides-Extra: dnnf
|
|
19
|
-
Requires-Dist: flamapy-dnnf~=2.9.0.
|
|
19
|
+
Requires-Dist: flamapy-dnnf~=2.9.0.dev3; extra == "dnnf"
|
|
20
20
|
Provides-Extra: sdd
|
|
21
|
-
Requires-Dist: flamapy-sdd~=2.9.0.
|
|
21
|
+
Requires-Dist: flamapy-sdd~=2.9.0.dev3; extra == "sdd"
|
|
22
22
|
Provides-Extra: all-solvers
|
|
23
|
-
Requires-Dist: flamapy-sharpsat~=2.9.0.
|
|
24
|
-
Requires-Dist: flamapy-dnnf~=2.9.0.
|
|
25
|
-
Requires-Dist: flamapy-sdd~=2.9.0.
|
|
23
|
+
Requires-Dist: flamapy-sharpsat~=2.9.0.dev3; extra == "all-solvers"
|
|
24
|
+
Requires-Dist: flamapy-dnnf~=2.9.0.dev3; extra == "all-solvers"
|
|
25
|
+
Requires-Dist: flamapy-sdd~=2.9.0.dev3; extra == "all-solvers"
|
|
26
26
|
Provides-Extra: dev
|
|
27
27
|
Requires-Dist: pytest; extra == "dev"
|
|
28
28
|
Requires-Dist: pytest-mock; extra == "dev"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
flamapy/commands/__init__.py,sha256=DdRS2Xyt37H_k2YaaFWUcE6xfJALzllraerIup1l_OU,14646
|
|
2
2
|
flamapy/interfaces/python/__init__.py,sha256=NVQH1l6O9ElD8YvUVBXJN0Y_ETmu3AbyQBZJJ9qiuoU,86
|
|
3
3
|
flamapy/interfaces/python/_stub.py,sha256=7JMmnmxHFbpC7XHVqozZUooLwPbHS4p1-B8QXH5wQf8,3898
|
|
4
|
-
flamapy/interfaces/python/flamapy_feature_model.py,sha256=
|
|
4
|
+
flamapy/interfaces/python/flamapy_feature_model.py,sha256=2cXOtYClp7vgybleRNL9JMV-T0UM3cMX-OTWjWszM90,31110
|
|
5
5
|
flamapy/interfaces/python/flamapy_feature_model.pyi,sha256=u-GtNc1wRslPO1I2sIIsNuOxrdT-dR0GZpqzyskHT34,6189
|
|
6
|
-
flamapy-2.9.0.
|
|
7
|
-
flamapy-2.9.0.
|
|
8
|
-
flamapy-2.9.0.
|
|
9
|
-
flamapy-2.9.0.
|
|
10
|
-
flamapy-2.9.0.
|
|
11
|
-
flamapy-2.9.0.
|
|
6
|
+
flamapy-2.9.0.dev3.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
7
|
+
flamapy-2.9.0.dev3.dist-info/METADATA,sha256=tmwahUhfuK3tcCWcjli62r564r2btzQVOJAlit9Duhw,1731
|
|
8
|
+
flamapy-2.9.0.dev3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
flamapy-2.9.0.dev3.dist-info/entry_points.txt,sha256=CS_W4K9LW9xOf-7ymWD58KklNHBnhMHm0RXAZ9JLgVo,57
|
|
10
|
+
flamapy-2.9.0.dev3.dist-info/top_level.txt,sha256=2YBI9dg4GVk28AJuyNu6dldi5Riwt5SP0zpNe2lSU5M,8
|
|
11
|
+
flamapy-2.9.0.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|