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

Elizabeth/try local install #10

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ This project is divided into three main parts: the Pylon camera interface, the N

You'll need to install some Python and Node packages to run these three components.

1. Create the `bloom-desktop` environment: `mamba create --name bloom-desktop`
1. Create the `bloom-desktop` environment with python 3.8 and nodejs: `mamba create --name bloom-desktop python=3.8 nodejs=18 pip -c conda-forge`
2. Activate the environment: `mamba activate bloom-desktop`
3. Install conda requirements: `mamba install python=3.8 nodejs nidaqmx`
3. Install pip requirements:
`pip install -r requirements.txt`
Comment on lines 13 to 14
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clarify the change in installation method

The updated instruction simplifies the setup process by focusing solely on pip requirements, which aligns with the PR objectives regarding nidaqmx installation issues. However, it might be beneficial to provide more context for this change.

Consider adding a brief explanation:

 3. Install pip requirements:
    `pip install -r requirements.txt`
+   Note: We now use pip to install all requirements, including `nidaqmx`, due to issues with the conda version.

This addition would help future contributors understand the reasoning behind the installation method change.

Committable suggestion was skipped due to low confidence.


Expand Down
26 changes: 18 additions & 8 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@

## Installation

1. Create `./.env` in this directory (see `.env.example`).
2. Edit `./.env` with an appropriate database file location.
3. Create `$HOME/.bloom/desktop-config.yaml` (see `desktop-config.yaml.example`).
4. Edit `$HOME/.bloom/desktop-config.yaml` with the correct database file location and other values.
5. Run `npm install`.
6. Run `npm run client:generate` to generate Typescript client for the new schema.
7. Run `npm run db:deploy` to create the database.
1. `mamba activate bloom-desktop`
2. Follow the instructions in (bloom)[https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads] to setup a local supabase instance to interact with, and add some test data.
Comment on lines +5 to +6
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix link formatting and grammar in Supabase setup instruction.

The new steps are helpful, but there are two issues to address:

  1. The link to the Bloom repository is formatted incorrectly. Use square brackets for the text and parentheses for the URL.
  2. The word "setup" should be "set up" when used as a verb.

Please apply the following changes:

-2. Follow the instructions in (bloom)[https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads] to setup a local supabase instance to interact with, and add some test data.
+2. Follow the instructions in [bloom](https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads) to set up a local Supabase instance to interact with, and add some test data.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
1. `mamba activate bloom-desktop`
2. Follow the instructions in (bloom)[https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads] to setup a local supabase instance to interact with, and add some test data.
1. `mamba activate bloom-desktop`
2. Follow the instructions in [bloom](https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads) to set up a local Supabase instance to interact with, and add some test data.
🧰 Tools
🪛 LanguageTool

[grammar] ~6-~6: The word “setup” is a noun. The verb is spelled with a white space.
Context: ...tm/bloom/-/tree/main?ref_type=heads] to setup a local supabase instance to interact w...

(NOUN_VERB_CONFUSION)

🪛 Markdownlint

6-6: (bloom)[https://gitlab.com/salk-tm/bloom/-/tree/main?ref_type=heads]
Reversed link syntax

(MD011, no-reversed-links)

3. Create `./.env` in this directory (see `.env.example`).
4. Edit `./.env` with an appropriate database file location.
5. Create `$HOME/.bloom/desktop-config.yaml` (see `desktop-config.yaml.example`).
- References test images located at `test\sample_scan`.
- Use the same environment variables as in https://gitlab.com/salk-tm/bloom/-/blob/main/web/env.dev to configure bloom-desktop to work with your local supabase instance.
6. Edit `$HOME/.bloom/desktop-config.yaml` with the correct database file location and other values.
7. Run `npm install`.
- Make sure you are in `app` directory.
- Build tools required for this step:
- https://visualstudio.microsoft.com/ C++ for Desktop Development on Windows
- XCode for Mac
- `build-essential` for Linux
- Use `npm cache clean` to cleanup
8. Run `npm run client:generate` to generate Typescript client for the new schema (`app\prisma\schema.prisma`)
9. Run `npm run db:deploy` to create the database and apply the migrations.

## Quickstart

Run `npm run start`.
Run `npm run start` from `app` directory.

## Modifying the database

Expand Down
7 changes: 6 additions & 1 deletion pylon/pylon_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
import sys
import time
import pathlib
import logging

import imageio.v2 as iio

sample_scan = '/Users/djbutler/dev/bloom-desktop-pilot/test/sample_scan'
logging.basicConfig(level=logging.INFO)

# Test images are in "test/sample_scan" directory from the root of the repo
sample_scan = pathlib.Path(__file__).parent.parent / "test" / "sample_scan"
logging.info(f"sample_scan: {sample_scan}")


async def save_image_async(executor, output_path, idx, array):
Expand Down
26 changes: 20 additions & 6 deletions pylon/pylon_stream_forever_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import time
import pathlib
import logging

import base64
from io import BytesIO
Expand All @@ -14,12 +15,18 @@

import imageio.v2 as iio

sample_scan = "/Users/djbutler/dev/bloom-desktop-pilot/test/sample_scan"
logging.basicConfig(level=logging.INFO)

# Test images are in "test/sample_scan" directory from the root of the repo
sample_scan = pathlib.Path(__file__).parent.parent / "test" / "sample_scan"
logging.info(f"sample_scan: {sample_scan}")



def stream_frames(camera_settings):
n = camera_settings["num_frames"]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unused variable 'n'.

The local variable 'n' is assigned but never used in the function. This was detected by the static analysis tool.

Consider removing the unused variable:

def stream_frames(camera_settings):
-    n = camera_settings["num_frames"]
    src_frames = glob.glob(os.path.join(sample_scan, "*.png"))

If the num_frames setting is intended to be used, please implement its functionality or remove it from the camera_settings if it's no longer needed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
n = camera_settings["num_frames"]
def stream_frames(camera_settings):
src_frames = glob.glob(os.path.join(sample_scan, "*.png"))
🧰 Tools
🪛 Ruff

28-28: Local variable n is assigned to but never used

Remove assignment to unused variable n

(F841)

src_frames = glob.glob(os.path.join(sample_scan, "*.png"))
logging.debug(f"Found {len(src_frames)} frames.")
src_frames.sort(key=lambda x: int(os.path.basename(x).split(".")[0]))
i = 0
while True:
Expand All @@ -29,6 +36,7 @@ def stream_frames(camera_settings):
# time the function call
start = time.time()
img = iio.imread(src_frame)
logging.debug(f"Read {src_frame}.")
end = time.time()
# print(f"iio.imread took {end - start} seconds", file=sys.stderr)
# time the function call
Expand All @@ -41,11 +49,17 @@ def stream_frames(camera_settings):


def img_to_base64(img):
buffer = BytesIO()
pil_img = Image.fromarray(img)
pil_img.save(buffer, format="PNG", compress_level=0)
# iio.imwrite(buffer, img, ".png")
base64_img = base64.b64encode(buffer.getvalue()).decode("utf-8")
if img is None or img.size == 0:
logging.error("Invalid image encountered!")
return ""

with BytesIO() as buffer:
with Image.fromarray(img) as pil_img:
logging.debug(f"{pil_img} opened.")
pil_img.save(buffer, format="PNG", compress_level=0)
logging.debug(f"{pil_img} saved to buffer.")
base64_img = base64.b64encode(buffer.getvalue()).decode("utf-8")
logging.debug(f"base64_img: {base64_img[:100]}")
return base64_img


Expand Down