Skip to content

Commit

Permalink
add to designid_status func option to include assignment_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
imedan committed Sep 4, 2024
1 parent d3f3488 commit 603a994
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion python/mugatu/designmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ def designid_status_valid(design_id, field_id, field_exposure):
return status


def find_designid_status(field_id, field_exposure):
def find_designid_status(field_id, field_exposure, assign_hash=None):
"""
Find the designid status based on a given field and field_exposure
Expand All @@ -1710,6 +1710,9 @@ def find_designid_status(field_id, field_exposure):
field_exposure: int
field_exposure for the design.
assign_hash: str
The assignment_hash for the design
Returns
-------
designid_status: int
Expand Down Expand Up @@ -1740,4 +1743,19 @@ def find_designid_status(field_id, field_exposure):
designid_status = designids[status][np.argmax(versions[status])]
else:
designid_status = -1

# if assignment_hash provided, check if already exists
if assign_hash is not None and designid_status == -1:
designs = targetdb.DesignToField.select()\
.join(targetdb.Design)\
.where(targetdb.Design.assignment_hash == assign_hash,
targetdb.DesignToField.field_exposure == field_exposure)
# get design_id for most recent version
if len(designs) > 0:
designids = np.zeros(len(designs), dtype=int)
versions = np.zeros(len(designs), dtype=int)
for i, d in enumerate(designs):
designids[i] = d.design_id
versions[i] = d.field.version.pk
designid_status = designids[np.argmax(versions)]
return designid_status

0 comments on commit 603a994

Please sign in to comment.