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

Feature/nav 150 extract python viewer package #14

Merged
merged 45 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a1e0f95
ORG: NAV-150 - Setup IDEA
munterfi Aug 21, 2024
dc82dbe
ORG: NAV-150 - Copy vscode setup
munterfi Aug 21, 2024
a1a6077
ORG: NAV-150 - Setup poetry
munterfi Aug 21, 2024
81492af
DOC: NAV-150 - Update README
munterfi Aug 21, 2024
0f17341
REFACTOR: NAV-150 - Copy viewer code
munterfi Aug 21, 2024
a273a79
TEST: NAV-150 - Add test folder
munterfi Aug 21, 2024
7f3cbcc
ORG: NAV-150 - Remove client
munterfi Aug 21, 2024
70e44ee
ORG: NAV-150 - Remove old viewer
munterfi Aug 21, 2024
527f95c
ORG: NAV-150 - Remove flake8 configuration, since it is not set as de…
munterfi Aug 21, 2024
8003db0
ORG: NAV-150 - Enable dependabot
munterfi Aug 21, 2024
5ba84b1
ORG: NAV-150 - Add poetry CI and Publish actions
munterfi Aug 21, 2024
01f7215
ORG: NAV-150 - Add public-transit-client from PYPI
munterfi Aug 21, 2024
734887f
ORG: NAV-150 - Build info
munterfi Aug 21, 2024
d57f13a
ORG: NAV-150 - Add deploy script
munterfi Aug 21, 2024
55ea805
ORG: NAV-150 - Add dockerfile for building docker image
munterfi Aug 21, 2024
913df6f
ORG: NAV-150 - Add Docker CI and Publish action
munterfi Aug 21, 2024
03f4cb4
ORG: NAV-150 - Update version of client
munterfi Aug 22, 2024
c3a8189
DOC: NAV-150 - Update readme
munterfi Aug 22, 2024
291c1e0
ENH: NAV-150 - Get app up and running again
munterfi Aug 22, 2024
8b66c49
FIX: NAV-150 - Remove unit test marker from pytest in github action
munterfi Aug 22, 2024
d30a055
TEST: NAV-150 - Add test which starts the app
munterfi Aug 22, 2024
9a73738
REFACTOR: NAV-150 - Use pathlib instead of os.
clukas1 Aug 22, 2024
d6fc06d
ORG: NAV-150 - Upgrade to service interface v0.5.0
munterfi Aug 23, 2024
378c8e8
ENH: NAV-150 - Enable service feature of v0.5.0
munterfi Aug 23, 2024
81f2420
ENH: NAV-150 - Check for all router features if query option is confi…
clukas1 Aug 23, 2024
25b5218
ENH: NAV-150 - Add schedule validity logic to date picker.
clukas1 Aug 23, 2024
42a21fb
STYLE: NAV-150 - Remove unused import.
clukas1 Aug 23, 2024
b3e9a2b
ORG: NAV-150 - Update client version to included type hinted version …
clukas1 Aug 23, 2024
5b73177
ORG: NAV-150 - Add google docstring requirement.
clukas1 Aug 23, 2024
3bfb644
STYLE: NAV-150 - Remove some mypy type issues.
clukas1 Aug 23, 2024
0502566
FIX: NAV-150 - Fix incorrect keyword arguments.
clukas1 Aug 23, 2024
b21ab43
ORG: NAV-150 - Update poetry.lock file.
clukas1 Aug 23, 2024
cb42561
ORG: NAV-150 - Add py.typed file.
clukas1 Aug 23, 2024
c84c589
ORG: NAV-150 - Update version to 0.5.0
clukas1 Aug 23, 2024
832a421
STYLE: NAV-150 - Some pylint fixes.
clukas1 Aug 23, 2024
822015d
ORG: NAV-150 - Remove TODOs since not possible
munterfi Aug 26, 2024
57c37b3
STYLE: NAV-150 - Format project and organize imports
munterfi Aug 26, 2024
e08490d
ORG: NAV-150 - Update poetry lock
munterfi Aug 26, 2024
421d431
DOC: NAV-150 - Update README.md
munterfi Aug 26, 2024
b79fe3e
FIX: NAV-150 - Show marker points of isolines correctly depending on …
munterfi Aug 27, 2024
3563059
FIX: NAV-150 - Wait for static logo to load before starting app
munterfi Aug 27, 2024
f8526e2
REFACTOR: NAV-150 - Move utils to utils package
munterfi Aug 27, 2024
a3cb9d1
ENH: NAV-150 - Rename main to connections
munterfi Aug 27, 2024
27ba8a1
FIX: NAV-150 - Remove sleep for logo loading, since it does not work …
munterfi Aug 27, 2024
ba52896
ENH: NAV-150 - Add page favicon.ico
munterfi Aug 27, 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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build image
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
IMAGE_TAG=ghcr.io/${{ github.repository }}:${COMMIT_HASH}
docker build . --file Dockerfile --tag $IMAGE_TAG
36 changes: 36 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker publish

on:
release:
types: [ created ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for image tag
id: meta
uses: docker/metadata-action@v4
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
48 changes: 48 additions & 0 deletions .github/workflows/poetry-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Poetry CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [ 3.12 ]

steps:
- uses: actions/checkout@v3

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

- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH

- name: Set up cache
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/pypoetry
key: poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction --no-root

- name: Run unit tests
run: poetry run pytest

- name: Run mypy
run: poetry run mypy .
37 changes: 37 additions & 0 deletions .github/workflows/poetry-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Poetry Publish

on:
release:
types: [ created ]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction --no-root

- name: Build the package
run: |
poetry build

- name: Publish to PyPI
env:
TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --username __token__ --password $TOKEN --no-interaction
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/public-transit-viewer.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions naviqore_client/.vscode/settings.json → .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"[python]": {
"editor.rulers": [88],
"editor.rulers": [
88
],
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"python.analysis.autoFormatStrings": true,
"python.analysis.typeCheckingMode": "strict",
"editor.defaultFormatter": "ms-python.black-formatter",
"black-formatter.args": ["--line-length", "88"],
"python.testing.pytestArgs": ["tests"],
"black-formatter.args": [
"--line-length",
"88"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Stage 1: Builder Stage
FROM python:3.12-slim AS builder

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir poetry \
&& poetry build -f wheel

# Stage 2: Production Stage
FROM python:3.12-slim

WORKDIR /app

COPY --from=builder /app/dist/*.whl ./
RUN pip install --no-cache-dir *.whl \
&& rm *.whl

EXPOSE 8501

RUN useradd --create-home appuser
USER appuser

CMD ["ptv-deploy"]
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# public-transit-viewer
A public transit viewer streamlit app
# Public Transit Viewer

Viewer to interact with the [Public Transit Service](https://github.com/naviqore/public-transit-service).

The streamlit based Python app allows users to query connections between two stops or generate isolines from a specific
stop. The application supports the query parameters of the service to search specific connections or isoline.

## Installation

Get the current release from pypi and start the viewer:

```sh
pip install public-transit-viewer

export NAVIQORE_SERVICE_URL=<SERVER:PORT>
ptv-deploy
```

Or run the viewer inside a Docker container:

```sh
docker run -p 8501:8501 -e NAVIQORE_SERVICE_URL=<SERVER:PORT> ghcr.io/naviqore/public-transit-client:latest
```

Access the viewer on `http://localhost:8501`.

## Development

### Configuration

Create a `.env` file in the root directory. And add a line telling the application to which service host it should
connect. In Local Development this is typically a Java Spring service running on `http://localhost:8080`.

The required line in the `.env` file will then be: `NAVIQORE_SERVICE_URL=http://localhost:8080`

**Note**: you can also specify the `NAVIQORE_SERVICE_URL` in your operating system environment.

### Starting the App

To start the app in development mode run following command from the root directory:

```sh
poetry run streamlit run public_transit_viewer/connections.py
```

## License

This project is licensed under the MIT License - see
the [LICENSE](https://github.com/naviqore/public-transit-viewer/blob/main/LICENSE) file for details.
1 change: 0 additions & 1 deletion naviqore_client/.python-version

This file was deleted.

Loading
Loading