Skip to content

Commit 5d421b4

Browse files
committed
Fix tests for momi intsallation on Ubuntu for py3.8
1 parent 9508a8b commit 5d421b4

File tree

5 files changed

+37
-30
lines changed

5 files changed

+37
-30
lines changed

.github/workflows/publication_to_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
build-n-publish:
1212
name: Build and publish Python distributions to PyPI and TestPyPI
13-
runs-on: ubuntu-18.04
13+
runs-on: ubuntu-20.04
1414

1515
steps:
1616
- uses: actions/checkout@master

.github/workflows/tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-20.04, windows-2019, macos-10.15]
17+
os: [ubuntu-20.04, windows-2019, macos-latest]
1818
python-version: [3.6, 3.8]
1919
include:
2020
- os: windows-2019
@@ -102,10 +102,16 @@ jobs:
102102
python3 setup.py install
103103
cd ..
104104
105+
# For some reason the last version of wheel cause an error for momi installation
106+
- name: Use specific version of wheel for momi installation (Linux)
107+
if: runner.os == 'Linux' && matrix.python-version == '3.8'
108+
run: |
109+
python3 -m pip install wheel==0.38.4
110+
105111
- name: Install momi engine (Linux).
106112
if: runner.os == 'Linux'
107113
run: |
108-
pip3 install momi
114+
python3 -m pip install momi
109115
110116
- name: Check installations of packages.
111117
run: |

gadma/cli/settings_storage.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ..engines import DadiEngine
1010
from ..engines import all_engines, all_drawing_engines, all_available_engines
1111
from ..models import StructureDemographicModel, CustomDemographicModel,\
12-
EpochDemographicModel
12+
EpochDemographicModel, TreeDemographicModel
1313
from ..optimizers import get_local_optimizer, get_global_optimizer
1414
from ..optimizers import LinearConstrain
1515
from ..utils import check_dir_existence, check_file_existence, abspath,\
@@ -1269,7 +1269,7 @@ def get_model(self):
12691269
has_dyns=create_dyns,
12701270
sym_migs=sym_migs,
12711271
frac_split=split_f,
1272-
migs_mask=migs_mask,
1272+
migs_mask=copy.deepcopy(migs_mask),
12731273
gen_time=gen_time,
12741274
theta0=theta0,
12751275
mutation_rate=mut_rate,
@@ -1441,8 +1441,8 @@ def get_available_engines(self, print_warnings=False):
14411441
continue
14421442
available_engines.append(engine.id)
14431443
else:
1444-
assert isinstance(self.model, CustomDemographicModel)
1445-
available_engines.append(self.engine.id)
1444+
assert isinstance(model, CustomDemographicModel)
1445+
available_engines.append(self.engine)
14461446
return available_engines
14471447

14481448
def is_valid(self):
@@ -1454,7 +1454,7 @@ def is_valid(self):
14541454
if self.units_of_time_in_drawing != "generations":
14551455
warnings.warn(
14561456
"Time for generation is not set. All times will be in"
1457-
"generations (output and pictures)."
1457+
" generations (output and pictures)."
14581458
)
14591459
self.units_of_time_in_drawing != "generations"
14601460
if (self.input_data is None and
@@ -1563,9 +1563,9 @@ def is_valid(self):
15631563
)
15641564
self.units_of_time_in_drawing = "years"
15651565

1566-
if self.sequence_length is None and momi_available:
1567-
warnings.warn("Code for momi2 will not be generated as `Sequence "
1568-
"length` is missed.")
1566+
# if self.sequence_length is None and momi_available:
1567+
# warnings.warn("Code for momi2 will not be generated as `Sequence"
1568+
# " length` is missed.")
15691569

15701570
# Check for sequence length if we have several chrom lengths
15711571
if isinstance(self.sequence_length, dict):
@@ -1598,25 +1598,26 @@ def is_valid(self):
15981598
"specify length for chromosomes separately via dict"
15991599
if not moments_ld_ok:
16001600
if self.engine != "momentsLD":
1601-
warnings.warn("Code for momentsLD will not be generated as: "
1602-
f"{reason}")
1601+
pass
1602+
# warnings.warn("Code for momentsLD will not be generated as: "
1603+
# f"{reason}")
16031604
else:
16041605
raise ValueError("MomentsLD requirements are not satisfied: "
16051606
f"{reason}")
16061607

1607-
for engine, is_available in zip(["demes", "momi2"],
1608-
[demes_available, momi_available]):
1609-
if is_available:
1610-
if not self.Nanc_will_be_available():
1611-
warnings.warn(
1612-
f"Code for {engine} engine will not be generated as "
1613-
"ancestral size will be missed in the dem. model. "
1614-
"The following options should be set to enable it:\n"
1615-
f"`Ancestral size as parameter`: True "
1616-
f"(got `self.ancestral_size_as_parameter`)\nor\n"
1617-
f"`Mutation rate` (got {self.mutation_rate})\n"
1618-
f"`Sequence length` (got {self.sequence_length})\nor\n"
1619-
f"`Theta0` (got {self.theta0})")
1608+
# for engine, is_available in zip(["demes", "momi2"],
1609+
# [demes_available, momi_available]):
1610+
# if is_available:
1611+
# if not self.Nanc_will_be_available():
1612+
# warnings.warn(
1613+
# f"Code for {engine} engine will not be generated as "
1614+
# "ancestral size will be missed in the dem. model. "
1615+
# "The following options should be set to enable it:\n"
1616+
# f"`Ancestral size as parameter`: True "
1617+
# f"(got `self.ancestral_size_as_parameter`)\nor\n"
1618+
# f"`Mutation rate` (got {self.mutation_rate})\n"
1619+
# f"`Sequence length` (got {self.sequence_length})\nor"
1620+
# f"\n`Theta0` (got {self.theta0})")
16201621

16211622
if self.ld_kwargs is not None:
16221623
if self.engine != "momentsLD":

gadma/core/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ def main():
6363
sys.stdout = StdAndFileLogger(log_file, settings_storage.silence)
6464
sys.stderr = StdAndFileLogger(log_file, stderr=True)
6565

66-
# Check what engines will be available and print warnings
67-
settings_storage.get_available_engines(print_warnings=True)
68-
6966
try:
7067
# Data reading
7168
print("Data reading")
@@ -90,6 +87,9 @@ def main():
9087
print(f"{bcolors.OKGREEN}--Successful bootstrap data reading--"
9188
f"{bcolors.ENDC}\n")
9289

90+
# Check what engines will be available and print warnings
91+
settings_storage.get_available_engines(print_warnings=True)
92+
9393
# Save parameters
9494
settings_storage.to_files(params_file, extra_params_file)
9595
if not args.test:

gadma/core/core_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(self, index, shared_dict, settings):
106106
self.code_dir = os.path.join(self.output_dir, 'code')
107107
ensure_dir_existence(self.code_dir)
108108
for engine_id in self.available_engines:
109-
engine_dir = os.path.join(self.code_dir, engine.id)
109+
engine_dir = os.path.join(self.code_dir, engine_id)
110110
ensure_dir_existence(engine_dir)
111111
# Set counters to zero for callbacks to count number of their calls
112112
self.draw_iter_callback_counter = 0

0 commit comments

Comments
 (0)