Skip to content

Commit

Permalink
Fix tests for momi intsallation on Ubuntu for py3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
noscode committed Jun 17, 2023
1 parent 9508a8b commit 5d421b4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publication_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI and TestPyPI
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@master
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-20.04, windows-2019, macos-latest]
python-version: [3.6, 3.8]
include:
- os: windows-2019
Expand Down Expand Up @@ -102,10 +102,16 @@ jobs:
python3 setup.py install
cd ..
# For some reason the last version of wheel cause an error for momi installation
- name: Use specific version of wheel for momi installation (Linux)
if: runner.os == 'Linux' && matrix.python-version == '3.8'
run: |
python3 -m pip install wheel==0.38.4
- name: Install momi engine (Linux).
if: runner.os == 'Linux'
run: |
pip3 install momi
python3 -m pip install momi
- name: Check installations of packages.
run: |
Expand Down
47 changes: 24 additions & 23 deletions gadma/cli/settings_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..engines import DadiEngine
from ..engines import all_engines, all_drawing_engines, all_available_engines
from ..models import StructureDemographicModel, CustomDemographicModel,\
EpochDemographicModel
EpochDemographicModel, TreeDemographicModel
from ..optimizers import get_local_optimizer, get_global_optimizer
from ..optimizers import LinearConstrain
from ..utils import check_dir_existence, check_file_existence, abspath,\
Expand Down Expand Up @@ -1269,7 +1269,7 @@ def get_model(self):
has_dyns=create_dyns,
sym_migs=sym_migs,
frac_split=split_f,
migs_mask=migs_mask,
migs_mask=copy.deepcopy(migs_mask),
gen_time=gen_time,
theta0=theta0,
mutation_rate=mut_rate,
Expand Down Expand Up @@ -1441,8 +1441,8 @@ def get_available_engines(self, print_warnings=False):
continue
available_engines.append(engine.id)
else:
assert isinstance(self.model, CustomDemographicModel)
available_engines.append(self.engine.id)
assert isinstance(model, CustomDemographicModel)
available_engines.append(self.engine)
return available_engines

def is_valid(self):
Expand All @@ -1454,7 +1454,7 @@ def is_valid(self):
if self.units_of_time_in_drawing != "generations":
warnings.warn(
"Time for generation is not set. All times will be in"
"generations (output and pictures)."
" generations (output and pictures)."
)
self.units_of_time_in_drawing != "generations"
if (self.input_data is None and
Expand Down Expand Up @@ -1563,9 +1563,9 @@ def is_valid(self):
)
self.units_of_time_in_drawing = "years"

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

# Check for sequence length if we have several chrom lengths
if isinstance(self.sequence_length, dict):
Expand Down Expand Up @@ -1598,25 +1598,26 @@ def is_valid(self):
"specify length for chromosomes separately via dict"
if not moments_ld_ok:
if self.engine != "momentsLD":
warnings.warn("Code for momentsLD will not be generated as: "
f"{reason}")
pass
# warnings.warn("Code for momentsLD will not be generated as: "
# f"{reason}")
else:
raise ValueError("MomentsLD requirements are not satisfied: "
f"{reason}")

for engine, is_available in zip(["demes", "momi2"],
[demes_available, momi_available]):
if is_available:
if not self.Nanc_will_be_available():
warnings.warn(
f"Code for {engine} engine will not be generated as "
"ancestral size will be missed in the dem. model. "
"The following options should be set to enable it:\n"
f"`Ancestral size as parameter`: True "
f"(got `self.ancestral_size_as_parameter`)\nor\n"
f"`Mutation rate` (got {self.mutation_rate})\n"
f"`Sequence length` (got {self.sequence_length})\nor\n"
f"`Theta0` (got {self.theta0})")
# for engine, is_available in zip(["demes", "momi2"],
# [demes_available, momi_available]):
# if is_available:
# if not self.Nanc_will_be_available():
# warnings.warn(
# f"Code for {engine} engine will not be generated as "
# "ancestral size will be missed in the dem. model. "
# "The following options should be set to enable it:\n"
# f"`Ancestral size as parameter`: True "
# f"(got `self.ancestral_size_as_parameter`)\nor\n"
# f"`Mutation rate` (got {self.mutation_rate})\n"
# f"`Sequence length` (got {self.sequence_length})\nor"
# f"\n`Theta0` (got {self.theta0})")

if self.ld_kwargs is not None:
if self.engine != "momentsLD":
Expand Down
6 changes: 3 additions & 3 deletions gadma/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ def main():
sys.stdout = StdAndFileLogger(log_file, settings_storage.silence)
sys.stderr = StdAndFileLogger(log_file, stderr=True)

# Check what engines will be available and print warnings
settings_storage.get_available_engines(print_warnings=True)

try:
# Data reading
print("Data reading")
Expand All @@ -90,6 +87,9 @@ def main():
print(f"{bcolors.OKGREEN}--Successful bootstrap data reading--"
f"{bcolors.ENDC}\n")

# Check what engines will be available and print warnings
settings_storage.get_available_engines(print_warnings=True)

# Save parameters
settings_storage.to_files(params_file, extra_params_file)
if not args.test:
Expand Down
2 changes: 1 addition & 1 deletion gadma/core/core_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, index, shared_dict, settings):
self.code_dir = os.path.join(self.output_dir, 'code')
ensure_dir_existence(self.code_dir)
for engine_id in self.available_engines:
engine_dir = os.path.join(self.code_dir, engine.id)
engine_dir = os.path.join(self.code_dir, engine_id)
ensure_dir_existence(engine_dir)
# Set counters to zero for callbacks to count number of their calls
self.draw_iter_callback_counter = 0
Expand Down

0 comments on commit 5d421b4

Please sign in to comment.