Skip to content

Commit

Permalink
Merge pull request #7 from preqldata/model-dev-devex
Browse files Browse the repository at this point in the history
model dev devex
  • Loading branch information
greenmtnboy authored Oct 15, 2023
2 parents 7b169f3 + 0ee3e66 commit ec838b4
Show file tree
Hide file tree
Showing 39 changed files with 549 additions and 280 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/frontend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,28 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install python dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Install Node dependencies
working-directory: ./frontend
run: npm install
# - name: Run tests
# working-directory: ./frontend
# run: npm test
# timeout-minutes: 5
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build the electron package and webservice
working-directory: ./frontend
run: npm run build
- name: Run tests
working-directory: ./frontend
run: npm test
env:
DEBUG: pw:webserver
timeout-minutes: 6
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ release
*.sw?
*.pyc
.ruff_cache
.mypy_cache

# python
*.pyc
Expand Down
19 changes: 6 additions & 13 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from copy import deepcopy
from datetime import datetime
from typing import Optional, Dict, List, Tuple

from dataclasses import dataclass
import uvicorn
from uvicorn.config import LOGGING_CONFIG

Expand Down Expand Up @@ -47,8 +47,6 @@

app = FastAPI()

from dataclasses import dataclass


def load_pyinstaller_trilogy_files() -> None:
# dynamic imports used by trilogy_public_models
Expand Down Expand Up @@ -127,10 +125,7 @@ def generate_default_bigquery() -> Executor:
return executor


CONNECTIONS: Dict[str, Executor] = {
# "duckdb_demo": generate_default_duckdb(),
# "bigquery_demo": generate_default_bigquery()
}
CONNECTIONS: Dict[str, Executor] = {}

## BEGIN REQUESTS

Expand Down Expand Up @@ -208,7 +203,7 @@ def parse_env_from_full_model(input: ModelInSchema) -> Environment:
env = Environment()
for source in input.sources:
if source.alias:
env.parse(source.contents, namespace = source.alias)
env.parse(source.contents, namespace=source.alias)
else:
env.parse(source.contents)
return env
Expand Down Expand Up @@ -262,7 +257,7 @@ async def update_connection(connection: ConnectionInSchema):


@router.post("/connection")
async def create_connection(connection: ConnectionInSchema):
def create_connection(connection: ConnectionInSchema):
if connection.full_model is not None:
try:
environment = parse_env_from_full_model(connection.full_model)
Expand Down Expand Up @@ -324,7 +319,7 @@ async def create_connection(connection: ConnectionInSchema):


@router.post("/raw_query")
async def run_raw_query(query: QueryInSchema):
def run_raw_query(query: QueryInSchema):
start = datetime.now()
# we need to use a deepcopy here to avoid mutation the model default
executor = CONNECTIONS.get(query.connection)
Expand Down Expand Up @@ -369,7 +364,7 @@ async def run_raw_query(query: QueryInSchema):


@router.post("/query")
async def run_query(query: QueryInSchema):
def run_query(query: QueryInSchema):
start = datetime.now()
# we need to use a deepcopy here to avoid mutation the model default
executor = CONNECTIONS.get(query.connection)
Expand Down Expand Up @@ -491,8 +486,6 @@ async def http_exception_handler(request, exc: HTTPException):

app.include_router(router)

PORT = 5678


def run():
LOGGING_CONFIG["disable_existing_loggers"] = True
Expand Down
Empty file added backend/stress_test.py
Empty file.
8 changes: 1 addition & 7 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import sys
from os.path import dirname

sys.path.insert(0, dirname(dirname(__file__)))


import pytest
from fastapi.testclient import TestClient
from main import app
from ..main import app


@pytest.fixture
Expand Down
48 changes: 47 additions & 1 deletion backend/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi.testclient import TestClient
from main import ConnectionInSchema
from ..main import ConnectionInSchema
from typing import List, Mapping
from trilogy_public_models import models as public_models

Expand Down Expand Up @@ -34,3 +34,49 @@ def test_read_models(test_client: TestClient):

response = test_client.post("/connection", data=parsed.json()) # type: ignore
assert response.status_code == 200


# def test_async_functions(test_client: TestClient):
# response = test_client.post("/long_sleep", json={"sleep": 1})
# assert response.status_code == 200
# assert response.json().get("slept") == 1

# ## start async test
# response = test_client.post("/async_long_sleep", json={"sleep": 5})
# assert response.status_code == 200

# guid1 = response.json().get("guid")
# assert guid1 is not None

# response = test_client.post("/async_long_sleep", json={"sleep": 5})
# assert response.status_code == 200
# guid2 = response.json().get("guid")
# assert guid2 is not None

# datetime1 = datetime.now()

# found:set[str] = set()
# attempts = 0
# max_attempts = 5
# from time import sleep

# while len(found) < 2:
# attempts += 1
# for guid in (guid1, guid2):
# if guid in found:
# continue
# response = test_client.get(f"/background_tasks/{guid}")
# print(response)
# if response.status_code == 200:
# found.add(guid)
# assert response.json().get("slept") == 5
# break
# elif response.status_code == 102:
# pass
# else:
# raise ValueError(response)
# sleep(1)
# if attempts > max_attempts:
# raise ValueError(f"Too many attempts, last response {response}")
# # basic check that they ran async and not 5+5 seconds
# assert (datetime.now() - datetime1).seconds < 7
83 changes: 0 additions & 83 deletions backend/trilogy-studio-engine-debug.spec

This file was deleted.

Binary file added frontend/build/icons/1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/build/icons/icon.icns
Binary file not shown.
Binary file added frontend/build/icons/icon.ico
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ec838b4

Please sign in to comment.