Errors in running the cli
agneta20 opened this issue · 22 comments
Did you download the ystafdb data, and put it in the data folder?
Yes I did
Unfortunately, I do not have a windows computer available right now, but will test it when at home.
I will try to replicate the error later today.
@IKnowLogic @agneta20 has installed the cli (is in the site packages)
and the cli looks for a local (to the script) folder while Agneta has the database local to where she is running the code.
The code should check this and use the absolute path relative to the location the cli is run.
@agneta20 can you provide the full path where you located the csv
file please?
Also, as a general rule, always check if a file exist before reading it and if this does not exist print an error with the absolute path where the file was supposed to be
I saved the csv files in the ystafdb folder that I had cloned from git in my local drive C:\Users\agneta\Desktop\ystafdb
@agneta20 shouldn't it be in the \data
next to the cli?
so in C:\Users\agneta\Desktop\ystafdb\data
?
There is a nested layer of ystafdb folders.
The data should be paced in ystafdb\ystafdb\data\
@agneta20 can you provide a view of how your directories are organized ?
[a screenshot is fine]
If I follow current instructions (that are ambiguous) here's the structure I created, that yields the same error:
ystafdb
├── bin
│ ├── __init__.py
│ └── ystafdb.py
├── config_parser.py
├── data
│ ├── affiliations.csv
│ ├── aggregate_subsystem_modules.csv
│ ├── citations.csv
│ ├── config.json
│ ├── contributors.csv
│ ├── criticality.csv
│ ├── criticality_ei_citations.csv
│ ├── criticality_ei.csv
│ ├── criticality_sr_citations.csv
│ ├── criticality_sr.csv
│ ├── criticality_timeframes.csv
│ ├── criticality_vsr_citations.csv
│ ├── criticality_vsr.csv
│ ├── cross_boundary_flows_citations.csv
│ ├── cross_boundary_flows.csv
│ ├── cross_boundary_flow_types.csv
│ ├── flows_citations.csv
│ ├── flows.csv
│ ├── indexes.csv
│ ├── material_names.csv
│ ├── methods.csv
│ ├── processes_citations.csv
│ ├── processes.csv
│ ├── process_names.csv
│ ├── process_types.csv
│ ├── publications.csv
│ ├── recycling_citations.csv
│ ├── recycling.csv
│ ├── recycling_use_types.csv
│ ├── reference_materials.csv
│ ├── reference_spaces.csv
│ ├── reference_timeframes.csv
│ ├── reliabilities.csv
│ ├── stock_types.csv
│ ├── subsystems.csv
│ ├── system_boundaries.csv
│ ├── trade_codes.csv
│ ├── trade_data_sources.csv
│ ├── units.csv
│ └── YSTAFDB_CSV_files.zip
I have the impression that the issue is then the one I was mentioning above.
I think the package is looking in the wrong directory: inside the package instead of the directory where the script is run.
This should be changed in the code
Yes, the culprit (line https://github.com/BONSAMURAIS/ystafdb/blob/master/ystafdb/config_parser.py#L10 ) will look for an absolute path.
To make things work @agneta20 you must:
- uninstall the package ystafdb (
pip uninstall ystafdb
) - put the csv files under
ystafdb/ystafdb/data
- install the package with:
python setup.py install
the "install" part of the package will take care of copying whatever is under the "ystafdb/ystafdb/data" directory to the final destination of the package .
I suggest that we update the installation instructions so that before providing the actual instal commands, we drive the user to download the necessary csv files and put them where they belong (see my workaround above).
This would only be a workaround, in general terms it would be better if the cli tool could take as input the location of the necessary csv files, so that the end-user can place them anywhere, and the cli tool remains independent. I'll create an issue for this.
Yes, I think is more efficient to search the data. Also is not nice to have an installation of a package full of data.
@IKnowLogic can you fix that?
@tngTUDOR That sounds like a good idea, I will write up the implementation.
The workaround I proposed above (#1 (comment)) will work for an installation based on cloning the repository and doing a python setup.py install
based installation, but not for a pip based installation. Hence the need for:
- Better install instructions (see #2 )
- A means to tell the cli where to find the ystaf data