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

Bulk Scan Updates #94

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Bulk Scan Updates #94

wants to merge 25 commits into from

Conversation

raginirai553
Copy link

No description provided.

@cassidysymons
Copy link
Collaborator

@ragini7913 It looks like bulk_scan.html is missing, can you please upload that and address the lint errors?

microsetta_admin/server.py Outdated Show resolved Hide resolved
Comment on lines 790 to 795
code = [random.choice(hex) for i in range(6)]
color_code = ['#' + ''.join(code)]
while color_code[0] in dict:
code = [random.choice(hex) for i in range(6)]
color_code = ['#' + ''.join(code)]
dict[obj["values"][val]] = color_code[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues here:

  1. This code is essentially repeated twice below. Please decompose it into a function that only handles the task of generating a dictionary of colors.
  2. The code can produce colors that are very similar, which somewhat defeats the purpose of color-coding. Can you consider alternatives that would do a better job of ensuring visual clarity?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a function to generate random color code. The logic to generate color codes is adjusted so that produced colors are not very similar. The code is further simplified

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still generating very similar colors, see below.

bulkscan_20230330

microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/templates/bulk_scan.html Outdated Show resolved Hide resolved
while color_code in dict:
color_code = _get_color_code()
dict[obj["values"][val]] = color_code

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the function return an error if it's called with an invalid criteria?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the function is called with an invalid criteria, it will return an empty dictionary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's nothing checking that between the function and the UI. Should there be a check and explicit exception if the result is an empty dictionary, rather than letting the UI silently fail?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of invalid criteria, visualization must show all samples to "None" legend for provided criteria. I have updated code to return the legend dictionary to at least return "None" as value for every sorting criteria.

color_code = _get_color_code()

if color_code is not None:
while color_code in dict.values():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this has the potential to go into an infinite loop if the supply of defined colors is exhausted. Can that be handled more gracefully?

while color_code in dict:
color_code = _get_color_code()
dict[obj["values"][val]] = color_code

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's nothing checking that between the function and the UI. Should there be a check and explicit exception if the result is an empty dictionary, rather than letting the UI silently fail?

microsetta_admin/templates/bulk_scan.html Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
@cassidysymons
Copy link
Collaborator

cassidysymons commented Apr 27, 2023

Hi @raginirai553 please see the below comments/issues:

  1. When I upload a file and choose Sort by Project, I get the following exception:
File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "microsetta_admin/server.py", line 994, in bulk_scan
    return _visualize_scans()
  File "microsetta_admin/server.py", line 897, in _visualize_scans
    table=_compose_table(legends, criteria),
  File "microsetta_admin/server.py", line 864, in _compose_table
    current_cols.append([rec[5], legends[val], proj, status, src])
KeyError: 'THDMI - Spain (Main)'
  1. I'm seeing the following in the logs, so I think you'll need to find a more efficient way to pass data around than using the session scope. It's safe to use session for a few specific options, but not large amounts of data:
/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/werkzeug/wrappers/base_response.py:468: UserWarning: The "b'session-microsetta-admin'" cookie is too large: the value was 5326 bytes but the header required 43 extra bytes. The final size was 5369 bytes but the limit is 4093 bytes. Browsers may silently ignore cookies larger than this.
  1. It would be good to add the Sort By dropdown to the upload screen so that there's not an extra step when first viewing a file.

microsetta_admin/server.py Outdated Show resolved Hide resolved
microsetta_admin/server.py Outdated Show resolved Hide resolved
@@ -964,11 +966,13 @@ def _post_bulk_scan():
obj = {}
obj["rack_id"] = rec[6]
if math.isnan(rec[3]):
obj['location_col'] = 'None'
error_msg = "Error: Empty column in row number" + rowCnt
break
else:
obj["location_col"] = str(int(rec[3]))
if math.isnan(rec[4]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isnan check needs to be removed, rec[4] will never be a number. Also, the error message strategy as written doesn't work - when it hits the isnan block, it throws an internal server error, meaning the user will never see the error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved the issued! As per the revised flow, samples without row or column numbers are ignored during bulk scan. Further, appropriate errors are displayed for such samples.

Screen Shot 2023-05-12 at 9 34 21 AM

@cassidysymons
Copy link
Collaborator

@raginirai553 There are a couple of significant issues with the Bulk Scan function that I'm experiencing in testing:

  1. When I sort by Sample Project, I receive the following exception:
[2023-05-16 08:49:59,572] ERROR in app: Exception on /scan-bulk [POST]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-admin/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "microsetta_admin/server.py", line 1024, in bulk_scan
    return _visualize_scans()
  File "microsetta_admin/server.py", line 905, in _visualize_scans
    table=_compose_table(legends, criteria),
  File "microsetta_admin/server.py", line 872, in _compose_table
    curr_cols.append([code, legends[val], proj, status, src])
KeyError: 'PROJECT NAME REDACTED - XXXXX (XXXXX)'
  1. When I sort by Sample Status or Sample Type, the first sample in the upload file renders 96 times in a single row:
    bulk_scan_20230516

Are you experiencing either of these issues in your local development environment?

microsetta_admin/server.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants