Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4011a4b
add tailwind
ken-zlai Sep 24, 2024
f46c568
format code w/ prettier
ken-zlai Sep 24, 2024
6a05ff7
add shadcn
ken-zlai Sep 24, 2024
2a9aad1
add shadcn button
ken-zlai Sep 24, 2024
f96c4fe
use button on home page for simple counter
ken-zlai Sep 24, 2024
570ba5d
npm run format
ken-zlai Sep 24, 2024
2b2bddc
modify typescript rules to ignore specific errors in shadcn components
ken-zlai Sep 24, 2024
53e759e
configure tailwind typography
ken-zlai Sep 24, 2024
8dab5f7
Merge branch 'ken-websvc' into ken-frontend
ken-zlai Sep 25, 2024
71895c7
basic dark mode config
ken-zlai Sep 25, 2024
d0b55ea
ignore warnings from node_modules folder
ken-zlai Sep 25, 2024
1e11bc2
configure testing stuff
ken-zlai Sep 25, 2024
3205caa
readme
ken-zlai Sep 25, 2024
afb9aea
move tests
ken-zlai Sep 25, 2024
05bce39
dark mode should be applied in the app.html
ken-zlai Sep 25, 2024
1c31f4a
create a reusable echart component
ken-zlai Sep 26, 2024
8f5bd92
basic heatmap to start testing
ken-zlai Sep 26, 2024
201dc8e
install echarts
ken-zlai Sep 26, 2024
251a052
fix type issues
ken-zlai Sep 26, 2024
a77da82
add sheet component
ken-zlai Sep 26, 2024
6d3a1e9
use resizeobserver on my echart
ken-zlai Sep 27, 2024
7462ed4
refactor echart for clarity
ken-zlai Sep 27, 2024
b2270f6
use proper type
ken-zlai Sep 27, 2024
cf8c8e6
svelte 5 state
ken-zlai Sep 27, 2024
ea4ba7b
create SplitView.svelte
ken-zlai Sep 27, 2024
db32508
use SplitView to show heatmap/sidebar
ken-zlai Sep 27, 2024
f8060b1
Merge branch 'piyush--apis' into ken-frontend
ken-zlai Sep 30, 2024
fffd0ed
add table component
ken-zlai Sep 30, 2024
ea0cd3c
index to export table elements
ken-zlai Sep 30, 2024
fd3702b
add basic api
ken-zlai Sep 30, 2024
7eb1bea
type for model
ken-zlai Sep 30, 2024
00f3807
format code
ken-zlai Sep 30, 2024
dc76a03
add ModelsResponse
ken-zlai Sep 30, 2024
998956a
render a basic table with models data
ken-zlai Sep 30, 2024
7ab1d5d
change route structure
ken-zlai Sep 30, 2024
79268df
add preview of timeseries data
ken-zlai Sep 30, 2024
8e9327c
add avatar
ken-zlai Sep 30, 2024
1855d2e
zipline logo
ken-zlai Sep 30, 2024
3d76751
Wire up Play frontend + server in docker setup
piyush-zlai Sep 30, 2024
c3f728a
create a layout for the app w/ top and left bar
ken-zlai Sep 30, 2024
578ed5b
move model code to model route
ken-zlai Sep 30, 2024
a284edb
add loading indication on nav
ken-zlai Sep 30, 2024
114511f
Merge branch 'main' into ken-frontend
ken-zlai Sep 30, 2024
7e7d697
Fix based on coder rabbit suggestions
piyush-zlai Sep 30, 2024
557555b
Address feedback
piyush-zlai Oct 1, 2024
5691a3c
Merge remote-tracking branch 'origin/piyush/docker-play' into ken-fro…
ken-zlai Oct 1, 2024
34da3a4
configure frontend to build using nodejs
ken-zlai Oct 1, 2024
811cb65
create a custom build for docker to use that env file
ken-zlai Oct 1, 2024
6b27bd3
add a quick coming soon to the / route
ken-zlai Oct 1, 2024
115faa3
zipline logo routes to / route
ken-zlai Oct 1, 2024
9e63629
quick header for timeseries data
ken-zlai Oct 1, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ releases
# Frontend Vite
/frontend/vite.config.js.timestamp-*
/frontend/vite.config.ts.timestamp-*

# Frontend Test Results
/frontend/test-results
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ lazy val frontend = (project in file("frontend"))
}

println("Building frontend...")
val buildResult = Process("npm run build", file("frontend")).!
val buildResult = Process("npm run build:docker", file("frontend")).!

if (buildResult == 0) {
println("Copying frontend assets to /hub/public...")
Expand All @@ -211,6 +211,7 @@ lazy val frontend = (project in file("frontend"))
}
)

// todo remove stuff here
lazy val hub = (project in file("hub"))
.enablePlugins(PlayScala)
.settings(
Expand Down
31 changes: 22 additions & 9 deletions docker-init/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
# Use the first Dockerfile to set up the build environment
FROM base_image:latest AS build_env
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Specify a valid base image that includes SBT for the build stage

The placeholder base_image:latest needs to be replaced with an actual base image that includes SBT. Without SBT installed, the RUN sbt dist command on line 8 will fail. Consider using an official SBT image like hseeberger/scala-sbt or another appropriate base image that suits your build requirements.


# Copy your application source code
COPY . /app

# Build the frontend and play app
RUN sbt dist

# Start a new stage for the runtime image
FROM amazoncorretto:17

# Install python deps
COPY requirements.txt .
RUN yum install -y python3
COPY docker-init/requirements.txt .
RUN yum install -y python3 unzip
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clean up after yum install to reduce image size

After installing packages with yum, it's good practice to clean up cached data to minimize the image size. Adding cleanup commands in the same RUN instruction helps keep the image lean.

Apply the following changes:

 RUN yum install -y python3 unzip && \
+    yum clean all && \
+    rm -rf /var/cache/yum
📝 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
RUN yum install -y python3 unzip
RUN yum install -y python3 unzip && \
yum clean all && \
rm -rf /var/cache/yum

RUN pip3 install --upgrade pip; pip3 install -r requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize pip installations and reduce image size

Combining the pip commands and using the --no-cache-dir option prevents caching of installed packages, which helps reduce the image size.

Apply the following changes:

-RUN  pip3 install --upgrade pip; pip3 install -r requirements.txt
+RUN pip3 install --upgrade pip && \
+    pip3 install --no-cache-dir -r requirements.txt
📝 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
RUN pip3 install --upgrade pip; pip3 install -r requirements.txt
RUN pip3 install --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt


RUN mkdir -p /app
Comment on lines +15 to 18
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Combine RUN commands to reduce image layers

To optimize the Docker image and reduce the number of layers, consider combining consecutive RUN instructions into a single one.

Apply the following changes:

-RUN yum install -y python3 unzip
-RUN pip3 install --upgrade pip && \
-    pip3 install --no-cache-dir -r requirements.txt
-RUN mkdir -p /app
+RUN yum install -y python3 unzip && \
+    yum clean all && \
+    rm -rf /var/cache/yum && \
+    pip3 install --upgrade pip && \
+    pip3 install --no-cache-dir -r requirements.txt && \
+    mkdir -p /app
📝 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
RUN yum install -y python3 unzip
RUN pip3 install --upgrade pip; pip3 install -r requirements.txt
RUN mkdir -p /app
RUN yum install -y python3 unzip && \
yum clean all && \
rm -rf /var/cache/yum && \
pip3 install --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt && \
mkdir -p /app

COPY generate_anomalous_data.py /app/
COPY start.sh /start.sh
COPY docker-init/generate_anomalous_data.py /app/
COPY docker-init/start.sh /start.sh
RUN chmod +x /start.sh
WORKDIR /app
Comment on lines +20 to 22
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Set execute permissions when copying the start.sh script

You can set the execute permissions during the COPY instruction to streamline the Dockerfile and reduce the number of layers.

Apply the following changes:

-COPY docker-init/start.sh /start.sh
-RUN chmod +x /start.sh
+COPY --chmod=+x docker-init/start.sh /start.sh
📝 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
COPY docker-init/start.sh /start.sh
RUN chmod +x /start.sh
WORKDIR /app
COPY --chmod=+x docker-init/start.sh /start.sh
WORKDIR /app


ENV DYNAMO_ENDPOINT="http://localhost:8000"
ENV AWS_DEFAULT_REGION="fakeregion"
ENV AWS_ACCESS_KEY_ID="fakeaccesskey"
ENV AWS_SECRET_ACCESS_KEY="fakesecretkey"
# Copy frontend + play zipped dist and set up app directory structure
COPY --from=build_env /app/hub/target/universal/hub-0.1.0-SNAPSHOT.zip /app
RUN unzip hub-0.1.0-SNAPSHOT.zip -d /app/hub && \
cp -r hub/hub-0.1.0-SNAPSHOT/* hub/. && \
rm -rf hub/hub-0.1.0-SNAPSHOT hub-0.1.0-SNAPSHOT.zip

EXPOSE 9000

ENTRYPOINT ["/start.sh"]
ENTRYPOINT ["/start.sh"]
14 changes: 11 additions & 3 deletions docker-init/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

This directory holds code to setup docker containers for dynamoDB, a spark master, and a spark worker. It also creates a container which contains a parquet table with example data containing anomolies. To start, run:

```docker-compose up```
```
$ cd chronon
$ docker-compose -f docker-init/compose.yaml up --build
...
app-1 | [info] 2024-09-30 20:47:56,448 [main] INFO play.api.Play - Application started (Prod) (no global state)
app-1 | [info] 2024-09-30 20:47:56,665 [main] INFO play.core.server.PekkoHttpServer - Listening for HTTP on /[0:0:0:0:0:0:0:0]:9000
```

To access the parquet table, from another terminal run:
You can now pull up the web-server on http://localhost:9000

You can also access the parquet anomaly data table. To do so, from another terminal run:

```docker-compose exec app bash```

The parquet is available as data.parquet
The parquet is available in the /app/data directory.
45 changes: 40 additions & 5 deletions docker-init/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
name: "hub-monitoring-demo"
services:
dynamo:
command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
Expand All @@ -21,8 +21,8 @@ services:
- SPARK_SSL_ENABLED=no
- SPARK_USER=spark
ports:
- '8080:8080'
- '7077:7077'
- "8080:8080"
- "7077:7077"

spark-worker:
image: bitnami/spark:3.5.2
Expand All @@ -37,11 +37,46 @@ services:
- SPARK_SSL_ENABLED=no
- SPARK_USER=spark

base:
build:
context: ..
dockerfile: .github/image/Dockerfile
image: base_image:latest

app:
build: .
command: tail -F nothing
build:
context: ..
dockerfile: docker-init/Dockerfile
depends_on:
- base
environment:
- DYNAMO_ENDPOINT=http://dynamo:8000
- AWS_DEFAULT_REGION=fakeregion
- AWS_ACCESS_KEY_ID=fakeaccesskey
- AWS_SECRET_ACCESS_KEY=fakesecretkey
- PLAY_HTTP_SECRET_KEY=my_fake_chronon_monitoring_hub_http_secret_key # needs to be long to make Play happy
- JAVA_OPTS=-Xms1g -Xmx1g
ports:
- "9000:9000"
healthcheck:
interval: 1s
retries: 5
start_period: 60s
test: curl -sS --fail http://app:${APP_PORT:-9000}/api/v1/ping
timeout: 5s

frontend:
build:
context: ..
dockerfile: docker-init/frontend/Dockerfile
depends_on:
- base
- app
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
24 changes: 24 additions & 0 deletions docker-init/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM base_image:latest AS build_env
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider using a specific version tag for the base image.

Using latest tag can lead to inconsistent builds as the base image may change over time. It's recommended to use a specific version tag for reproducibility.

Consider changing the first line to:

-FROM base_image:latest AS build_env
+FROM base_image:<specific-version> AS build_env

Replace <specific-version> with the appropriate version number.

Committable suggestion was skipped due to low confidence.


# Copy the entire project directory into the container
COPY . /app
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize the COPY command to include only necessary files.

Copying the entire project directory might include unnecessary files, increasing the image size and build time.

Consider using a .dockerignore file to exclude unnecessary files and directories. Then, you can keep the COPY command as is:

COPY . /app

Alternatively, you can explicitly copy only the necessary files and directories:

-COPY . /app
+COPY package.json package-lock.json /app/
+COPY src/ /app/src/
+COPY public/ /app/public/

Adjust the paths according to your project structure.

Committable suggestion was skipped due to low confidence.


# Install Node.js and npm
RUN apk add --update nodejs npm

# Build the frontend using SBT
RUN sbt "project frontend" buildFrontend

FROM node:18-alpine

# Copy the built frontend from the previous stage to the new container
COPY --from=build_env app/frontend /app/frontend

# Set the working directory for subsequent commands
WORKDIR /app/frontend

# Expose port 3000 for the SvelteKit app
EXPOSE 3000

# Specify the command to run when the container starts
CMD ["node", "build/index.js"]
3 changes: 2 additions & 1 deletion docker-init/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ if ! python3 generate_anomalous_data.py; then
echo "Error: Failed to generate anomalous data" >&2
exit 1
fi
exec "$@"

exec "./hub/bin/hub"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider the implications of removing exec "$@".

The removal of exec "$@" means this script no longer accepts and executes arbitrary commands passed as arguments. This reduces its flexibility and may break existing workflows that relied on this behavior.

If maintaining the ability to execute arbitrary commands is important, consider one of these alternatives:

  1. Keep both behaviors:
    if [[ $# -eq 0 ]]; then
      exec "${HUB_BINARY_PATH:-./hub/bin/hub}"
    else
      exec "$@"
    fi
  2. Pass arguments to the hub binary:
    exec "${HUB_BINARY_PATH:-./hub/bin/hub}" "$@"

Please clarify if this change in behavior is intentional and aligns with the project's requirements.

133 changes: 115 additions & 18 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,135 @@
# create-svelte
# Chronon Frontend

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
The frontend for Chronon.

## Creating a project
## Getting Started

If you're seeing this, you've probably already done this step. Congrats!
### Prerequisites

- [Node.js](https://nodejs.org/en/) (LTS version recommended)
- npm (comes with Node.js)

### Installation

1. Clone the repository:

```bash
git clone https://github.com/zipline-ai/chronon.git
cd chronon
```

2. Navigate to the frontend directory:

```bash
cd frontend
```

3. Install dependencies:
```bash
npm install
```

### Development

To start the development server:

```bash
# create a new project in the current directory
npm create svelte@latest
npm run dev
```

This will start a local server. The app will automatically reload if you make changes to the code.

# create a new project in my-app
npm create svelte@latest my-app
### Build

To create an optimized production build:

```bash
npm run build
```

## Developing
This will create an optimized version of your project in the `build` directory.

### Preview

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
To preview the production build locally:

```bash
npm run dev
npm run preview
```

# or start the server and open the app in a new browser tab
npm run dev -- --open
### Running Tests

#### All Tests

To run both unit and integration tests together:

```bash
npm run test
```

## Building
#### Unit Tests

To create a production version of your app:
To run unit tests using Vitest:

```bash
npm run build
npm run test:unit
```

To run unit tests once:

```bash
npm run test:unit:once
```

#### Integration Tests

To run integration tests using Playwright:

```bash
npm run test:integration
```

To run integration tests once:

```bash
npm run test:integration:once
```

For the Playwright UI to explore test results:

```bash
npm run test:integration:ui
```

### Linting and Formatting

To check code formatting and linting issues:

```bash
npm run lint
```

To format the codebase:

```bash
npm run format
```

### Type Checking

To check the TypeScript types:

```bash
npm run check
```

To continuously check types while developing:

```bash
npm run check:watch
```

You can preview the production build with `npm run preview`.
## Best Practices

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
1. **Code Style**: This project uses Prettier and ESLint for code formatting and linting. Please run `npm run lint` and `npm run format` before committing changes.
2. **Testing**: Ensure all changes are covered with unit and integration tests. Use Vitest for unit tests and Playwright for integration tests.
Comment on lines +132 to +135
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider expanding the Best Practices section.

The current Best Practices section provides a good starting point, but it could be enhanced to provide more comprehensive guidance for contributors.

Consider the following improvements:

  1. Add more specific guidelines, such as:

    • Naming conventions
    • Component structure
    • State management practices
    • Performance considerations
  2. Include a link to a more comprehensive style guide or contribution guidelines document.

  3. Mention any specific coding patterns or architectural decisions that are important for the project.

  4. Add a note about documentation expectations for new features or significant changes.

Example expansion:

## Best Practices

1. **Code Style**: This project uses Prettier and ESLint for code formatting and linting. Please run `npm run lint` and `npm run format` before committing changes.
2. **Testing**: Ensure all changes are covered with unit and integration tests. Use Vitest for unit tests and Playwright for integration tests.
3. **Naming Conventions**: Use PascalCase for component names, camelCase for variables and functions, and UPPER_CASE for constants.
4. **Component Structure**: Follow the Single Responsibility Principle. Keep components small and focused on a single task.
5. **State Management**: Use React hooks for local state and [preferred state management solution] for global state.
6. **Performance**: Optimize renders by using React.memo, useMemo, and useCallback where appropriate.
7. **Documentation**: Update relevant documentation when adding new features or making significant changes.

For more detailed guidelines, please refer to our [Contribution Guidelines](link-to-guidelines).

14 changes: 14 additions & 0 deletions frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "new-york",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app.css",
"baseColor": "neutral"
},
Comment on lines +4 to +8
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Missing Tailwind Configuration Files

The Tailwind configuration is referencing tailwind.config.js and src/app.css, but neither of these files exist in the repository. Please ensure these files are added or update the references accordingly.

🔗 Analysis chain

LGTM! Verify the existence of specified Tailwind files.

The Tailwind configuration looks good. The base color is set to "neutral", which is a valid Tailwind color.

Please run the following script to verify the existence of the specified Tailwind files:


Please run the following corrected script to verify the existence of the specified Tailwind files:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of Tailwind configuration files

# Test: Check if tailwind.config.js exists
if [ -f "tailwind.config.js" ]; then
    echo "tailwind.config.js exists"
else
    echo "tailwind.config.js does not exist"
fi

# Test: Check if src/app.css exists
if [ -f "src/app.css" ]; then
    echo "src/app.css exists"
else
    echo "src/app.css does not exist"
fi

Length of output: 431


Script:

# 
#!/bin/bash
# Description: Verify the existence of Tailwind configuration files

# Test: Check if tailwind.config.js exists
if [ -f "tailwind.config.js" ]; then
    echo "tailwind.config.js exists"
else
    echo "tailwind.config.js does not exist"
fi

# Test: Check if src/app.css exists
if [ -f "src/app.css" ]; then
    echo "src/app.css exists"
else
    echo "src/app.css does not exist"
fi

Length of output: 196

"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
},
"typescript": true
}
Comment on lines +1 to +14
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider additional configurations for enhanced setup.

The overall structure of the configuration file is good and covers the basic setup for a SvelteKit project with shadcn UI and Tailwind CSS. However, you might want to consider adding some additional configurations to enhance your setup:

  1. Add a outDir property to specify the output directory for the built files.
  2. Include a componentPath to define a custom path for shadcn components if needed.
  3. Consider adding a themes array if you plan to support multiple themes.

Here's an example of how these additions might look:

{
  // ... existing configurations ...
  "outDir": "src/lib/components/ui",
  "componentPath": "src/lib/components/ui",
  "themes": ["light", "dark"]
}

These additions can provide more flexibility and control over your project structure and theming.

9 changes: 9 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export default [
parserOptions: {
parser: ts.parser
}
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^\\$\\$(Props|Events|Slots|Generic)$'
}
]
}
},
{
Expand Down
Loading