flamapy 2.9.0.dev1__tar.gz → 2.9.0.dev3__tar.gz
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-2.9.0.dev1 → flamapy-2.9.0.dev3}/PKG-INFO +12 -12
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/flamapy_feature_model.py +59 -18
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy.egg-info/PKG-INFO +12 -12
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy.egg-info/SOURCES.txt +1 -0
- flamapy-2.9.0.dev3/flamapy.egg-info/requires.txt +26 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/pyproject.toml +12 -12
- flamapy-2.9.0.dev3/tests/test_imports.py +69 -0
- flamapy-2.9.0.dev1/flamapy.egg-info/requires.txt +0 -26
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/LICENSE +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/README.md +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/commands/__init__.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/__init__.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/_stub.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/flamapy_feature_model.pyi +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy.egg-info/dependency_links.txt +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy.egg-info/entry_points.txt +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy.egg-info/top_level.txt +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/setup.cfg +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/setup.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_2_9_compatibility.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_async_streaming.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_backend_level_warning.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_basic_units.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_cli_basic_units.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_descriptors_cover_facade.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_documentation_examples.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_fama_suite_bdd.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_fama_suite_sat.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_metrics_fanout.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_optimization_and_sampling.py +0 -0
- {flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/tests/test_planner_routing.py +0 -0
|
@@ -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"
|
{flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/flamapy_feature_model.py
RENAMED
|
@@ -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"
|
|
@@ -22,6 +22,7 @@ tests/test_descriptors_cover_facade.py
|
|
|
22
22
|
tests/test_documentation_examples.py
|
|
23
23
|
tests/test_fama_suite_bdd.py
|
|
24
24
|
tests/test_fama_suite_sat.py
|
|
25
|
+
tests/test_imports.py
|
|
25
26
|
tests/test_metrics_fanout.py
|
|
26
27
|
tests/test_optimization_and_sampling.py
|
|
27
28
|
tests/test_planner_routing.py
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
flamapy-fw~=2.9.0.dev3
|
|
2
|
+
flamapy-fm~=2.9.0.dev3
|
|
3
|
+
flamapy-sat~=2.9.0.dev3
|
|
4
|
+
flamapy-bdd~=2.9.0.dev3
|
|
5
|
+
flamapy-z3~=2.9.0.dev3
|
|
6
|
+
|
|
7
|
+
[all-solvers]
|
|
8
|
+
flamapy-sharpsat~=2.9.0.dev3
|
|
9
|
+
flamapy-dnnf~=2.9.0.dev3
|
|
10
|
+
flamapy-sdd~=2.9.0.dev3
|
|
11
|
+
|
|
12
|
+
[dev]
|
|
13
|
+
pytest
|
|
14
|
+
pytest-mock
|
|
15
|
+
prospector
|
|
16
|
+
mypy
|
|
17
|
+
coverage
|
|
18
|
+
|
|
19
|
+
[dnnf]
|
|
20
|
+
flamapy-dnnf~=2.9.0.dev3
|
|
21
|
+
|
|
22
|
+
[sdd]
|
|
23
|
+
flamapy-sdd~=2.9.0.dev3
|
|
24
|
+
|
|
25
|
+
[sharpsat]
|
|
26
|
+
flamapy-sharpsat~=2.9.0.dev3
|
|
@@ -4,30 +4,30 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "flamapy"
|
|
7
|
-
version = "2.9.0.
|
|
7
|
+
version = "2.9.0.dev3"
|
|
8
8
|
description = "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."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "GPL-3.0-or-later"
|
|
11
11
|
authors = [{ name = "Flamapy", email = "flamapy@us.es" }]
|
|
12
12
|
requires-python = ">=3.11"
|
|
13
13
|
dependencies = [
|
|
14
|
-
"flamapy-fw~=2.9.0.
|
|
15
|
-
"flamapy-fm~=2.9.0.
|
|
16
|
-
"flamapy-sat~=2.9.0.
|
|
17
|
-
"flamapy-bdd~=2.9.0.
|
|
18
|
-
"flamapy-z3~=2.9.0.
|
|
14
|
+
"flamapy-fw~=2.9.0.dev3",
|
|
15
|
+
"flamapy-fm~=2.9.0.dev3",
|
|
16
|
+
"flamapy-sat~=2.9.0.dev3",
|
|
17
|
+
"flamapy-bdd~=2.9.0.dev3",
|
|
18
|
+
"flamapy-z3~=2.9.0.dev3",
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
[project.optional-dependencies]
|
|
22
22
|
# Optional solver backends: not part of the default install, selectable per call
|
|
23
23
|
# (e.g. backend='sharpsat') or per model (FLAMAFeatureModel(path, backend=...)).
|
|
24
|
-
sharpsat = ["flamapy-sharpsat~=2.9.0.
|
|
25
|
-
dnnf = ["flamapy-dnnf~=2.9.0.
|
|
26
|
-
sdd = ["flamapy-sdd~=2.9.0.
|
|
24
|
+
sharpsat = ["flamapy-sharpsat~=2.9.0.dev3"]
|
|
25
|
+
dnnf = ["flamapy-dnnf~=2.9.0.dev3"]
|
|
26
|
+
sdd = ["flamapy-sdd~=2.9.0.dev3"]
|
|
27
27
|
all-solvers = [
|
|
28
|
-
"flamapy-sharpsat~=2.9.0.
|
|
29
|
-
"flamapy-dnnf~=2.9.0.
|
|
30
|
-
"flamapy-sdd~=2.9.0.
|
|
28
|
+
"flamapy-sharpsat~=2.9.0.dev3",
|
|
29
|
+
"flamapy-dnnf~=2.9.0.dev3",
|
|
30
|
+
"flamapy-sdd~=2.9.0.dev3",
|
|
31
31
|
]
|
|
32
32
|
dev = [
|
|
33
33
|
"pytest",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Models with imports are analysed as one tree: the imported models used to count as leaf
|
|
2
|
+
features, so their features and constraints were ignored (flamapy/fm_metamodel#110)."""
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
|
|
8
|
+
|
|
9
|
+
SPIRITS = ('features\n Spirits\n alternative\n Gin\n Rum\n'
|
|
10
|
+
' optional\n Ice\nconstraints\n Rum => Ice\n')
|
|
11
|
+
BACKENDS = ['sat', 'bdd', 'z3']
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _model(tmp_path, main: str, **files: str) -> FLAMAFeatureModel:
|
|
15
|
+
for name, text in {'Spirits': SPIRITS, 'Mix': main, **files}.items():
|
|
16
|
+
(tmp_path / f'{name}.uvl').write_text(text)
|
|
17
|
+
return FLAMAFeatureModel(str(tmp_path / 'Mix.uvl'), raise_errors=True)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _two_parents(imports: str, first: str, second: str) -> str:
|
|
21
|
+
return (f'imports\n{imports}features\n Mix\n optional\n'
|
|
22
|
+
f' Three\n mandatory\n {first}.Spirits\n'
|
|
23
|
+
f' Two\n mandatory\n {second}.Spirits\n')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.parametrize('backend', BACKENDS)
|
|
27
|
+
def test_imported_features_and_constraints_are_analysed(tmp_path, backend):
|
|
28
|
+
fm = _model(tmp_path, 'imports\n Spirits as S\nfeatures\n Mix\n optional\n'
|
|
29
|
+
' S.Spirits\n')
|
|
30
|
+
# Mix alone, or with Spirits: Gin (with or without Ice) or Rum (which requires Ice).
|
|
31
|
+
assert fm.configurations_number(backend=backend) == 4
|
|
32
|
+
assert fm.last_result.exact is True
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.parametrize('backend', BACKENDS)
|
|
36
|
+
def test_the_same_model_under_two_aliases_gives_independent_subtrees(tmp_path, backend):
|
|
37
|
+
fm = _model(tmp_path, _two_parents(' Spirits as S\n Spirits as T\n', 'S', 'T'))
|
|
38
|
+
assert fm.configurations_number(backend=backend) == 16 # (1 + 3) * (1 + 3)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize('backend', BACKENDS)
|
|
42
|
+
def test_nested_imports_reached_through_two_models(tmp_path, backend):
|
|
43
|
+
fm = _model(
|
|
44
|
+
tmp_path,
|
|
45
|
+
'imports\n B as B\n C as C\nfeatures\n Mix\n optional\n'
|
|
46
|
+
' B.B\n C.C\n',
|
|
47
|
+
B='imports\n Spirits as S\nfeatures\n B\n mandatory\n S.Spirits\n',
|
|
48
|
+
C='imports\n Spirits as S\nfeatures\n C\n mandatory\n S.Spirits\n')
|
|
49
|
+
assert fm.configurations_number(backend=backend) == 16
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_a_model_without_imports_or_repeated_names_does_not_warn(tmp_path):
|
|
53
|
+
with warnings.catch_warnings():
|
|
54
|
+
warnings.simplefilter('error', UserWarning)
|
|
55
|
+
_model(tmp_path, 'features\n Mix\n optional\n A\n B\n')
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize('main', [
|
|
59
|
+
_two_parents(' Spirits as S\n', 'S', 'S'), # the model of flamapy/fm_metamodel#110
|
|
60
|
+
'features\n Mix\n optional\n Three\n mandatory\n'
|
|
61
|
+
' Sp\n Two\n mandatory\n Sp\n',
|
|
62
|
+
])
|
|
63
|
+
def test_repeated_feature_names_warn(tmp_path, main):
|
|
64
|
+
with pytest.warns(UserWarning, match='cannot be guaranteed') as record:
|
|
65
|
+
fm = _model(tmp_path, main)
|
|
66
|
+
assert record[0].filename == __file__
|
|
67
|
+
# The backend does not approximate anything: the warning is the only signal.
|
|
68
|
+
fm.satisfiable(backend='sat')
|
|
69
|
+
assert fm.last_result.exact is True
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
flamapy-fw~=2.9.0.dev1
|
|
2
|
-
flamapy-fm~=2.9.0.dev1
|
|
3
|
-
flamapy-sat~=2.9.0.dev1
|
|
4
|
-
flamapy-bdd~=2.9.0.dev1
|
|
5
|
-
flamapy-z3~=2.9.0.dev1
|
|
6
|
-
|
|
7
|
-
[all-solvers]
|
|
8
|
-
flamapy-sharpsat~=2.9.0.dev1
|
|
9
|
-
flamapy-dnnf~=2.9.0.dev1
|
|
10
|
-
flamapy-sdd~=2.9.0.dev1
|
|
11
|
-
|
|
12
|
-
[dev]
|
|
13
|
-
pytest
|
|
14
|
-
pytest-mock
|
|
15
|
-
prospector
|
|
16
|
-
mypy
|
|
17
|
-
coverage
|
|
18
|
-
|
|
19
|
-
[dnnf]
|
|
20
|
-
flamapy-dnnf~=2.9.0.dev1
|
|
21
|
-
|
|
22
|
-
[sdd]
|
|
23
|
-
flamapy-sdd~=2.9.0.dev1
|
|
24
|
-
|
|
25
|
-
[sharpsat]
|
|
26
|
-
flamapy-sharpsat~=2.9.0.dev1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flamapy-2.9.0.dev1 → flamapy-2.9.0.dev3}/flamapy/interfaces/python/flamapy_feature_model.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|