Skip to content

Commit

Permalink
Black formatting (#378)
Browse files Browse the repository at this point in the history
* black formats every python file in repo

* adds docs

* remove check yaml

* formats all html

* replace br tags

* close image tags

* Revert "remove check yaml"

This reverts commit bb6bdad.

* Revert "Revert "remove check yaml""

This reverts commit 7b5ad50.

* Revert "formats all html"

This reverts commit 2459eea.

* undo all html paths
  • Loading branch information
dxenes1 authored Dec 9, 2022
1 parent 964da05 commit 07a5c1d
Show file tree
Hide file tree
Showing 54 changed files with 1,949 additions and 1,094 deletions.
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3.9
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Clone this repository recursively so that the neuvue-client submodule will also
git clone https://github.com/aplbrain/neuvue-app.git --recursive
```

Create a python3 virtual environment and install the requirements in neuvue_project/requirements.txt.
Create a python3 virtual environment and install the requirements in neuvue_project/requirements.txt.

```shell
python3 -m venv venv
Expand All @@ -20,6 +20,22 @@ cd neuvue_project
pip install -r requirements.txt
```

## Development Installation

Install developer python requirements and set up pre-commit enviroment.

```
source venv/bin/activate
pip install -r requirements-dev.txt
pre-commit install
```

Once changes are staged. Run pre-commit to automatically remove trailing whitespaces, check YAML files, and run black formatting on all python files.

```
pre-commit
```

## (Optional) Compiling the neuroglancer project

A working neuroglancer compilation is included under `neuvue_project/workspace/static/workspace/`. However, if the underlying neuroglancer client needs to change,it must be compiled and linked.
Expand All @@ -43,7 +59,7 @@ Requirements: [nvm](https://github.com/nvm-sh/nvm)
npm i
npm link neuroglancer
npm run build
```
```
3. Copy the built files to static
```
cd neuvue_project/workspace/static/ts/wrapper
Expand All @@ -52,7 +68,7 @@ Requirements: [nvm](https://github.com/nvm-sh/nvm)

## Running a development environment

There is an included `neuvueDB.sqlite3` database file containing the tables needed to run the Django app. By default, the settings are configured for production which uses a cloud-enabled MySQL database server. To enable development mode:
There is an included `neuvueDB.sqlite3` database file containing the tables needed to run the Django app. By default, the settings are configured for production which uses a cloud-enabled MySQL database server. To enable development mode:

Run the following convenience script:
```
Expand All @@ -63,9 +79,9 @@ Or perform each step individually:

1. Open `neuvue_project/neuvue/settings.py` and set `DEBUG=True`

2. In the same file, modify `NEUVUE_QUEUE_ADDR` variable to the Nuevue-Queue endpoint you would like to use.
2. In the same file, modify `NEUVUE_QUEUE_ADDR` variable to the Nuevue-Queue endpoint you would like to use.

3. Get the recent migrations to the database by running
3. Get the recent migrations to the database by running

`python manage.py migrate`

Expand All @@ -77,11 +93,11 @@ Or perform each step individually:

`python manage.py collectstatic --no-input`

6. Run the app with the `runserver` command to start a development instance. Run on the localhost:8000 address and port to allow OAuth client to properly authenticate user.
6. Run the app with the `runserver` command to start a development instance. Run on the localhost:8000 address and port to allow OAuth client to properly authenticate user.

`python manage.py runserver localhost:8000`

7. Open your app on http://localhost:8000
7. Open your app on http://localhost:8000


## OAuth Set-up
Expand All @@ -92,7 +108,7 @@ We use `django-allauth` to connect Google OAuth to the Django environment. Users

http://localhost:8000/accounts/login/

Django users, OAuth settings, and site configuration can be modified in the admin console.
Django users, OAuth settings, and site configuration can be modified in the admin console.

http://localhost:8000/admin

Expand Down
4 changes: 2 additions & 2 deletions neuvue_project/dashboard/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'dashboard'
default_auto_field = "django.db.models.BigAutoField"
name = "dashboard"
34 changes: 19 additions & 15 deletions neuvue_project/dashboard/templatetags/inclusion_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

register = template.Library()

@register.inclusion_tag('reusable_components/confirm_modal.html')

@register.inclusion_tag("reusable_components/confirm_modal.html")
def confirm_modal(column):
return {
"column": column.lower(),
Expand All @@ -12,40 +13,43 @@ def confirm_modal(column):
"button_id": column.lower() + "-button",
}

@register.inclusion_tag('reusable_components/metrics_card.html')

@register.inclusion_tag("reusable_components/metrics_card.html")
def metrics_card(title, value, color):
return {
"title": title,
"value": value,
"color": color # should be a bootstrap color utility, e.g. primary, secondary
"color": color, # should be a bootstrap color utility, e.g. primary, secondary
}

@register.inclusion_tag('modals/flag_modal.html')

@register.inclusion_tag("modals/flag_modal.html")
def flag_modal(task_id):
return {
"task_id": task_id
}
return {"task_id": task_id}


@register.inclusion_tag('modals/remove_task_modal.html')
@register.inclusion_tag("modals/remove_task_modal.html")
def remove_task_modal():
return {}

@register.inclusion_tag('modals/timeout_modal.html')

@register.inclusion_tag("modals/timeout_modal.html")
def timeout_modal():
return {}

@register.inclusion_tag('modals/confirm_selected_segments_modal.html')

@register.inclusion_tag("modals/confirm_selected_segments_modal.html")
def confirm_selected_segments_modal(number_of_selected_segments_expected):
return {
"number_of_selected_segments_expected": number_of_selected_segments_expected
}

@register.inclusion_tag('modals/distribute_task_modal.html')

@register.inclusion_tag("modals/distribute_task_modal.html")
def distribute_task_modal():
return {}

@register.inclusion_tag('reusable_components/instructions.html')

@register.inclusion_tag("reusable_components/instructions.html")
def processed_instructions(instructions):
return {
"instructions": instructions
}
return {"instructions": instructions}
Loading

0 comments on commit 07a5c1d

Please sign in to comment.