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

Pydantic #16

Merged
merged 33 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f2a5073
BIG: formalized models for workflows used in scheduler and DB, test_s…
eudoxos Oct 1, 2024
c0072ed
Remove debugging logs, try fixing restAPI startup in pytest/xprocess
eudoxos Oct 1, 2024
c4299af
(remove class no longer in use)
eudoxos Oct 1, 2024
a841a33
Decorate restApiControl for granta: stubs or granta-specific code (mo…
eudoxos Oct 3, 2024
65b6b39
move things around, decorators and other cleanups, move restApiContro…
eudoxos Oct 3, 2024
c2d6609
rename api/ctl* to api/client*, fix imports
eudoxos Oct 4, 2024
d8e8795
small import and annotation fixes to make mypy happy
eudoxos Oct 6, 2024
caad7c5
(import fix)
eudoxos Oct 6, 2024
263e28d
WIP (BIG): convert webapi and workflowmanager to models (mostly), fix…
eudoxos Oct 7, 2024
83e1b75
make web working (mostly); update Makefile to run a fully self-contai…
eudoxos Oct 8, 2024
7a7cc1e
Fix db initialization
eudoxos Oct 8, 2024
a0b98ae
Fix test, show log after execution
eudoxos Oct 8, 2024
f23865c
fix usecase model, fix db init, update makefile, others
eudoxos Oct 8, 2024
c2ca415
Changes allover the place, so that hte (simulated) web client adds wo…
eudoxos Oct 11, 2024
8afedcb
Add script for testing web interface (not yet integrated in the CI)
eudoxos Oct 11, 2024
2eb1f59
CI: add webtest (WIP)
eudoxos Oct 11, 2024
f13c610
CI: fix flake8 & dir for webstes
eudoxos Oct 11, 2024
1e8ac73
CI: fix command-line args to FastAPI
eudoxos Oct 11, 2024
daceb79
(CI)
eudoxos Oct 11, 2024
1727c5a
(CI?)
eudoxos Oct 11, 2024
bcbb7ce
(CI)
eudoxos Oct 11, 2024
8d4224c
remove table_structures
eudoxos Oct 11, 2024
2d3ca33
add model_dump_db which defines required behavior for the db; add tes…
eudoxos Oct 13, 2024
1bd5608
Fix models so that all database records are validated
eudoxos Oct 13, 2024
2472988
Add notebook validating all database records, in all VPNs
eudoxos Oct 13, 2024
49951a4
cleanups, handle workflow not being found (catch "exception", add cus…
eudoxos Oct 13, 2024
0497bf6
Convert statistics to models as well, minor cleanups, add annotations…
eudoxos Oct 16, 2024
6324b57
(CI: syntax fix in granta)
eudoxos Oct 16, 2024
f4e3a75
change setExecutionStatus* to setExecutionStatus(...,*), fix scripts …
eudoxos Oct 16, 2024
9f228f6
(remove unused mypy.ini)
eudoxos Oct 16, 2024
f2bfcd9
Add parent methods to models
eudoxos Oct 31, 2024
63c821a
CI: add python 3.11, 3.12, 3.13
eudoxos Nov 1, 2024
b585728
Merge branch 'master' into pydantic
eudoxos Nov 19, 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
12 changes: 11 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
# needs quotes so that float 3.10 does not get interpreted as 3.1
python-version: [ '3.10' ]
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -42,3 +42,13 @@ jobs:
timeout-minutes: 2
run: |
python -m pytest .
- name: webapi test
timeout-minutes: 2
run: |
make & # runs all services, a separate instance
sleep 10
# cd as webtest contains relative paths to uploaded files
# run twice to also test workflow version bumping
cd tools && bash webtest.sh && bash webtest.sh
#
kill $! # terminate make
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
doc/build
__pycache__
.ipynb_checkpoints

.pytest_cache
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
MAKEFLAGS+=-j3
TASKS=rest web browse
MAKEFLAGS+=-j6
TASKS=ns mongo rest web browse scheduler

.PHONY: $(TASKS)
run: $(TASKS)


# if any task fails, use kill -TERM $(MAKPID) to teminate everything immediately
DIE := kill -TERM $(shell echo $$PPID)


ns:
python3 -m Pyro5.nameserver --port 11001 || $(DIE)
mongo:
mkdir -p mongodb-tmp~ && /usr/bin/mongod --port 11002 --noauth --dbpath=./mongodb-tmp~ --logpath=/dev/null --logappend || $(DIE)
rest:
cd mupifDB && FLASK_APP=mupifdbRestApi.py PYTHONPATH=.. python3 -m flask run --host 127.0.0.1 --port 5000
# MUPIFDB_DRY_RUN=1
sleep 2 && cd mupifDB/api && MUPIFDB_MONGODB_PORT=11002 MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIFDB_LOG_LEVEL=DEBUG MUPIFDB_RESTAPI_HOST=localhost MUPIFDB_RESTAPI_PORT=11003 PYTHONPATH=../.. python3 main.py || $(DIE)
web:
cd webapi && MUPIFDB_REST_SERVER=http://127.0.0.1:5000 FLASK_APP=index.py PYTHONPATH=.. python3 -m flask run --host 127.0.0.1 --port 5555
sleep 7 && cd webapi && MUPIFDB_MONGODB_PORT=11002 MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIFDB_WEB_FAKE_AUTH=1 FLASK_APP=index.py PYTHONPATH=.. python3 -m flask run --debug --no-reload --host 127.0.0.1 --port 11004 || $(DIE)
browse:
sleep 2 && xdg-open http://127.0.0.1:5555
sleep 9 # && xdg-open http://127.0.0.1:11004
scheduler:
sleep 7 && MUPIF_LOG_LEVEL=DEBUG MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIF_NS=localhost:11001 PYTHONPATH=.. python3 -c 'from mupifDB import workflowscheduler as ws; ws.LOOP_SLEEP_SEC=5; ws.schedulerStatFile="./sched-stat.json"; ws.main()' || $(DIE)
4 changes: 3 additions & 1 deletion mupifDB/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
__version__ = '0.0.1'
__author__ = 'Borek Patzak'

__package__ = __name__

# List all submodules, so they can all be imported: from mupif import *
__all__ = ['workflowmanager', 'schedulerstat', 'error', 'restApiControl', 'my_email']
# __all__ = ['workflowmanager', 'schedulerstat', 'error', 'restApiControl', 'my_email']

from . import workflowmanager
from . import schedulerstat
Expand Down
Empty file added mupifDB/api/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions mupifDB/api/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import requests
import json
import datetime
import sys
import os
import tempfile
import importlib
import re
import logging

import pydantic
from typing import List,Optional,Literal

from .. import models

from rich import print_json
from rich.pretty import pprint

from .client_util import api_type, NotFoundResponse

if api_type=='granta':
from .client_granta import *
else:
from .client_mupif import *

from .client_edm import *
51 changes: 51 additions & 0 deletions mupifDB/api/client_edm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from .client_util import *
import json
import re

def getEDMDataArray(DBName, Type):
response = rGet(f"EDM/{DBName}/{Type}")
return response.json()

def getEDMData(DBName, Type, ID, path):
if ID == '' or ID is None:
return None
response = rGet(f"EDM/{DBName}/{Type}/{ID}/?path={path}")
return response.json()


def setEDMData(DBName, Type, ID, path, data):
response = rPatch(f"EDM/{DBName}/{Type}/{ID}", data=json.dumps({"path": str(path), "data": data}))
return response.json()


def createEDMData(DBName, Type, data):
response = rPost(f"EDM/{DBName}/Type", data=json.dumps(data))
return response.json()


def cloneEDMData(DBName, Type, ID, shallow=[]):
response = rGet(f"EDM/{DBName}/{Type}/{ID}/clone", params={"shallow": ' '.join(shallow)})
return response.json()


def getSafeLinks(DBName, Type, ID, paths=[]):
response = rGet(f"EDM/{DBName}/{Type}/{ID}/safe-links", params={"paths": ' '.join(paths)})
return response.json()


def getEDMEntityIDs(DBName, Type, filter=None):
response = rPut(f"EDM/{DBName}/{Type}/find", data=json.dumps({"filter": (filter if filter else {})}))
return response.json()


def uploadEDMBinaryFile(DBName, binary_data):
response = rPost(f"EDM/{DBName}/blob/upload", files={"blob": binary_data})
return response.json()


def getEDMBinaryFileByID(DBName, fid):
response = rGet(f"EDM/{DBName}/blob/{fid}")
d = response.headers['Content-Disposition']
filename = re.findall("filename=(.+)", d)[0]
return response.content, filename

Loading
Loading