Skip to content

Commit d0c284e

Browse files
authored
v3.0.0 Anubis LMS (#84)
* CHG course aware admin utilities * ADD professor and TA management components * ADD basic permission and crash checks * CHG rename pytest.sh * CHG lint * ADD TODO on all places in api that need docs * CHG document a huge amount of the api * FIX debug message target * CHG move nav items into Components subfolder * CHG set the DH_HOST for testing data seed * CHG significantly reduce course context checks * FIX spacing issue in design doc and add management ide auth notes * CHG more graceful course context checks in the frontend * FIX theia admin network policy * CHG simplify theia proxy LRU cache * CHG more clear error message on course action permission * FIX remove is_admin check from public submission * FIX remove is_admin check from auth user create * CHG increment version on about page
1 parent 1c2e1d1 commit d0c284e

File tree

135 files changed

+4023
-1452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+4023
-1452
lines changed

.gitmodules

-3
This file was deleted.

Makefile

+12-21
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ BUILT_IMAGES := $(shell \
1717
2> /dev/null \
1818
)
1919
RUNNING_CONTAINERS := $(shell docker-compose ps -q)
20-
API_IP := $(shell docker network inspect anubis_default | \
21-
jq '.[0].Containers | .[] | select(.Name == "anubis_api_1") | .IPv4Address' -r | \
22-
awk '{print substr($$0, 1, index($$0, "/")-1)}' \
23-
2> /dev/null \
24-
)
2520
VOLUMES := $(shell docker volume ls | awk '{if (match($$2, /^anubis_.*$$/)) {print $$2}}')
2621

2722

@@ -45,6 +40,14 @@ push:
4540
docker-compose build --parallel --pull $(PUSH_SERVICES)
4641
docker-compose push $(PUSH_SERVICES)
4742

43+
startup-links:
44+
@echo ''
45+
@echo 'seed: http://localhost/api/admin/seed/'
46+
@echo 'auth: http://localhost/api/admin/auth/token/superuser'
47+
@echo 'auth: http://localhost/api/admin/auth/token/ta'
48+
@echo 'auth: http://localhost/api/admin/auth/token/professor'
49+
@echo 'site: http://localhost/'
50+
4851
.PHONY: debug # Start the cluster in debug mode
4952
debug:
5053
docker-compose up -d $(PERSISTENT_SERVICES)
@@ -55,10 +58,7 @@ debug:
5558
sleep 3
5659
@echo 'running migrations'
5760
make -C api migrations
58-
@echo ''
59-
@echo 'seed: http://localhost/api/admin/seed/'
60-
@echo 'auth: http://localhost/api/admin/auth/token/jmc1283'
61-
@echo 'site: http://localhost/'
61+
make startup-links
6262

6363
.PHONY: mindebug # Start the minimal cluster in debug mode
6464
mindebug:
@@ -70,26 +70,17 @@ mindebug:
7070
sleep 3
7171
@echo 'running migrations'
7272
make -C api migrations
73-
@echo ''
74-
@echo 'seed: http://localhost/api/admin/seed/'
75-
@echo 'auth: http://localhost/api/admin/auth/token/jmc1283'
76-
@echo 'site: http://localhost/'
73+
make startup-links
7774

7875
.PHONY: mkdebug # Start minikube debug
7976
mkdebug:
8077
./k8s/debug/provision.sh
81-
@echo ''
82-
@echo 'seed: http://localhost/api/admin/seed/'
83-
@echo 'auth: http://localhost/api/admin/auth/token/jmc1283'
84-
@echo 'site: http://localhost/'
78+
make startup-links
8579

8680
.PHONY: mkrestart # Restart minikube debug
8781
mkrestart:
8882
./k8s/debug/restart.sh
89-
@echo ''
90-
@echo 'seed: http://localhost/api/admin/seed/'
91-
@echo 'auth: http://localhost/api/admin/auth/token/jmc1283'
92-
@echo 'site: http://localhost/'
83+
make startup-links
9384

9485
yeetdb:
9586
docker-compose kill db

api/Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ all: venv
1010

1111
venv:
1212
virtualenv -p `which python3` venv
13-
./venv/bin/pip install -r ./requirements.txt -r ./requirements-dev.txt
13+
./venv/bin/pip install -r ./requirements.txt
14+
./venv/bin/pip install -U black pytest
1415

1516
debug:
1617
make -C .. debug
@@ -25,10 +26,8 @@ cleanyeetdb:
2526
migrations: venv
2627
./venv/bin/alembic upgrade head
2728

28-
.PHONY: lint # Run autopep8 then black on lint directories
29+
.PHONY: lint # Run black on lint directories
2930
lint: venv
30-
@echo 'autopep to check and fix un-python things'
31-
./venv/bin/autopep8 --in-place --aggressive --aggressive $(LINT_FILES)
3231
@echo 'black to stylize'
3332
./venv/bin/black $(LINT_FILES)
3433

api/anubis/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def create_pipeline_app():
7979
# Initialize app with all the extra services
8080
init_services(app)
8181

82-
# register blueprints
82+
# register views
8383
register_pipeline_views(app)
8484

8585
return app

api/anubis/config.py

+17-41
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,47 @@
44

55

66
class Config:
7-
SECRET_KEY = None
8-
STATS_REAP_DURATION = timedelta(days=60)
9-
10-
# sqlalchemy
11-
SQLALCHEMY_DATABASE_URI = None
12-
SQLALCHEMY_POOL_PRE_PING = True
13-
SQLALCHEMY_POOL_SIZE = 100
14-
SQLALCHEMY_POOL_RECYCLE = 280
15-
SQLALCHEMY_TRACK_MODIFICATIONS = False
16-
17-
# OAuth
18-
OAUTH_CONSUMER_KEY = ""
19-
OAUTH_CONSUMER_SECRET = ""
20-
21-
# Cache config
22-
CACHE_REDIS_HOST = "redis-master"
23-
CACHE_REDIS_PASSWORD = os.environ.get("REDIS_PASSWORD", default="anubis")
24-
25-
# Logger config
26-
LOGGER_NAME = os.environ.get("LOGGER_NAME", default="anubis-api")
27-
28-
# Theia config
29-
THEIA_DOMAIN = ""
30-
THEIA_TIMEOUT = timedelta(hours=6)
317

328
def __init__(self):
9+
# General flask config
3310
self.DEBUG = os.environ.get("DEBUG", default="0") == "1"
34-
3511
self.SECRET_KEY = os.environ.get("SECRET_KEY", default="DEBUG")
3612

13+
# sqlalchemy
14+
self.SQLALCHEMY_DATABASE_URI = None
15+
self.SQLALCHEMY_POOL_PRE_PING = True
16+
self.SQLALCHEMY_POOL_SIZE = 100
17+
self.SQLALCHEMY_POOL_RECYCLE = 280
18+
self.SQLALCHEMY_TRACK_MODIFICATIONS = False
3719
self.SQLALCHEMY_DATABASE_URI = os.environ.get(
3820
"DATABASE_URI",
3921
default="mysql+pymysql://anubis:anubis@{}/anubis".format(
4022
os.environ.get("DB_HOST", "db")
4123
),
4224
)
25+
26+
# Elasticsearch
4327
self.DISABLE_ELK = os.environ.get("DISABLE_ELK", default="0") == "1"
4428

4529
# OAuth
4630
self.OAUTH_CONSUMER_KEY = os.environ.get("OAUTH_CONSUMER_KEY", default="DEBUG")
47-
self.OAUTH_CONSUMER_SECRET = os.environ.get(
48-
"OAUTH_CONSUMER_SECRET", default="DEBUG"
49-
)
31+
self.OAUTH_CONSUMER_SECRET = os.environ.get("OAUTH_CONSUMER_SECRET", default="DEBUG")
5032

5133
# Redis
52-
self.CACHE_REDIS_HOST = os.environ.get(
53-
"CACHE_REDIS_HOST", default="redis-master"
54-
)
55-
56-
self.CACHE_REDIS_PASSWORD = os.environ.get(
57-
"REDIS_PASS", default="anubis"
58-
)
34+
self.CACHE_REDIS_HOST = os.environ.get("CACHE_REDIS_HOST", default="redis-master")
35+
self.CACHE_REDIS_PASSWORD = os.environ.get("REDIS_PASS", default="anubis")
5936

6037
# Logger
6138
self.LOGGER_NAME = os.environ.get("LOGGER_NAME", default="anubis-api")
6239

6340
# Theia
64-
self.THEIA_DOMAIN = os.environ.get(
65-
"THEIA_DOMAIN", default="ide.anubis.osiris.services"
66-
)
41+
self.THEIA_DOMAIN = os.environ.get("THEIA_DOMAIN", default="ide.anubis.osiris.services")
6742
self.THEIA_TIMEOUT = timedelta(hours=6)
6843

69-
logging.info(
70-
"Starting with DATABASE_URI: {}".format(self.SQLALCHEMY_DATABASE_URI)
71-
)
44+
# autograding specific config
45+
self.STATS_REAP_DURATION = timedelta(days=60)
46+
47+
logging.info("Starting with DATABASE_URI: {}".format(self.SQLALCHEMY_DATABASE_URI))
7248
logging.info("Starting with SECRET_KEY: {}".format(self.SECRET_KEY))
7349
logging.info("Starting with DEBUG: {}".format(self.DEBUG))
7450

0 commit comments

Comments
 (0)