Skip to content

Implement soft link and external link#87

Open
lepmik wants to merge 5 commits intodevfrom
lepmik/links
Open

Implement soft link and external link#87
lepmik wants to merge 5 commits intodevfrom
lepmik/links

Conversation

@lepmik
Copy link
Copy Markdown
Member

@lepmik lepmik commented May 10, 2019

  • Link classes live in links.py module
  • They are subclass of the abstract class Link
  • Functionality should match h5py

Should fix #1
Aims for compatibility with NWB NeurodataWithoutBorders/pynwb#629

@lepmik lepmik requested review from dragly and miladh May 10, 2019 15:38
@codecov
Copy link
Copy Markdown

codecov bot commented May 11, 2019

Codecov Report

❌ Patch coverage is 97.95918% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.71%. Comparing base (dd8f40f) to head (d9fbbdc).
⚠️ Report is 173 commits behind head on dev.

Files with missing lines Patch % Lines
tests/test_links.py 97.95% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #87      +/-   ##
==========================================
+ Coverage   95.57%   95.71%   +0.13%     
==========================================
  Files          11       12       +1     
  Lines        1604     1702      +98     
==========================================
+ Hits         1533     1629      +96     
- Misses         71       73       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lepmik lepmik marked this pull request as ready for review May 11, 2019 12:48
name_validation=None, plugins=None):
self._open_datasets = weakref.WeakValueDictionary({})
directory = pathlib.Path(directory) #.resolve()
directory = pathlib.Path(directory).absolute() #.resolve()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this necessary? Not that I mind, just good to know why it was added.

Copy link
Copy Markdown
Member

@dragly dragly left a comment

Choose a reason for hiding this comment

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

The fundamental parts look really good! I would just change some of the behavior :)

return self
return super(File, self).__getitem__(path)

def __setitem__(self, name, value):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this related to links or is it just something we have left out from before? Seems like this is something that has been missing on File regardless of links?


def _link(self, name, get_link=False):
link_meta = self._group(name).meta[exob.EXDIR_METANAME][exob.LINK_METANAME]
print(link_meta)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be removed :)

EXDIR_METANAME = "exdir"
TYPE_METANAME = "type"
VERSION_METANAME = "version"
LINK_METANAME = "link"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I prefer if the type is soft_link, external_link, etc. That reduces the level of conditional nesting - you can say if type == "external_link" instead of if type == "link" and link_type == "external". And then have the meta-groups be soft_link and external_link as well. It just reduces the confusion of which variables can go together. (No-one will think that they can just change the target from external to soft and still keep the file, for instance.

f = setup_teardown_file[3]
g = File(external_path, 'w')
f['ext'] = ExternalLink(external_path, '/missing')
with pytest.raises(KeyError):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To add to the comment above: This should not be a KeyError. It should actually return the object that the link is pointing to.

return len([a for a in self])

def get(self, key):
def get(self, name, get_link=False):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the getter should first try to see if it is an object or a link, instead of forcing the user to tell it to expect a link or not. This is also how h5py works.

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.

Add support for internal and external links

2 participants