Skip to content

Commit

Permalink
Changes to the code that runs locally
Browse files Browse the repository at this point in the history
s3 path gives an error
  • Loading branch information
sugan89 committed Sep 3, 2024
1 parent 62804e1 commit f082f89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/pe2loaddata/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def headless(
os.makedirs(output_path)

# Strip spaces because XML parser is broken
channels = dict([(str(k).replace(" ", ""), v) for (k, v) in channels.items()])
if channels != '':
channels = dict([(str(k).replace(" ", ""), v) for (k, v) in channels.items()])


if "s3" in index_directory:
Expand Down Expand Up @@ -101,8 +102,8 @@ def headless(
return

else:
index_file = glob.glob(f"{index_directory}" + "/*.xml")

index_file = glob.glob(f"{index_directory}" + "/*.xml")[0]
#__import__("IPython").embed()
print(index_file)
index_file

Expand All @@ -115,7 +116,7 @@ def headless(
wells = handler.root.wells.wells

paths = {}

#print(paths)
if not illum_only:
if search_subdirectories:
if remote:
Expand All @@ -130,6 +131,7 @@ def headless(
path, filename = fullpath.rsplit("/", 1)
if filename.endswith(".tiff"):
paths[filename] = path
print(fullpath)
except KeyError:
print("Listing files in s3 directory failed.")
return
Expand All @@ -142,7 +144,7 @@ def headless(
else:
for filename in os.listdir(index_directory):
paths[filename] = index_directory

print(paths)
with open(output, "w") as fd:
writer = csv.writer(fd, lineterminator="\n")

Expand Down
18 changes: 13 additions & 5 deletions src/pe2loaddata/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def write_csv(writer, images, plates, wells, channels, channelid, metadata, path
else:
fields[field_id][channel] = image
except Exception as e:
print(e)
#print(image.channel_name)
print('error at image step')
#print(e)

for field in sorted(fields):
d = fields[field]
Expand All @@ -154,10 +156,12 @@ def write_csv(writer, images, plates, wells, channels, channelid, metadata, path
file_name = image.metadata["URL"]

row += [file_name, paths[file_name]]
print(channels)
except Exception as e:
logging.debug("Channel = {}; Field = {}; Plate = {}".format(channel, field, plate_name))

print(e)
#print(file_name)
#print('error at field step')
#print(e)

row = []

Expand Down Expand Up @@ -187,8 +191,11 @@ def write_csv(writer, images, plates, wells, channels, channelid, metadata, path
row += [file_name, paths[file_name]]
except Exception as e:
logging.debug("Channel = {}; Field = {}; Plate = {}".format(channel, field, plate_name))

print(e)
print(channelid.keys())
#print(paths[file_name])
#print(image.metadata["URL"])
#print('error at else step')
#print(e)

row = []

Expand All @@ -209,3 +216,4 @@ def write_csv(writer, images, plates, wells, channels, channelid, metadata, path

writer.writerow(row)

#__import__("IPython").embed()

0 comments on commit f082f89

Please sign in to comment.