Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple errors on Windows 10 #2

Open
bobturneruk opened this issue Jul 20, 2021 · 7 comments
Open

Multiple errors on Windows 10 #2

bobturneruk opened this issue Jul 20, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@bobturneruk
Copy link
Contributor

Running:

python test_trace.py

results in numerous errors e.g.

RuntimeError
The above exception was the direct cause of the following exception:

: Traceback (most recent call last):

        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.  File "<string>", line 1, in <module>


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 116, in spawn_main
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 125, in _main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 236, in prepare
    prepare(preparation_data)
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 287, in _fixup_main_from_path
        _fixup_main_from_path(data['init_main_from_path'])main_content = runpy.run_path(main_path,

  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\multiprocess\spawn.py", line 287, in _fixup_main_from_path
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 265, in run_path
        main_content = runpy.run_path(main_path,return _run_module_code(code, init_globals, run_name,

  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 265, in run_path
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,return _run_module_code(code, init_globals, run_name,

  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 87, in _run_code
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 97, in _run_module_code
        exec(code, run_globals)_run_code(code, mod_globals, init_globals,

  File "C:\Users\bobturner\Documents\causcumber\scenarios\basic-end2end\test_trace.py", line 156, in <module>
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)run_covasim("Baseline", base_params.copy(), [])

  File "C:\Users\bobturner\Documents\causcumber\scenarios\basic-end2end\test_trace.py", line 156, in <module>
  File "C:\Users\bobturner\Documents\causcumber\scenarios\basic-end2end\test_trace.py", line 84, in run_covasim
        run_covasim("Baseline", base_params.copy(), [])intervention_sim.run(n_runs=n_runs, verbose=0)

  File "C:\Users\bobturner\Documents\causcumber\scenarios\basic-end2end\test_trace.py", line 84, in run_covasim
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 167, in run
    intervention_sim.run(n_runs=n_runs, verbose=0)
self.sims = multi_run(sims, **kwargs)  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 167, in run

  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 1468, in multi_run
    self.sims = multi_run(sims, **kwargs)
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 1468, in multi_run
    raise E
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 1449, in multi_run
        raise Esims = sc.parallelize(single_run, iterkwargs=iterkwargs, kwargs=kwargs, **par_args) # Run in parallel

  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\covasim\run.py", line 1449, in multi_run
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\sciris\sc_parallel.py", line 285, in parallelize
    raise RuntimeError(errormsg) from E
RuntimeError:
 Uh oh! It appears you are trying to run with multiprocessing on Windows outside
 of the __main__ block; please see https://docs.python.org/3/library/multiprocessing.html
 for more information. The correct syntax to use is e.g.

 import sciris as sc

 def my_func(x):
     return

 if __name__ == '__main__':
     sc.parallelize(my_func)

sims = sc.parallelize(single_run, iterkwargs=iterkwargs, kwargs=kwargs, **par_args) # Run in parallel
  File "C:\Users\bobturner\.conda\envs\causcumber\lib\site-packages\sciris\sc_parallel.py", line 285, in parallelize
    raise RuntimeError(errormsg) from E
RuntimeError:
 Uh oh! It appears you are trying to run with multiprocessing on Windows outside
 of the __main__ block; please see https://docs.python.org/3/library/multiprocessing.html
 for more information. The correct syntax to use is e.g.

 import sciris as sc

 def my_func(x):
     return

 if __name__ == '__main__':
     sc.parallelize(my_func)
@bobturneruk
Copy link
Contributor Author

This may be a covasim issue.

@jmafoster1
Copy link
Contributor

Yeah I think it is a covasim issue. What are you using to run the program? I find I get that kind of issue on Spyder sometimes but never if I run it from the terminal.

@bobturneruk
Copy link
Contributor Author

Terminal. Python 3.8, Windows 10. I typically don't use Spyder - VSCode is my IDE of choice. I'm adaptable, though!

@bobturneruk
Copy link
Contributor Author

I'll investigate further,

@jmafoster1
Copy link
Contributor

That's really weird, then. The issues do look to be Windows specific, so I'm afraid I can't help you. I've not used Windows for years. Maybe see if you can run the basic covasim tutorials on your machine, and then create an issue over there if it's still not working?

@bobturneruk
Copy link
Contributor Author

Yes. I'm fine with whatever OS, but I'll try and pin this down.

@AndrewC19
Copy link

AndrewC19 commented Jul 20, 2021

This is a Covasim issue. Multiprocessing on Windows is strange so we need to run covasim from within a main block. We should do this everywhere to ensure compatability with Windows.

The issue is explained here.

I'll open a PR with a fix.

@AndrewC19 AndrewC19 added the bug Something isn't working label Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants