Comments (5)
Can we get the error that was thrown why trying to install the wheel file?
from amazon-redshift-udfs.
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.
Did you ever resolve this? I'm having the same issue.
from amazon-redshift-udfs.
See latest libraryInstaller.sh this is resolved.
from amazon-redshift-udfs.
Fix included here https://github.com/aws-samples/amazon-redshift-udfs/blob/master/bin/libraryInstaller.sh
from amazon-redshift-udfs.
Related Issues (20)
- RedShift function to import S3 file HOT 1
- Script fails to find wheel files or zip results. HOT 1
- import fails for murmur2 package HOT 2
- Redshift can't open shared object file HOT 1
- [Enhancement] f_rank_td HOT 1
- [Enhancement] f_oreplace_td
- [Enhancement] f_octet_length_td
- [Enhancement] f_char2hexint_td
- [Enhancement] f_csvld_td
- [Enhancement] f_nvp_td
- [Enhancement] f_transalate_td
- [Enhancement] f_translate_chk_td
- [Enhancement] Support Python Lambda UDFs w/ dependent libraries
- [Enhancement] Example for C++ Lambda UDF
- [Enhancement] Example Java UDF HOT 2
- [Feature Request] String comparison Python UDF example HOT 1
- Broken link to index.js for lambda-udfs/f_upper_nodejs
- Support non-Commercial partitions
- ua-parser not working: No module named _regexes. Please look at svl_udf_log for more information HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-redshift-udfs.