Handle Files or directories with DRF apps
stephano21
HOBBYOP

2 years ago

I'm developing an API in Django Rest Framework, and in one of my applications called 'Predict,' I've created a directory named 'data' where I have a file handling the logic to obtain data and pass it to a pre-trained model 'Model.joblib,' which is in the same directory as the file. Now, on my local machine, it works by passing the absolute path, but in production on 'Railway,' it doesn't work with either absolute or relative paths.
I have no idea what it could be, I haven't investigated thoroughly but I really need to fix this immediately, I appreciate your help in advance.

25 Replies

2 years ago

Can you share some of the paths you've tried, what paths work locally and what paths don't work on Railway, and the errors you are getting.


stephano21
HOBBYOP

2 years ago

There is the implementation locally and the initial error.


2 years ago

Those don't look like file path related errors to me?


stephano21
HOBBYOP

2 years ago

Well, as I mentioned earlier, I superficially investigated, and it was suggested to me to check the issue with paths. Still, I continue testing, and if I find something, I will document it


stephano21
HOBBYOP

2 years ago

This happens when I use a relative path.

Attachments


stephano21
HOBBYOP

2 years ago

This happens when I use an absolute path.

"Error al sincronizar el dataset:Layer 'simplernncell' expected 3 variables, but received 0 variables during loading. Expected: ['simplernn8/simplernncell/kernel:0', 'simplernn8/simplernncell/recurrentkernel:0', 'simplernn8/simplernn_cell/bias:0']"

Attachments


2 years ago

English only, please.

Without knowing your project structure or your deployment strategy I would just be guessing, So I would recommend just keep debugging this, different paths, etc.


stephano21
HOBBYOP

2 years ago

It's important to emphasize that this exception doesn't occur locally.


2 years ago

I'm sorry but that doesn't mean this isn't a code and or config issue.


stephano21
HOBBYOP

2 years ago

If you are using a production environment, make sure that access permissions to the model and storage directories are correct and properly configured.

Could this be a reason? Since I consider Railway to be quite pragmatic with file exposure, in my opinion.


2 years ago

No, you aren't getting permission errors.


stephano21
HOBBYOP

2 years ago

I understand, so I would have to validate the model construction itself to rule that out as well. Thank you very much for the clarifications and help.


2 years ago

Just had a thought, is the model in Git LFS? If so, Railway does not pull files from Git LFS.


stephano21
HOBBYOP

2 years ago

The model is from TensorFlow, it's in '.joblib' format, and this is where I compiled it, so to speak.

from joblib import dump
dump(bestrfmodel, 'model.joblib')


2 years ago

I'm sorry but that doesn't answer my question.


stephano21
HOBBYOP

2 years ago

No, the model is in its original extension, I just verified it, or at least I think so, but yes, I uploaded the binary to the repository


2 years ago

I'm sorry but that doesn't quite answer my question.


stephano21
HOBBYOP

2 years ago

Well, I wouldn't know exactly when GitHub or Git does it through Git LFS, so I would believe it's not that type of file. How could I check it? I think I didn't attach a screenshot in my previous response.
I think the attachment limit has been exceeded.


2 years ago

No worries if you don't know what Git LFS is or what it entails, that's why GitHub writes documentation!


stephano21
HOBBYOP

2 years ago

PS C:\ProyectosSChang\VictoriaAPI> git lfs ls-files PS C:\ProyectosSChang\VictoriaAPI>
PS C:\ProyectosSChang\VictoriaAPI> git lfs ls-files PS C:\ProyectosSChang\VictoriaAPI>

I think I have ruled out that possibility


2 years ago

How big is the modal file?


stephano21
HOBBYOP

2 years ago

144 kb


2 years ago

Alright, then this goes back to code and or config issue.


stephano21
HOBBYOP

2 years ago

That's right, I will validate that tomorrow, I will keep you informed


2 years ago

Sounds good!


Loading...