-
Notifications
You must be signed in to change notification settings - Fork 82
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
import-io/improvement #171
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a plugin that is supposed to work now, please check hello world works in py2 and 3 (and write the you already tested that in the PR desc)
input_schema_names = frozenset([e['name'] for e in input.read_schema()]) | ||
output_schema = input.read_schema() | ||
print(')))))))))') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug?
from dataiku.customrecipe import * | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't basic config necessary?
I'd rather not use name and not even use logger =
just use logging.basicConfig
with a decent format (for example I probably did something not horrible for example in azure cognitive services plugins) and then just use logging.info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Joachim, we should share config (nothing fancy, just simple stuff) across plugins)
@@ -13,24 +18,23 @@ def __init__(self, config): | |||
elif self.config['api_url'].startswith('https://extraction.import.io/'): | |||
self.api_version = 'extraction' | |||
else: | |||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe more specifically type the Exception, not necessarily custom but just a more descriptive exception class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we should probably log the exception proper (might be having a moment - does raise do that natively?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved with comments
raise Exception( | ||
'It looks like this URL is not an API URL. URLs to call the API (and get a json response) start with "https://api.import.io" .') | ||
print '[import.io connector] calling API...' | ||
raise Exception('It looks like this URL is not an API URL. URLs to call the API (and get a json response) start with "https://api.import.io" .') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like from the above if/else the url can also start with another prefix? Might be confusing to not log that
@@ -13,24 +18,23 @@ def __init__(self, config): | |||
elif self.config['api_url'].startswith('https://extraction.import.io/'): | |||
self.api_version = 'extraction' | |||
else: | |||
raise Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we should probably log the exception proper (might be having a moment - does raise do that natively?)
raise | ||
logger.error(e) | ||
logger.error('response was:{}'.format(response.text)) | ||
raise ValueError | ||
|
||
def get_read_schema(self): | ||
if self.api_version == 'api': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: couldn't api-version just be a None like value?
else: | ||
return None | ||
return None | ||
|
||
def generate_rows(self, dataset_schema=None, dataset_partitioning=None, partition_id=None, records_limit = -1): | ||
if self.api_version == 'api': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we testing this in every function? also why would api version be api
from dataiku.customrecipe import * | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Joachim, we should share config (nothing fancy, just simple stuff) across plugins)
logger.error('request to import.io failed') | ||
logger.error(e) | ||
logger.error('response was: {}'.format(response)) | ||
raise ValueError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't we masking exceptions? Why not just throw the actual exception? (There's sometimes reason to do this but I don't know if that is the case here as a number of things could be going wrong and it might help user to know)
input_schema_names = frozenset([e['name'] for e in input.read_schema()]) | ||
output_schema = input.read_schema() | ||
print(')))))))))') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 with Joachim, idk what is going on here
DO NOT MERGE