dadi-cli: import model syntax error

22 views
Skip to first unread message

Alexandra Sumarli

unread,
Jul 5, 2024, 12:53:35 PM (12 days ago) Jul 5
to dadi-user

Dear Ryan and dadi team,

I am attempting to import some models from Rougeux et al., (2017) into dadi-cli, but I am running into a syntax error (below and in screenshot). The model file that I used (“modeledemo_new_models.py”) from the author’s GitHub is here. I was wondering if there is a way to resolve this issue so that I can import these models?

 

Thank you for your time!

Best,

Alex

 

Input

>dadi-cli InferDM --model IM2N --model-file modeledemo_new_models.py --fs CB-CL.sfs --ubounds 10 10 10 10 10 10 10 10 .5 --lbounds 1e-2 1e-2 0 0 0 0 0 0 0 --output CB_CL.IM2N.demog.params --optimizations 10 --global-optimization

 

Output

dadi-cli InferDM --model IM2N --model-file modeledemo_new_models.py --fs CB-CL.sfs --ubounds 10 10 10 10 10 10 10 10 .5 --lbounds 1e-2 1e-2 0 0 0 0 0 0 0 --output CB_CL.IM2N.demog.params --optimizations 10 --global-optimization
Traceback (most recent call last):
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/site-packages/dadi_cli/Models.py", line 56, in get_model
    func = getattr(importlib.import_module(model_file), model_name)
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'modeledemo_new_models'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alexandrasumarli/opt/miniconda3/bin/dadi-cli", line 10, in <module>
    sys.exit(main())
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/site-packages/dadi_cli/__main__.py", line 1890, in main
    args.runner(args)
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/site-packages/dadi_cli/__main__.py", line 235, in run_infer_dm
    func, param_names = get_model(args.model, args.model_file)
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/site-packages/dadi_cli/Models.py", line 65, in get_model
    func = getattr(importlib.import_module(model_file), model_name)
  File "/Users/alexandrasumarli/opt/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 983, in get_code
  File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/alexandrasumarli/Desktop/White_sticklebak_wgs_vcfs/REDO_reformatted_for_demo_modeling_CB_CL_wheat_061224/dadi_runs/modeledemo_new_models.py", line 8
    def SI(params, (n1,n2), pts):
                               ^
SyntaxError: invalid syntax

dadi_cli_syntax_error.png

Ryan Gutenkunst

unread,
Jul 5, 2024, 3:57:01 PM (12 days ago) Jul 5
to dadi-user
Hello Alex,

I think the issue is the use of (n1,n2) in the arguments list. It should be easy to fix. In each function you want to use, change (n1, n2) in the arguments list for “ns". And then as the first line in the function add the line "n1,n2 = ns”. For example:

def SI(params, ns, pts):
    n1, n2 = ns
    nu1, nu2, Ts, O = params
    <snip>

Best,
Ryan

<dadi_cli_syntax_error.png>


--
You received this message because you are subscribed to the Google Groups "dadi-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dadi-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dadi-user/0c8e3160-f269-42cf-9321-106f94600e23n%40googlegroups.com.
<dadi_cli_syntax_error.png>

Reply all
Reply to author
Forward
0 new messages