Closed Bachibouzouk closed 4 months ago
I've added @ClaudiaLSS and @mohammadamint because I believe they may also be on Windows or a non-Linux system and may help test this.
Hey @FLomb, I've been working on Linux, and it seems to be working fine for me. I'm not sure if I'll be able to test this.
We still need a windows user to tell us if it works, then I will update the documentation with this new command
Perhaps @FraSanvit could make a test on Windows
I've added @ClaudiaLSS and @mohammadamint because I believe they may also be on Windows or a non-Linux system and may help test this.
I have some issues running it (get some errors), not sure if it is the correct way or not:
from ramp import ramp_py2xlsx
ramp_py2xlsx(
"ramp/example/input_file_1.py", # using the example files in ramp
output_path="test.xlsx"
)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File c:\Users\TAHAVORM\Downloads\GitRepos\RAMP\amin_test.py:2
[1](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:1) # %%
----> [2](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:2) ramp_py2xlsx(
[3](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:3) "ramp/example/input_file_1.py",
[4](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:4) output_path="test.xslx"
[5](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:5) )
File c:\Users\TAHAVORM\Downloads\GitRepos\RAMP\ramp\ramp_convert_old_input_files.py:84, in convert_old_user_input_file(fname_path, output_path, suffix, keep_names)
[81](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:81) output_fname = fname_path.split(os.path.sep)[-1].replace(".py", suffix)
[82](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:82) output_fname = os.path.join(output_path, output_fname)
---> [84](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:84) file_module = importlib.import_module(fname)
[86](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:86) user_list = file_module.User_list
[88](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:88) UseCase(users=user_list).save(output_fname)
File c:\Users\TAHAVORM\AppData\Local\miniconda3\envs\ramp\lib\importlib\__init__.py:127, in import_module(name, package)
[125](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:125) break
[126](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:126) level += 1
--> [127](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:127) return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:984, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'ramp/example/input_file_1'
not sure if it is the correct way or not
This should probably be the path which is not what windows expects, maybe if you provide the full absolute path it works ?
If you look at the first post of this thread, I explain how to test this feature in the terminal as well, can you try this as well?
I think the problematic call happens there: https://github.com/RAMP-project/RAMP/blob/8b66734bb3cd146f7b1a09db5ff74a00bb0e4f3e/ramp/ramp_convert_old_input_files.py#L84 maybe you can try to fiddle with it to manage to import any python module (.py file) you create in a folder not within your current directory?
@mohammadamint - I updated the documentation
@s-eckoff did test that it was working on windows, and I tested with a colleague who has windows, it worked
As our tests all passed and I implemented your suggestion I will merge now
This should fix #130
On linux it works. @Stevogallo - could you try on windows?
In a new virtual env, install this ramp version by checking out this branch and then form the root of the repository you type
pip install -e .
To test if it works I suggest you move then within your terminal to a different folder where you copy-paste a
.py
file, then you should be able to convert it to excel using in the command lineramp_convert -i <name of your .py ramp input file>
Alternatively, you should be able to do it from within a python script: