Skip to content

Commit

Permalink
Merge pull request #1165 from uc-cdis/fix/handle-csv-ordering-with-us…
Browse files Browse the repository at this point in the history
…erinfo

PXP-11364 handle csv ordering with userinfo
  • Loading branch information
AlbertSnows authored Jul 23, 2024
2 parents 234638e + c87fc48 commit 329afeb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def _parse_csv(self, file_dict, sess, dbgap_config={}, encrypted=True):
"""
user_projects = dict()
user_info = dict()
user_info = defaultdict(dict)

# parse dbGaP sftp server information
dbgap_key = dbgap_config.get("decrypt_key", None)
Expand Down Expand Up @@ -542,6 +542,7 @@ def _parse_csv(self, file_dict, sess, dbgap_config={}, encrypted=True):
] # when converting the YAML from fence-config, python reads it as Python string literal. So "\" turns into "\\" which messes with the regex match
project_id_patterns += patterns

self.logger.info(f"Using these file paths: {file_dict.items()}")
for filepath, privileges in file_dict.items():
self.logger.info("Reading file {}".format(filepath))
if os.stat(filepath).st_size == 0:
Expand Down Expand Up @@ -657,9 +658,9 @@ def _parse_csv(self, file_dict, sess, dbgap_config={}, encrypted=True):
tags["pi"] = row["downloader for names"]

user_info[username] = {
"email": row.get("email") or "",
"email": row.get("email") or user_info[username].get('email') or "",
"display_name": display_name,
"phone_number": row.get("phone") or "",
"phone_number": row.get("phone") or user_info[username].get('phone_number') or "",
"tags": tags,
}

Expand Down Expand Up @@ -1570,6 +1571,8 @@ def _sync(self, sess):
local_csv_file_list = glob.glob(
os.path.join(self.sync_from_local_csv_dir, "*")
)
# Sort the list so the order of of files is consistent across platforms
local_csv_file_list.sort()

user_projects_csv, user_info_csv = self._merge_multiple_local_csv_files(
local_csv_file_list,
Expand Down

0 comments on commit 329afeb

Please sign in to comment.