Code Monkey home page Code Monkey logo

Comments (5)

IanMeyers avatar IanMeyers commented on September 23, 2024

Can we get the error that was thrown why trying to install the wheel file?

from amazon-redshift-udfs.

Varshasavya avatar Varshasavya commented on September 23, 2024

Here are the steps followed and the errors encountered by the customer.

I've been having some trouble trying to load a particular Python package (https://github.com/selwin/python-user-agents) into Redshift as a library.

Things I've tried:
(1) From the link in the Github repo, I zipped the python-user-agents/user_agents folder, uploaded it to s3 and created the library using a CREATE LIBRARY statement. Once I did this, I wrote a small UDF just importing the relevant class from the user_agents module I wanted to use. However, I got an import error for a different module (ua_parser), which user_agents depends on.
(2) Given the outcome of (1), I figured I needed to have all module dependencies present in the zip file (is this information documented somewhere?). I ended up finding this nifty looking import script from you guys here (https://github.com/aws-samples/amazon-redshift-udfs/blob/master/bin/PipLibraryInstaller/installPipModuleAsRedshiftLibrary.sh), which builds wheel files for a python module and all its dependencies, zips them together and uploads the zip file to s3. After making a couple of modifications (namely, those in: https://github.com/aws-samples/amazon-redshift-udfs/pull/16/files), I uploaded the new user_agents.zip file to s3 and recreated the library in Redshift (along with the test UDF). I got another import error, but this time for the user_agents module itself.

I'd like to be able to use the module import script in the future, so could you tell me what I'm doing wrong? I'm attaching both versions of the python package (from (1) and (2), but I'm attaching them with different names, to be less confusing for you). The CREATE LIBRARY statement I used was:
"""
CREATE OR REPLACE LIBRARY user_agents
LANGUAGE plpythonu
FROM 's3://<s3_dir>/user_agents.zip'
CREDENTIALS '<redshift_iam_role_creds>'
;
"""
(NOTE: again, the zip files actually had the name user_agents.zip at the time of uploading).

The test UDF I wrote was:
"""
CREATE OR REPLACE FUNCTION f_user_agent_test (ua_string VARCHAR)
RETURNS VARCHAR
IMMUTABLE
AS $$
from user_agents import parse
return ua_string
$$ LANGUAGE plpythonu
;
"""

And the query I used to validate was:
"""
SELECT f_user_agent_test('blah');


The error messages were as follows (numbered as in "Things I've tried"):

(1) -----
message: "ImportError: No module named ua_parser"
traceback: """
line 2, in f_user_agent_test
File "init.py", line 3, in
File "parsers.py", line 3, in
"""

(2) -----
message: "ImportError: No module named user_agents"
traceback: "line 2, in f_user_agent_test"

from amazon-redshift-udfs.

mfutch78 avatar mfutch78 commented on September 23, 2024

Did you ever resolve this? I'm having the same issue.

from amazon-redshift-udfs.

rjvgupta avatar rjvgupta commented on September 23, 2024

See latest libraryInstaller.sh this is resolved.

from amazon-redshift-udfs.

Varshasavya avatar Varshasavya commented on September 23, 2024

Fix included here https://github.com/aws-samples/amazon-redshift-udfs/blob/master/bin/libraryInstaller.sh

from amazon-redshift-udfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.