Skip to content

Commit

Permalink
Resolves #64
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Eleff committed Aug 21, 2024
1 parent b3721bd commit c5eb457
Show file tree
Hide file tree
Showing 27 changed files with 848 additions and 49 deletions.
Binary file added .coverage
Binary file not shown.
70 changes: 70 additions & 0 deletions .github/workflows/coverage-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Coverage

on:
push:
branches: [ "v[0-9]+.[0-9]+.[0-9]+" ]

pull_request:
branches: [ "v[0-9]+.[0-9]+.[0-9]+" ]

permissions:
contents: write

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Create coverage report
run: |
if [ ! -d coverage ]; then mkdir coverage; fi
coverage run -m pytest tests/
coverage report -m --format=markdown --omit=tests/* > ./coverage/COVERAGE.md
- name: Create coverage badge
uses: tj-actions/coverage-badge-py@v2

- name: Move coverage reports
run: |
mv coverage.svg ./coverage
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: ./coverage/coverage.svg

- name: Commit & push coverage badge
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote add github https://github.com/thomaseleff/pytensils.git
git add coverage/coverage.svg
git add coverage/COVERAGE.md
git commit -m "Updated coverage"
git push github $BRANCH_NAME
45 changes: 45 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Unit-Tests

on:
push:
branches: [ "v[0-9]+.[0-9]+.[0-9]+" ]

pull_request:
branches: [ "v[0-9]+.[0-9]+.[0-9]+" ]

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -vvvsx tests/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ archive
data
testing.py
/project
/planning
/planning
tests/resources/app
4 changes: 2 additions & 2 deletions assemblit/_app/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(
```
"""
layer.run(script=script)
return layer.run(script=script).wait()


def build(
Expand Down Expand Up @@ -66,4 +66,4 @@ def build(
assemblit build demo
```
"""
layer.build(app_type=app_type)
return layer.build(app_type=app_type).wait()
11 changes: 5 additions & 6 deletions assemblit/_app/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import shutil
import subprocess
import copy
import textwrap
from typing import Union, Literal
from pytensils import utils
import assemblit
Expand Down Expand Up @@ -440,7 +439,7 @@ def build(
os.path.abspath(path),
'README.md'
),
content=textwrap.dedent(markdown)
content=markdown
)

# Unload the Python script
Expand All @@ -463,13 +462,13 @@ def build(
application = create_app(config=config)

# Run the web-application
subprocess.Popen(
return subprocess.Popen(
'streamlit run %s --server.port %s' % (
os.path.join(os.path.abspath(path), 'app.py'),
application.ASSEMBLIT_CLIENT_PORT
),
shell=True
).wait()
)


def run(
Expand All @@ -490,13 +489,13 @@ def run(
application = create_app(config=config)

# Run the web-application
subprocess.Popen(
return subprocess.Popen(
'streamlit run %s --server.port %s' % (
os.path.abspath(script),
application.ASSEMBLIT_CLIENT_PORT
),
shell=True
).wait()
)


# Define environment variable constructing functions
Expand Down
2 changes: 1 addition & 1 deletion assemblit/_orchestrator/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def start(
"""

# Start the orchestration server
layer.start(path=path)
return layer.start(path=path).wait()
2 changes: 1 addition & 1 deletion assemblit/_orchestrator/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def start(
server.start()

# Deploy the `prefect` server job
server.deploy(job_entrypoint=os.path.abspath(server.ASSEMBLIT_SERVER_JOB_ENTRYPOINT))
return server.deploy(job_entrypoint=os.path.abspath(server.ASSEMBLIT_SERVER_JOB_ENTRYPOINT))


def health_check(
Expand Down
6 changes: 4 additions & 2 deletions assemblit/_orchestrator/prefect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def configure(self) -> str:
def start(self):
""" Starts the `prefect` orchestration server.
"""
subprocess.Popen(
orchestrator = subprocess.Popen(
'prefect server start --host="%s" --port="%s"' % (
self.ASSEMBLIT_SERVER_HOST,
self.ASSEMBLIT_SERVER_PORT
Expand All @@ -234,6 +234,8 @@ def start(self):
while not self.health_check():
time.sleep(1)

return orchestrator

def deploy(
self,
job_entrypoint: str
Expand All @@ -249,7 +251,7 @@ def deploy(
return subprocess.Popen(
'"%s" "%s"' % (sys.executable, job_entrypoint),
shell=True
).wait()
)

def health_check(self) -> requests.Response | bool:
""" Checks the health of the `prefect` orchestration server.
Expand Down
14 changes: 8 additions & 6 deletions assemblit/blocks/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ def from_dict(dict_object: dict) -> Setting:
)

# Assert that the slider setting type has kwargs
if (
str(dict_object['type']).strip().lower() == 'slider'
and (
if str(dict_object['type']).strip().lower() == 'slider':

if 'kwargs' not in dict_object:
raise ValueError('Missing kwargs. Slider `Setting` objects require kwargs as a `dict`.')

if (
dict_object['kwargs'] is None
or dict_object['kwargs'] == ''
or not isinstance(dict_object['kwargs'], dict)
)
):
raise ValueError('Missing kwargs. Slider `Setting` objects require kwargs as a `dict`.')
):
raise ValueError('Missing kwargs. Slider `Setting` objects require kwargs as a `dict`.')

return Setting(**dict_object)

Expand Down
8 changes: 4 additions & 4 deletions assemblit/pages/data_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import streamlit as st
import pandas as pd
from assemblit import setup, blocks
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit._database import sessions, data
from assemblit.pages._components import _core, _data_uploader, _data_review

Expand Down Expand Up @@ -89,10 +89,10 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.headerless = headerless
self.content_info = content_info
self.content_info = content.clean_text(content_info)
self.data_dictionary = data_dictionary
self.data_example = data_example

Expand Down
11 changes: 7 additions & 4 deletions assemblit/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import streamlit as st
from assemblit import setup, _app, toolkit
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit._auth import vault
from assemblit.pages._components import _core

Expand Down Expand Up @@ -91,10 +91,13 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.content_file_path = content_file_path
self.content_info = content_info
if content_info:
self.content_info = content.clean_text(content_info)
else:
self.content_info = None
self.headerless = headerless

# Initialize database class variables
Expand Down
8 changes: 4 additions & 4 deletions assemblit/pages/run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import streamlit as st
from assemblit import setup, blocks
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit._database import sessions, data, analysis
from assemblit.pages._components import _core, _run_analysis

Expand Down Expand Up @@ -76,9 +76,9 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.content_info = content_info
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.content_info = content.clean_text(content_info)
self.headerless = headerless

# Assign database class variables to set the scope for run analysis
Expand Down
8 changes: 4 additions & 4 deletions assemblit/pages/run_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import streamlit as st
from assemblit import setup
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit._database import sessions, analysis
from assemblit.pages._components import _core, _run_listing

Expand Down Expand Up @@ -76,9 +76,9 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.content_info = content_info
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.content_info = content.clean_text(content_info)
self.headerless = headerless

# Assign database class variables to set the scope for run listing
Expand Down
6 changes: 3 additions & 3 deletions assemblit/pages/session_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import streamlit as st
from assemblit import setup, blocks
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit._database import users
from assemblit.pages._components import _core, _key_value, _selector

Expand Down Expand Up @@ -100,8 +100,8 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.headerless = headerless
self.clear_on_submit = clear_on_submit

Expand Down
8 changes: 4 additions & 4 deletions assemblit/pages/workflow_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import copy
import streamlit as st
from assemblit import setup, blocks
from assemblit.toolkit import _exceptions
from assemblit.toolkit import _exceptions, content
from assemblit.pages._components import _key_value, _core

_COMPATIBLE_APP_TYPES = ['aaas']
Expand Down Expand Up @@ -96,9 +96,9 @@ def __init__(
)

# Assign content class variables
self.header = header
self.tagline = tagline
self.content_info = content_info
self.header = content.clean_text(header)
self.tagline = content.clean_text(tagline)
self.content_info = content.clean_text(content_info)
self.headerless = headerless
self.clear_on_submit = clear_on_submit

Expand Down
Loading

0 comments on commit c5eb457

Please sign in to comment.