Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixups for klone download #62

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/fibad/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@
return

# Create thread objects for each of our worker threads
num_threads = config.get("concurrent_connections", 2)
if num_threads > 5:
raise RuntimeError("This client only opens 5 connections or fewer.")
num_threads = config.get("concurrent_connections", 10)

Check warning on line 74 in src/fibad/download.py

View check run for this annotation

Codecov / codecov/patch

src/fibad/download.py#L74

Added line #L74 was not covered by tests

if num_threads > 10:
RuntimeError("More than 10 concurrent connections to HSC is disallowed on a per-user basis")

Check warning on line 77 in src/fibad/download.py

View check run for this annotation

Codecov / codecov/patch

src/fibad/download.py#L76-L77

Added lines #L76 - L77 were not covered by tests

# If we are using more than one connection, cut the list of rectangles into
# batches, one batch for each thread.
Expand Down Expand Up @@ -413,6 +414,9 @@
filter=config["filter"],
rerun=config["rerun"],
type=config["type"],
image=config.get("image"),
mask=config.get("mask"),
variance=config.get("variance"),
)

@staticmethod
Expand Down Expand Up @@ -461,7 +465,10 @@
for index, location in enumerate(locations):
args = {field: location[field] for field in fields}
args["lineno"] = index + offset

# tracts are ints in the fits files and dC.rect constructor wants them as str
args["tract"] = str(args["tract"])

# Sets the file name on the rect to be the object_id, also includes other rect fields
# which are interpolated at save time, and are native fields of dc.Rect.
args["name"] = str(
Expand All @@ -471,9 +478,9 @@
rects.append(rect)

# We sort rects here so they end up tract,ra,dec ordered across all requests made in all threads
# Threads do their own sorting prior to each chunked request in downloadCutout.py; however
# Threads do their own sorting prior to all chunked request in downloadCutout.py; however
# sorting at this stage will allow a greater number of rects that are co-located in the sky
# to end up in the same thread and same chunk.
# to end up in the same thread and therefore be sorted into the same request.
rects.sort()

return rects
4 changes: 2 additions & 2 deletions src/fibad/downloadCutout/downloadCutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ class Rect:

rerun: str = default_rerun
type: str = default_type
filter: Union[str, list[str]] = ALLFILTERS
tract: int = ANYTRACT
filter: Union[str, list[str]] = ALLFILTERS
ra: float = math.nan
dec: float = math.nan
sw: float = math.nan
Expand All @@ -344,8 +344,8 @@ class Rect:
def create(
rerun: Union[str, None] = None,
type: Union[str, None] = None,
filter: Union[Union[str, list[str]], None] = None,
tract: Union[str, int, None] = None,
filter: Union[Union[str, list[str]], None] = None,
ra: Union[str, float, None] = None,
dec: Union[str, float, None] = None,
sw: Union[str, float, None] = None,
Expand Down
2 changes: 1 addition & 1 deletion src/fibad/fibad_default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ retries = 3
# `timepout` How long should we wait to get a full HTTP response from the server. Default 3600s (1hr)
timeout = 3600
# `chunksize` How many sky location rectangles should we request in a single request. Default is 990
chunksize = 990
chunk_size = 990

[model]
name = "ExampleAutoencoder"
Expand Down