Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I load trained models with Python 2.7? #110

Closed
venegas09 opened this issue Mar 26, 2019 · 14 comments
Closed

How can I load trained models with Python 2.7? #110

venegas09 opened this issue Mar 26, 2019 · 14 comments

Comments

@venegas09
Copy link

venegas09 commented Mar 26, 2019

Description

I want to use a trained model in AWS Lambda and then deploy it on AWS Sagemaker, for local use. The problem is that AWS Lambda in Sagemaker just allows using Python 2.7 so I have to use pmdarima 0.9.0 as highest for the prediction, but I have this issue #107 when reading the trained model. So my question is If there is anything I can do for using pmdarima 0.9.0 without having the #107 issue?

My idea is to train a model on Sagemaker, and then deploy it on AWS Greengrass for local predictions. So I need to run the predictions on Python 2.7.

Versions

Windows-10-10.0.17763
('Python', '2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]')
('pmdarima', '0.9.0')
('NumPy', '1.16.2')
('SciPy', '1.2.1')
('Scikit-Learn', '0.20.3')
('Statsmodels', '0.9.0')

@tgsmith61591
Copy link
Member

Sagemaker is container-based. Can you create a docker image with python 3.5+ and store it in your ECR registry? Paging @charlesdrotar for this one, since he's the AWS expert

@venegas09
Copy link
Author

Yes, I can create and train the model with python 3.5+ in Sagemaker, but then I want to use it in AWS Lambda that only allows Python 2.7, so it breaks.

@aaronreidsmith
Copy link
Member

Lambda allows 2.7, 3.6, and 3.7, as far as I know. I usually run 3.6 in Lambda

@venegas09
Copy link
Author

venegas09 commented Mar 26, 2019

Sorry, I mean Lambda in AWS Greengrass

@aaronreidsmith
Copy link
Member

I am not well-versed in Sagemaker, but just looking at their demo docs, they have an example in 3.7 (pre-labeling) and 2.7 (post-labeling) (link). I can't find anything that says they explicitly only support 2.7, could you link me to that?

@venegas09
Copy link
Author

AWS Greengrass just support Python 2.7 for AWS Lambda functions (maybe you read the previous post that I wrote wrong :( ): https://aws.amazon.com/greengrass/faqs/?nc1=h_ls

@tgsmith61591
Copy link
Member

tgsmith61591 commented Mar 26, 2019

Deviating a bit, the issue you posted yesterday (#107) alludes to the fact that even though you're using pmdarima 0.9.0, your model was probably trained and pickled in an earlier version. Is that correct?

Also, I suspect we're addressing the XY problem a bit here... if your container in SageMaker supports 3.7, and you have your model endpoint there, isn't Lambda just used to invoke that endpoint? In other words, if your SageMaker container is some arbitrary Docker image you store in ECR, should it matter what version of python Lambda supports?

Full disclosure, I'm no AWS guru. Just thinking from an arch standpoint here, and fully ready to admit I don't understand the particulars of your problem.

@venegas09
Copy link
Author

venegas09 commented Mar 26, 2019

Yes, I solved that issue. I just had to train it with the latest version (1.1.0)
Thanks! :)

Also: Maybe I'm not explaining really well, sorry. My problem is that I have to do the prediction with AWS Lambda in Sagemaker (Python 2.7), so I don't want to invoke the Sagemaker endpoint. What I want to do is to load the trained model which is stored in AWS S3 and execute the prediction directly in the function (model.predict(n_periods=x)). But I'm having problems when loading the model in python2.7 (ImportError: No module named pmdarima.arima.arima)

@tgsmith61591
Copy link
Member

Woohoo! I'll close it out then. If anything else comes up, feel free to reach out.

@tgsmith61591
Copy link
Member

@venegas09 this is sounding like a separate issue, if you're getting an ImportError. Also, the updated comments are showing GreenGrass, etc., rather than Sage Maker. This may be a larger issue than is applicable to the package itself. It might be worth us putting together a page in the doc that shows a repeatable pattern for such architectures.

@venegas09
Copy link
Author

But I guess that the importError is because I have trained the model with pmdarima 1.1.0 and then i'm loading it in a machine without that library, because it just uses Python2.7. Could it be possible to train a model in pmdarima 1.1.0 and then make the prediction using pyramid-arima 0.9.0 library?

@tgsmith61591
Copy link
Member

I think this has gone way outside of the scope of the original issue. We decided to stop supporting 2.7 since it is so near end of life, and distributing 5 extra wheels in our CI jobs was so expensive time-wise. That said, there is no overt code that would break 2.7 compat, to my knowledge. You can clone, change this line in the setup.py:

python_requires='>=3.5'

And build from source:

$ make install

You will need Cython.

Now, to address your specific question, perhaps I'll get around to writing a blog post on it someday. But it's far too specific to handle here in the issue board.

@venegas09
Copy link
Author

venegas09 commented Mar 28, 2019

I don't know why but I can't install it from source... (same error as #65) I'm in a Windows 10 machine

@tgsmith61591
Copy link
Member

tgsmith61591 commented Mar 28, 2019

https://www.alkaline-ml.com/pmdarima/setup.html#build-from-source

Please read the doc. I know this is your first issue, so for future reference, keep issues focused. I'm locking this thread

You can also read our appveyor.yml to see how we build on Windows.

@alkaline-ml alkaline-ml locked as off-topic and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants