Skip to content

Commit

Permalink
Merge pull request #156 from hubmapconsortium/jpuerto/r-investigation
Browse files Browse the repository at this point in the history
Jpuerto/r investigation
  • Loading branch information
jpuerto-psc authored Feb 29, 2024
2 parents cd0f903 + 6f1eda5 commit faf6ab1
Show file tree
Hide file tree
Showing 31 changed files with 397 additions and 381 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort
pip install flake8==7.0.0 black==24.2.0 isort==5.13.2
- name: Flake8 Lint
run: |
flake8 --ignore=E501,W503 src
- name: Black Lint
run: |
black --line-length 88 --check --diff src
black --line-length 99 --check --diff src
- name: isort Lint
run: |
isort --profile black --check-only --diff src
7 changes: 5 additions & 2 deletions src/example_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
"main_resource": {
"python_version": "python3.8",
"module_manager": "virtualenv",
"modules": ["jupyterlab"],
"time_limit": "60"
"modules": [
"jupyterlab"
],
"time_limit": "60",
"environment_name": "JupyterLabJob"
}
}
},
Expand Down
83 changes: 45 additions & 38 deletions src/example_django_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": ["redis://127.0.0.1:6379/0?"]
"hosts": [
"redis://127.0.0.1:6379/0?"
]
}
}
},
Expand All @@ -41,47 +43,52 @@
"LOGGING": {
"version": 1,
"formatters": {
"django-q": {
"format": "{asctime} [Q] {levelname} {message}",
"style": "{"
},
"user_workspaces_server": {
"format": "{asctime} [UWS] {levelname} {message}",
"style": "{"
}
"django-q": {
"format": "{asctime} [Q] {levelname} {message}",
"style": "{"
},
"user_workspaces_server": {
"format": "{asctime} [UWS] {levelname} {message}",
"style": "{"
}
},
"handlers": {
"discard": {
"class": "logging.NullHandler"
},
"django-q-console": {
"class": "logging.StreamHandler",
"formatter": "django-q"
},
"user_workspaces_server_console": {
"class": "logging.StreamHandler",
"formatter": "user_workspaces_server"
},
"mail": {
"class": "user_workspaces_server.logging.AsyncEmailHandler",
"formatter": "user_workspaces_server",
"level": "ERROR",
"subject": "UWS Log",
"from_email": "[email protected]",
"email_list": []
}
"discard": {
"class": "logging.NullHandler"
},
"django-q-console": {
"class": "logging.StreamHandler",
"formatter": "django-q"
},
"user_workspaces_server_console": {
"class": "logging.StreamHandler",
"formatter": "user_workspaces_server"
},
"mail": {
"class": "user_workspaces_server.logging.AsyncEmailHandler",
"formatter": "user_workspaces_server",
"level": "ERROR",
"subject": "UWS Log",
"from_email": "[email protected]",
"email_list": []
}
},
"loggers": {
"django-q": {
"level": "INFO",
"propagate": true,
"handlers": ["django-q-console"]
},
"user_workspaces_server": {
"level": "DEBUG",
"propagate": false,
"handlers": ["user_workspaces_server_console", "mail"]
}
"django-q": {
"level": "INFO",
"propagate": true,
"handlers": [
"django-q-console"
]
},
"user_workspaces_server": {
"level": "DEBUG",
"propagate": false,
"handlers": [
"user_workspaces_server_console",
"mail"
]
}
}
}
}
4 changes: 1 addition & 3 deletions src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "user_workspaces_server_project.settings"
)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_workspaces_server_project.settings")
argv = sys.argv
cmd = argv[1] if len(argv) > 1 else ""
os.environ["SUBCOMMAND"] = cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ def api_authenticate(self, request):
raise ParseError(repr(e))

if "client_token" not in body:
raise ParseError(
"Missing client_token. Please have admin generate a token for you."
)
raise ParseError("Missing client_token. Please have admin generate a token for you.")

if "user_info" not in body:
raise ParseError(
"Missing user_info. Please provide user_info to get user_token."
)
raise ParseError("Missing user_info. Please provide user_info to get user_token.")

try:
client_token = body["client_token"]
Expand Down
83 changes: 45 additions & 38 deletions src/tests/github_test_django_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": ["redis://127.0.0.1:6379/0?"]
"hosts": [
"redis://127.0.0.1:6379/0?"
]
}
}
},
Expand All @@ -37,47 +39,52 @@
"LOGGING": {
"version": 1,
"formatters": {
"django-q": {
"format": "{asctime} [Q] {levelname} {message}",
"style": "{"
},
"user_workspaces_server": {
"format": "{asctime} [UWS] {levelname} {message}",
"style": "{"
}
"django-q": {
"format": "{asctime} [Q] {levelname} {message}",
"style": "{"
},
"user_workspaces_server": {
"format": "{asctime} [UWS] {levelname} {message}",
"style": "{"
}
},
"handlers": {
"discard": {
"class": "logging.NullHandler"
},
"django-q-console": {
"class": "logging.StreamHandler",
"formatter": "django-q"
},
"user_workspaces_server_console": {
"class": "logging.StreamHandler",
"formatter": "user_workspaces_server"
},
"mail": {
"class": "user_workspaces_server.logging.AsyncEmailHandler",
"formatter": "user_workspaces_server",
"level": "ERROR",
"subject": "UWS Log",
"from_email": "[email protected]",
"email_list": []
}
"discard": {
"class": "logging.NullHandler"
},
"django-q-console": {
"class": "logging.StreamHandler",
"formatter": "django-q"
},
"user_workspaces_server_console": {
"class": "logging.StreamHandler",
"formatter": "user_workspaces_server"
},
"mail": {
"class": "user_workspaces_server.logging.AsyncEmailHandler",
"formatter": "user_workspaces_server",
"level": "ERROR",
"subject": "UWS Log",
"from_email": "[email protected]",
"email_list": []
}
},
"loggers": {
"django-q": {
"level": "INFO",
"propagate": true,
"handlers": ["django-q-console"]
},
"user_workspaces_server": {
"level": "DEBUG",
"propagate": false,
"handlers": ["user_workspaces_server_console", "mail"]
}
"django-q": {
"level": "INFO",
"propagate": true,
"handlers": [
"django-q-console"
]
},
"user_workspaces_server": {
"level": "DEBUG",
"propagate": false,
"handlers": [
"user_workspaces_server_console",
"mail"
]
}
}
}
}
14 changes: 2 additions & 12 deletions src/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
UWS_CONFIG = json.load(
open(
BASE_DIR
/ (
"github_test_config.json"
if os.environ.get("GITHUB_WORKFLOW")
else "test_config.json"
)
/ ("github_test_config.json" if os.environ.get("GITHUB_WORKFLOW") else "test_config.json")
)
)

Expand All @@ -41,9 +37,7 @@
)

SECRET_KEY = (
get_random_string(12)
if not DJANGO_CONFIG["SECRET_KEY"]
else DJANGO_CONFIG["SECRET_KEY"]
get_random_string(12) if not DJANGO_CONFIG["SECRET_KEY"] else DJANGO_CONFIG["SECRET_KEY"]
)

DEBUG = DJANGO_CONFIG["DEBUG"]
Expand Down Expand Up @@ -93,13 +87,11 @@

WSGI_APPLICATION = "user_workspaces_server_project.wsgi.application"


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = DJANGO_CONFIG["DATABASES"]


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

Expand All @@ -118,7 +110,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

Expand All @@ -132,7 +123,6 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

Expand Down
9 changes: 5 additions & 4 deletions src/tests/unittests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

class WorkspaceModelTests(TestCase):
def test_get_workspace_query_param_fields(self):
"""Animals that can speak are correctly identified"""
"""Check Workspace query parameters"""
assert Workspace.get_query_param_fields() == ["name", "description", "status"]

def test_get_workspace_dict_fields(self):
"""Animals that can speak are correctly identified"""
"""Check Workspace dictionary fields"""
assert Workspace.get_dict_fields() == [
"id",
"name",
Expand All @@ -18,12 +18,13 @@ def test_get_workspace_dict_fields(self):
"datetime_created",
"workspace_details",
"status",
"default_job_type",
]


class JobModelTests(TestCase):
def test_get_workspace_query_param_fields(self):
"""Animals that can speak are correctly identified"""
"""Check Job query parameters"""
assert Job.get_query_param_fields() == [
"workspace_id",
"resource_job_id",
Expand All @@ -32,7 +33,7 @@ def test_get_workspace_query_param_fields(self):
]

def test_get_workspace_dict_fields(self):
"""Animals that can speak are correctly identified"""
"""Check Job dictionary fields"""
assert Job.get_dict_fields() == [
"id",
"workspace_id",
Expand Down
Loading

0 comments on commit faf6ab1

Please sign in to comment.