Skip to content

Conversation

@du-phan
Copy link
Contributor

@du-phan du-phan commented Dec 18, 2019

DO NOT MERGE

  • Add code-env
  • Add support for python 3

Copy link
Contributor

@JoachimZ JoachimZ left a 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)

logger.error("Setting schema")
input_schema_names = frozenset([e['name'] for e in input.read_schema()])
output_schema = input.read_schema()
print(')))))))))')
Copy link
Contributor

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__)
Copy link
Contributor

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

Copy link

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)

elif self.config['api_url'].startswith('https://extraction.import.io/'):
self.api_version = 'extraction'
else:
raise Exception(
Copy link

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

Copy link

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?)

Copy link

@ghost ghost left a 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" .')
Copy link

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

elif self.config['api_url'].startswith('https://extraction.import.io/'):
self.api_version = 'extraction'
else:
raise Exception(
Copy link

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 ValueError

def get_read_schema(self):
if self.api_version == 'api':
Copy link

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?

return None

def generate_rows(self, dataset_schema=None, dataset_partitioning=None, partition_id=None, records_limit = -1):
if self.api_version == 'api':
Copy link

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__)
Copy link

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
Copy link

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)

logger.error("Setting schema")
input_schema_names = frozenset([e['name'] for e in input.read_schema()])
output_schema = input.read_schema()
print(')))))))))')
Copy link

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

@tdesfont tdesfont changed the title Import io/improvement import-io/improvement Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants