Skip to content

Commit

Permalink
Slightly more generalized version
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Sep 24, 2024
1 parent ea1403e commit b91a4a5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions one/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,16 +1827,13 @@ def list_aggregates(self, relation: str, identifier: str = None,
.reset_index(level=0)
.drop('eid', axis=1)
.rename_axis(index={'id': 'did'}))
# Since rel_path for public FI file records starts with public/aggregates instead of just
# aggregates as is the case for internal FI file records, as well as public and internal
# AWS file records, we need to make sure to use the file path part after 'aggregates'
# and not simply the second part, as relation.
# Since rel_path for public FI file records starts with 'public/aggregates' instead of just
# 'aggregates', we should discard the file path parts before 'aggregates' (if present)
records['rel_path'] = records['rel_path'].str.replace(
r'^[\w\/]+(?=aggregates\/)', '', n=1, regex=True)
# The relation is the first part after 'aggregates', i.e. the second part
records['relation'] = records['rel_path'].map(
lambda x: x.split('aggregates')[-1].split('/')[1].lower()
)
records['rel_path'] = records['rel_path'].map(
lambda x: '/'.join(x.split('/')[1:]) if 'public' in x else x
)
lambda x: x.split('aggregates')[-1].split('/')[1].lower())
records = records[records['relation'] == relation.lower()]

def path2id(p) -> str:
Expand Down

0 comments on commit b91a4a5

Please sign in to comment.