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

Replace the use of numpy #19

Closed
jkinred opened this issue Aug 24, 2019 · 6 comments
Closed

Replace the use of numpy #19

jkinred opened this issue Aug 24, 2019 · 6 comments

Comments

@jkinred
Copy link

jkinred commented Aug 24, 2019

Is it necessary to import numpy to get access to long? There is a long built-in for Python 2.

The import of numpy makes use of this project quite inefficient for deploying on Lambda (25MB bundle) as well as causing locking issues delays with Pipenv.

from numpy import long

if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821

@asqui
Copy link

asqui commented Sep 2, 2019

Curious. I did wonder why there was a dependency on numpy in SDK v2 but never looked into it.

This looks like an accidental import of long from numpy, leading to an accidental package dependency on numpy!

In this case, can you just use six.integer_types in place of the conditional expression?

if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821

In this case, you simply do not need the import. In Python 3, long will not be evaluated; in Python 2, it exists as a builtin.

'long': int if six.PY3 else long, # noqa: F821

Judging by the # noqa: F821 exclusion ("Undefined name"), it may have been like this originally, and then someone 'helpfully' added an import for the undefined long?

(Unfortunately I don't see a six constant to represent this concept of "long on Python 2, int on Python 3". If using future instead of six, it has a better way of dealing with this scenario: from past.builtins import long: https://python-future.org/compatible_idioms.html#long-integers)

@jkinred
Copy link
Author

jkinred commented Sep 2, 2019

I have drawn the same conclusion as you and have applied pretty much what you've said on a fork which I have deployed and running on Python 3. I have not yet had a chance to test it is compatible with Python 2 or indeed what test cases need to be hit.

master...jkinred:master

@dbanty
Copy link

dbanty commented Sep 27, 2019

@jkinred is there any update on this? My company just started using OpsGenie and we'd like to log problems directly to it from our Python applications. Requiring numpy in those applications is definitely a non-option.

@konstantin-kornienko
Copy link

Any updates here?

@defreng
Copy link

defreng commented Feb 20, 2020

I agree, removing the numpy dependency would be great!

Right now it is very annoying to include the opsgenie-sdk dependency, for example in an alpine docker container, because it needs to compile numpy.

Also it seems to be an easy fix?

@yaleman
Copy link
Contributor

yaleman commented Dec 7, 2020

I've submitted a PR to fix this in #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants