Skip to content

Conversation

@eywalker
Copy link
Contributor

Implemented changes discussed in #318, namely:

  • Updated fetch and fetch1 __call__ syntax to take in unnamed arguments as attribute names
  • Deprecated the following properties/methods: order_by, limit, offset, as_dict, squeeze, __getitem__(rel.fetch[] and rel.fetch1[] syntax). Invoking these methods will now throw a deprecation warning
  • Properly handle warning messages. Namely, remove capturing of warnings by logging as this is not something a library should do!
  • Warnings issued by call to underlying pymysql are appropriately silenced
  • Added tests for new fetch syntax while keeping tests for previous syntax until the old syntax is completely removed in a future release.

With this major feature addition (i.e. ability to fetch individual attributes with __call__), the version number has been incremented from 0.6.1 to 0.7.0 in accordance to semver.

@coveralls
Copy link

coveralls commented Jun 10, 2017

Coverage Status

Coverage increased (+0.05%) to 93.107% when pulling 283dd99 on eywalker:master into 17acda7 on datajoint:master.

Copy link
Member

@dimitri-yatsenko dimitri-yatsenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve but I think there are additional opportunities for improvement that we may as well pursue now.


sql_behavior = update_dict(self.sql_behavior, kwargs)
ext_behavior = update_dict(self.ext_behavior, kwargs)
total_behavior = dict(sql_behavior)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we don't need the 'behaviors' dicts anymore since fetch no longer has a state. We could just keep the individual settings in their own variables -- it will be more explicit and more succinct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - just note that we are still going to keep backward compatible behavior for a few rounds and hence I'm not drastically changing the internals yet.

ret = OrderedDict((name, unpack_(ret[name]) if heading[name].is_blob else ret[name])
for name in heading.names)
else:
single_output = len(attrs) == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single_output assignment can be moved closer to where it's used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

"""

def __call__(self, **kwargs):
def __call__(self, *attrs, **kwargs):
Copy link
Member

@dimitri-yatsenko dimitri-yatsenko Jun 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead of the anonymous **kwargs we should use named arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that would actually be cleaner - probably in next iteration.

warnings.warn('Use of `squeeze` on `fetch` object is deprecated. Please use `squeeze=True` keyword arguments '
'in the call to `fetch`/`keys` instead', stacklevel=2)

ret = self.copy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should deprecate FetchBase.copy too. It seems to be needed only for the old stateful Fetch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this will be deprecated once statefullness is completely retired.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just saying that it should be marked DEPRECATED like the other deprecated things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usage is only internal hence I didn't put explicit deprecate. I guess I could add that now.

@property
def squeeze(self):
"""
DEPRECATED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could remove FetchBase and Fetch1 and make Fetch do everything. Fetch would then have the argument exactly_one. The fetch1 method could simply call fetch(*args, exactly_one=True, **kwargs). This could obviate the inheritance and the state handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's think about it but let's not all of the sudden go about changing everything.

@coveralls
Copy link

coveralls commented Jun 10, 2017

Coverage Status

Coverage increased (+0.05%) to 93.103% when pulling 7ff082a on eywalker:master into 17acda7 on datajoint:master.

@dimitri-yatsenko dimitri-yatsenko merged commit 332e061 into datajoint:master Jun 10, 2017
@eywalker eywalker mentioned this pull request Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants