Skip to content

Commit

Permalink
fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mircealungu committed Apr 27, 2024
2 parents 954f09d + cfd5483 commit 3ea06a2
Show file tree
Hide file tree
Showing 76 changed files with 9,304 additions and 6,806 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source ~/.venvs/z_env/bin/activate

5 changes: 3 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh

DIR="$(cd "$(dirname "$0")" && pwd)"

echo $DIR
for rule_name in $DIR/rules; do
$DIR/rules/routes_should_not_end_in_slash
cd "$DIR/rules"
./routes_should_not_end_in_slash
done
18 changes: 0 additions & 18 deletions .github/workflows/pr-mt-diagrams.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/publish_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Docker Image

on:
release:
types: [published]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: zeeguu/api

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


15 changes: 15 additions & 0 deletions .github/workflows/render-architectural-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Render ARchitectural Diff with ArchLens

jobs:
render-diff-and-upload-comment:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: run_archlens
uses: archlens/render-diff-on-pr@main
with:
config-path: "archlens.json"
render-diff: "true"
BRANCH_NAME: "_archlens_diff"
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Python package
name: Unit Testing

on: [push]
on:
pull_request:
branches:
- master
push:

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ instance
dev_data_folder*
.idea/
.cache/
data/

*.pyc
*.egg-info
Expand Down
111 changes: 111 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
FROM python:3.12.3

RUN apt-get clean all
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get dist-upgrade -y

# Git
# ---
# required by github dependencies in requirements.txt
RUN apt-get -y install git


# mysql CL client
# -------------------------
# - good for debugging sometimes
RUN apt-get install -y mysql\*


# libmysqlclient
# --------------
# - required to be able to install mysqlclient with pip
# https://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
RUN apt-get install -y default-libmysqlclient-dev

# Zeeguu-Api
# ----------

# Declare that this will be mounted from a volume
VOLUME /Zeeguu-API

# We need to copy the requirements file it in order to be able to install it
# However, we're not copying the whole folder, such that in case we make a change in the folder
# (e.g. to this build file) the whole cache is not invalidated and the build process does
# not have to start from scratch
RUN mkdir /Zeeguu-API
COPY ./requirements.txt /Zeeguu-API/requirements.txt
COPY ./setup.py /Zeeguu-API/setup.py

# Install requirements and setup
WORKDIR /Zeeguu-API

RUN python -m pip install -r requirements.txt
RUN python setup.py develop

# Copy the rest of the files
# (this is done after the requirements are installed, so that the cache is not invalidated)
WORKDIR /Zeeguu-API
COPY . /Zeeguu-API

ENV ZEEGUU_CONFIG=/Zeeguu-API/default_docker.cfg

VOLUME /zeeguu-data


# mysql CL client
# -------------------------
# - good for debugging sometimes
RUN apt-get install -y mysql\*


# libmysqlclient
# --------------
# - required to be able to install mysqlclient with pip
# https://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
RUN apt-get install -y default-libmysqlclient-dev


# Apache
# ------
RUN apt-get install -y \
apache2 \
apache2-dev \
vim


# mod_wsgi
# --------
RUN pip install mod_wsgi

RUN /bin/bash -c 'mod_wsgi-express install-module | tee /etc/apache2/mods-available/wsgi.{load,conf}'
RUN a2enmod wsgi
RUN a2enmod headers

# ML: maybe better to map this file from outside?
RUN echo '\n\
<VirtualHost *:8080>\n\
WSGIDaemonProcess zeeguu_api home=/zeeguu-data/ python-path=/Zeeguu-API/\n\
WSGIScriptAlias / /Zeeguu-API/zeeguu_api.wsgi\n\
<Location />\n\
WSGIProcessGroup zeeguu_api\n\
WSGIApplicationGroup %{GLOBAL}\n\
</Location>\n\
<Directory "/Zeeguu-API">\n\
<Files "zeeguu_api.wsgi">\n\
Require all granted\n\
</Files>\n\
</Directory>\n\
ErrorLog ${APACHE_LOG_DIR}/error.log\n\
LogLevel info\n\
CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
</VirtualHost>' > /etc/apache2/sites-available/zeeguu-api.conf

RUN a2dissite 000-default.conf
RUN a2ensite zeeguu-api

RUN chown -R www-data:www-data /var/www


# have apache listen on port 8080
RUN sed -i "s,Listen 80,Listen 8080,g" /etc/apache2/ports.conf
10 changes: 5 additions & 5 deletions archlens.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"views": {

"top-level-view-depth-1": {
"packages": [
"packages": [
{
"packagePath":"",
"depth":1
"path": "*",
"depth": 1
}
],
],

"ignorePackages": []
}

}
}
}
19 changes: 13 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
dev_server:
image: zeeguu_api_dev
image: zeeguu/api
environment:
ZEEGUU_CONFIG: /Zeeguu-API/default_docker.cfg
ZEEGUU_ES_CONN_STRING: "elasticsearch:9200"
Expand All @@ -15,12 +15,19 @@ services:
volumes:
- .:/Zeeguu-API
- ./data/zeeguu:/zeeguu-data
entrypoint: "python /Zeeguu-API/dev.py"
entrypoint: "python /Zeeguu-API/start.py"
networks:
- zeeguu_backend
depends_on:
- elasticsearch

readability_server:
image: zeeguu/readability_server
ports:
- 3456:3456
networks:
- zeeguu_backend
restart: unless-stopped

elasticsearch:
image: elasticsearch:7.6.2
Expand All @@ -40,7 +47,7 @@ services:


dev_play:
image: zeeguu_api_dev
image: zeeguu/api
environment:
ZEEGUU_CONFIG: /Zeeguu-API/default_docker.cfg

Expand All @@ -53,7 +60,7 @@ services:

# docker-compose run --rm dev_bash
dev_bash:
image: zeeguu_api_dev
image: zeeguu/api
stdin_open: true # docker run -i
tty: true # docker run -t

Expand All @@ -68,7 +75,7 @@ services:
- zeeguu_backend

dev_test:
image: zeeguu_api_dev
image: zeeguu/api
environment:
ZEEGUU_CONFIG: /Zeeguu-API/default_docker.cfg

Expand All @@ -80,7 +87,7 @@ services:
- zeeguu_backend

dev_init_es:
image: zeeguu_api_dev
image: zeeguu/api
environment:
ZEEGUU_CONFIG: /Zeeguu-API/default_docker.cfg
ZEEGUU_ES_CONN_STRING: "elasticsearch:9200"
Expand Down
12 changes: 9 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ en_core_web_md @ https://github.com/explosion/spacy-models/releases/download/en_
de_core_news_md @ https://github.com/explosion/spacy-models/releases/download/de_core_news_md-3.7.0/de_core_news_md-3.7.0-py3-none-any.whl
da_core_news_md @ https://github.com/explosion/spacy-models/releases/download/da_core_news_md-3.7.0/da_core_news_md-3.7.0-py3-none-any.whl
rapidfuzz==3.0.0
scipy==1.10.1
scipy==1.13.0
git+https://github.com/zeeguu/confusionwords.git@main#egg=confusionwords
readabilipy
scikit-learn==1.4.0
flask_monitoringdashboard
flask_monitoringdashboard

# the following two were required when deploying the API on Mac OS with Python 3.12.1
cryptography
lxml_html_clean

# spacy sometimes pulls an older version of pydantic that breaks stuff; adding the following line to prevent this
pydantic>=1.10.8
2 changes: 1 addition & 1 deletion dev.py → start.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/env python
#!python3
import logging

# this is needed since when run as wsgi this script
Expand Down
17 changes: 4 additions & 13 deletions tools/_playground.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
from zeeguu.core.model import User
from zeeguu.core.user_statistics.activity import exercises_duration_by_day
from zeeguu.core.content_retriever.parse_with_readability_server import download_and_parse

from zeeguu.api.app import create_app

app = create_app()
app.app_context().push()

print("before the for")
for id in User.all_recent_user_ids(150):
u = User.find_by_id(id)
print(u.name)
duration_old = exercises_duration_by_day(u, True)
duration_new = exercises_duration_by_day(u)
if duration_new != duration_old:
print("old way")
print(duration_old)
print("new way")
print(duration_new)
na = download_and_parse(
"https://www.dr.dk/stories/1288510966/allerede-inden-oscar-showets-start-lurer-en-ny-skandale-i-kulissen")
print(na)
12 changes: 3 additions & 9 deletions tools/add_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@

def create_and_test_feed(url: str, feed_type: int):
feed = Feed.from_url(url, feed_type=feed_type)

feed_items = feed.feed_items()
if not feed_items:
print("Feed seems broken. No items found.")
else:
count = len(feed_items)
print(f"Feed seems healthy: {count} items found. ")
print(feed.feed_health_info())

return feed

Expand All @@ -34,8 +28,8 @@ def main():
print(f"= {icon_name}")

description = (
input(f"Description (Enter for: {test_feed.description}): ")
or test_feed.description
input(f"Description (Enter for: {test_feed.description}): ")
or test_feed.description
)
print(f"= {description}")

Expand Down
Loading

0 comments on commit 3ea06a2

Please sign in to comment.