Hi Alex,
Thanks for integrating the previous fix so fast, and again for providing Rocketsled.
I wanted to also let you know about a couple changes I had to make to get it to run:
1) Run on my Windows sandbox, and,
2) Run RS jobs that were not located in my Python install directory (I wanted to store my RS jobs in a separate work folder)
The changes I made were all in utils.py’s serialize() / deserialize() functions (see attached):
1) Change the “/” to Python’s “os.sep” OS-dependent filepath separator so it work son windows
2) Modify serialize() to try getting the “wf_creator” function from the RS Job’s module first
Steps to reproduce:
1) Copy basic.py somewhere outside the Python installation dir
a. In this case, I used: C:\Users\abe\rmsit\workspaces\projects\ers3_rocketsled_scripts
2) Rename “basic.py” to “basic2.py” (or any other name that is not already used by a module in your Python installation dir)
3) Run basic2.py
It errors out with:
Traceback (most recent call last):
File "<ipython-input-1-5a380a7f1dd2>", line 1, in <module>
runfile('C:/Users/abe/rmsit/workspaces/projects/ers3_rocketsled_scripts/basic2.py', wdir='C:/Users/abe/rmsit/workspaces/projects/ers3_rocketsled_scripts')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/abe/rmsit/workspaces/projects/ers3_rocketsled_scripts/basic2.py", line 96, in <module>
mc.configure(wf_creator=wf_creator, dimensions=x_dim)
File "C:\ProgramData\Anaconda3\lib\site-packages\rocketsled\control.py", line 219, in configure
wf_creator = serialize(wf_creator)
File "C:\ProgramData\Anaconda3\lib\site-packages\rocketsled\utils.py", line 122, in serialize
"you sure it's module is in your PYTHONPATH?".format(fun_path))
ImportError: Administrator.rmsit.workspaces.projects.ers3_rocketsled_scripts.basic2.wf_creator couldn't be serialized to be imported. Are you sure it's module is in your PYTHONPATH?
I added a print statement to print out the function path it was trying to resolve:
for _ in range(5):
try:
# if we couldn't find the func, try adding the parent folder name to the import path
full_import_path = all_pkgs[-1] + "." + full_import_path
all_pkgs = all_pkgs[:-1]
fun_path = full_import_path + "." + name
print("fun_path: {}".format(fun_path))
deserialize(fun_path)
return fun_path
except ImportError:
continue
else:
raise ImportError("{} couldn't be serialized to be imported. Are "
"you sure it's module is in your PYTHONPATH?".format(fun_path))
This is the output of the print statement:
2019-06-06 11:33:31,422 INFO Optimization collection opt_default hard reset.
fun_path: ers3_rocketsled_scripts.basic2.wf_creator
fun_path: projects.ers3_rocketsled_scripts.basic2.wf_creator
fun_path: workspaces.projects.ers3_rocketsled_scripts.basic2.wf_creator
fun_path: rmsit.workspaces.projects.ers3_rocketsled_scripts.basic2.wf_creator
fun_path: abe.rmsit.workspaces.projects.ers3_rocketsled_scripts.basic2.wf_creator
So it never tried to look up the base case “basic2.wf_creator”. I rearranged the code in the for-loop like so, but will defer to you on whether this is the right thing to do:
for _ in range(5):
try:
fun_path = full_import_path + "." + name
print("fun_path: {}".format(fun_path))
deserialize(fun_path)
return fun_path
except ImportError:
# if we couldn't find the func, try adding the parent folder name to the import path
full_import_path = all_pkgs[-1] + "." + full_import_path
all_pkgs = all_pkgs[:-1]
continue
else:
raise ImportError("{} couldn't be serialized to be imported. Are "
"you sure it's module is in your PYTHONPATH?".format(fun_path))
The output of the print statement now gets “basic2.wf_creator” on the first iteration of the for-loop:
fun_path: basic2.wf_creator
I tested this out with Anaconda3 on a Windows 7 VM. Like I said, I will defer to you on whether these are the right code changes. I just know I had to make these changes to get it to work on my Win7 box, and I figured I’d share so hopefully it makes it easier for you. I would have done a pull request on Github, but I need to check on our corporate policies before I can do that, so I figured I would just email you to get it to you faster. Sorry about that.
If you have any feedback, please feel free to let me know!
Thanks,
Abe