2 months ago
I used a guideline to attach Volume to my project with folder called "/models".
RAILWAY_VOLUME_MOUNT_PATH = /models
Can I read/write also from imported py scripts (within builded image) - or Volume is only mounted to main Service? Which is api.py (fastapi) script in my case and imports are not allowed to save into mounted volume?
I am asking because when api endpoint pass execution to imported py file function...it runs properly until side script tries to save my file to /models/myfile. Here is logging error...
No such file or directory: 'models/5_H1_EURUSD.joblib'
6 Replies
2 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
2 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 2 months ago
2 months ago
Howdy! With Railway volumes they are mounted at the path you set.
So /models is an absolute path.
The file models/5_H1_EURUSD.joblib is in a relative path (at the current dir) so you would need to change that to /models/5_H1_EURUSD.joblib` and it should work!
2 months ago
Any script in your app has full access to the volume. You can think of a volume as just a folder on the computer that your application is running on. Anything on that same computer has access to that folder. What's happening in your case is its just not finding that folder. My best guess is that it's not mounted on the correct location. Your application looks like this on Railway (when built with Railpack/Nixpacks):
- root
- app
- main.pyif you mount a volume to /data in your service then your filetree will look like this:
- root
- app
- main.py
- dataIn this case, for your scripts to reach the data folder, they need to escape the app directory. You can make this simpler by attaching data directly into the app directory by mounting the volume to /app/data, in which case the structure looks like this:
- root
- app
- main.py
- dataIn your case, you likely want to mounting the models folder inside of your app folder by mounting the volume to /app/models instead of /models. Keep in mind this is only my best guess, can you confirm where your volume is mounted and whether or not youre using Railpack/Nixpacks to build (if you didnt set a Dockerfile then you likely are building using Railpack/Nixpacks)
noahd
Howdy! With Railway volumes they are mounted at the path you set. So /models is an absolute path. The file models/5_H1_EURUSD.joblib is in a relative path (at the current dir) so you would need to change that to /models/5_H1_EURUSD.joblib` and it should work!
2 months ago
Damn bro beat me to it
