Closed jerbaroo closed 4 years ago
I installed the package using poetry
and tried to run example.py
. Here are the errors I encountered so far:
Cannot find the root of the project if it is not a git repo.
Traceback (most recent call last):
File "C:/Users/arpada/Wok/Projects/python_sandbox/bridge_sim_pip/bridge_sim_pip/example.py", line 4, in <module>
config = configs.opensees_default(bridges.bridge_narrow)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\bridge_sim\configs\__init__.py", line 33, in opensees_default
vehicle_data_path=os.path.join(project_dir(), "data/traffic/traffic.csv"),
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\bridge_sim\util.py", line 60, in project_dir
return os.path.dirname(findup.glob(".git"))
File "c:\users\arpada\appdata\local\programs\python\python38\lib\ntpath.py", line 223, in dirname
return split(p)[0]
File "c:\users\arpada\appdata\local\programs\python\python38\lib\ntpath.py", line 185, in split
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
INFO: Found Opensees at: c:\Users\arpada\Wok\OpenSees3.2.0-x64.exe\bin\OpenSees.exe
I think a solution like this would be fine:
__main__
After I run git init
I receive a different error message when trying to run example.py
: traffic data is missing.
INFO: Found Opensees at: c:\Users\arpada\Wok\OpenSees3.2.0-x64.exe\bin\OpenSees.exe
Traceback (most recent call last):
File "C:/Users/arpada/Wok/Projects/python_sandbox/bridge_sim_pip/bridge_sim_pip/example.py", line 4, in <module>
config = configs.opensees_default(bridges.bridge_narrow)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\bridge_sim\configs\__init__.py", line 30, in opensees_default
return Config(
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\bridge_sim\model\__init__.py", line 251, in __init__
self.vehicle_data = load_vehicle_data(vehicle_data_path)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\bridge_sim\vehicles\sample.py", line 174, in load_vehicle_data
return pd.read_csv(vehicle_data_path, usecols=col_names, index_col=index_col_name)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\pandas\io\parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\pandas\io\parsers.py", line 448, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\pandas\io\parsers.py", line 880, in __init__
self._make_engine(self.engine)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\pandas\io\parsers.py", line 1114, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\arpada\AppData\Local\pypoetry\Cache\virtualenvs\bridge-sim-pip-zJKk_yHz-py3.8\lib\site-packages\pandas\io\parsers.py", line 1891, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas\_libs\parsers.pyx", line 374, in pandas._libs.parsers.TextReader.__cinit__
File "pandas\_libs\parsers.pyx", line 674, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] File C:\Users\arpada\Wok\Projects\python_sandbox\bridge_sim_pip\data/traffic/traffic.csv does not exist: 'C:\\Users\\arpada\\Wok\\Projects\\python_sandbox\\bridge_sim_pip\\data/traffic/traffic.csv'
Either the data should be part of the pip package or come from an external source. In one my projects I use a public S3
bucket to host data and the pip installed package can download it if needed. This way it does not contaminate the package source code and does not increase its size. I use the data during unit testing so there is even more reason to not add it to the package.
Here is a minimal working example how I set it up:
import os
import numpy as np
TEST_DATA_BASE_URL = "https://prob-taralli-data.s3.eu-central-1.amazonaws.com/kde/"
expected_density_vec = np.loadtxt(
fname=os.path.join(
TEST_DATA_BASE_URL, "1d_density%23gaussian_mixture%23matlab.txt"
)
)
I thought the installation process was a little too smooth, I think I was installing my local development package rather than what I was pushing to PyPI.
I included a few files in the Python package, easier to setup, and compressed filesize is 4.0 MB according to PyPI which is still fine.
include = [
"model-template-3d.tcl",
"data/temperature/holly-springs-18.txt",
"data/temperature/holly-springs-19.txt",
"data/traffic/traffic.csv",
"data/bridge705/bridge-705.org"]
os.path.dirname(findup.glob(".git")) -> pathlib.Path(__file__).parents[1].absolute()
Thanks for the updates and for publishing it on pypi. I tested it on my Windows 10 machine, it works.
A weird Windows thing: after I updated the bridge-sim
package it could not find the OS exe anymore. although it was added to the environmental variables of the system. I had to add the OS exe to the environmental variables of my account.
Closes #165
@rozsasarpi the purpose of this pull request is to provide a Python package on PyPI which required a little restructuring of the code. Can you take it for a little spin before I merge to master, following the installation instructions https://github.com/barischrooneyj/bridge-sim/blob/publish-on-pypi/README.org#concrete-slab-bridge-simulation. Mainly just check that the PyPI package actually works for you.