Skip to content

Commit

Permalink
Merge pull request #252 from RTIInternational/update_docs
Browse files Browse the repository at this point in the history
Update SMART to version 3.0.0 after pulling in updates from dev and significantly updating docs
  • Loading branch information
AstridKery authored Apr 28, 2023
2 parents 174b178 + 7487289 commit cfbb7f0
Show file tree
Hide file tree
Showing 225 changed files with 38,698 additions and 1,429 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ smart-docs/docs/_build/
smart-docs/docs/nbuild/

# Landing
docs/node_modules/
docs/node_modules/

# Backups
backup/*
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_backend:
script:
- cd envs/dev
- docker-compose start
- docker exec -i smart_backend bash -c "./run_tests.sh"
- docker exec -i backend bash -c "./run_tests.sh"
after_script:
- cd envs/dev
- docker-compose stop
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
- id: isort
name: isort
pass_filenames: false
entry: docker-compose -f envs/dev/docker-compose.yml run --rm smart_backend bash -c "/code/scripts/isort.sh --format"
entry: docker-compose -f envs/dev/docker-compose.yml run --rm backend bash -c "/code/scripts/isort.sh --format"
language: system
types: [python]
- id: docformatter
name: docformatter
pass_filenames: false
entry: docker-compose -f envs/dev/docker-compose.yml run --rm smart_backend bash -c "/code/scripts/docformatter.sh --format"
entry: docker-compose -f envs/dev/docker-compose.yml run --rm backend bash -c "/code/scripts/docformatter.sh --format"
language: system
types: [python]
- id: black
name: black
pass_filenames: false
entry: docker-compose -f envs/dev/docker-compose.yml run --rm smart_backend bash -c "/code/scripts/black.sh --format"
entry: docker-compose -f envs/dev/docker-compose.yml run --rm backend bash -c "/code/scripts/black.sh --format"
language: system
types: [python]
- id: flake8
name: flake8
pass_filenames: false
entry: docker-compose -f envs/dev/docker-compose.yml run --rm smart_backend bash -c "/code/scripts/flake8.sh"
entry: docker-compose -f envs/dev/docker-compose.yml run --rm backend bash -c "/code/scripts/flake8.sh"
language: system
types: [python]
- id: eslint-js
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_script:
script:
- docker-compose up -d
- docker-compose exec smart_frontend bash -c "./run_tests.sh"
- docker-compose exec smart_backend bash -c "./run_tests.sh"
- docker-compose exec backend bash -c "./run_tests.sh"

after_script:
- docker-compose down
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ docker volume create --name=vol_smart_data
Then, migrate the database to ensure the schema is prepared for the application.

```bash
docker-compose run --rm smart_backend ./migrate.sh
docker-compose run --rm backend ./migrate.sh
```

### Workflow During Development
Expand All @@ -61,16 +61,16 @@ docker-compose up
If your database is blank, you will need to run migrations to initialize all the required schema objects; you can start a blank backend container and run the migration django management command with the following command:

```shell
docker-compose run --rm smart_backend ./migrate.sh
docker-compose run --rm backend ./migrate.sh
```

#### Dependency management in Python

We use [pip-tools](https://github.com/jazzband/pip-tools) to manage Python dependencies. To change the dependencies:

1. Edit [requirements.in](./backend/docker/requirements.in) to add, remove, or edit a dependency. You only need to put primary dependencies here, that is, the ones explicitly needed by our source code. pip-tools will take care of adding their dependencies.
1. Run `docker-compose run --rm smart_backend pip-compile docker/requirements.in` to generate a new [requirements.txt](./backend/docker/requirements.txt). Note that pip-tools uses the existing `requirements.txt` file when building a new one, so that it can maintain existing versions. To upgrade a package to the newest version compatible with the other libraries, just remove it from the existing `requirements.txt` before running pip-compile.
1. Run `docker-compose build smart_backend` to install the updated requirements into the Docker image.
1. Run `docker-compose run --rm backend pip-compile docker/requirements.in` to generate a new [requirements.txt](./backend/docker/requirements.txt). Note that pip-tools uses the existing `requirements.txt` file when building a new one, so that it can maintain existing versions. To upgrade a package to the newest version compatible with the other libraries, just remove it from the existing `requirements.txt` before running pip-compile.
1. Run `docker-compose build backend` to install the updated requirements into the Docker image.

### Custom Environment Variables

Expand All @@ -86,12 +86,17 @@ EXTERNAL_FRONTEND_PORT=3001

The `.env` file is ignored by `.gitignore`.

### Timezones

All date-times in the SMART backend and database are set to UTC (Coordinated Universal Time) as reccomended by the [Django docs](https://docs.djangoproject.com/en/4.1/topics/i18n/timezones/). By default the history and download date-times are set to Eastern New York time. To change this, go to `SMART/backend/django/smart/settings.py` and update the `TIME_ZONE_FRONTEND` variable to the desired time-zone.


### Running tests

Backend tests use [py.test](https://docs.pytest.org/en/latest/) and [flake8](http://flake8.pycqa.org/en/latest/). To run them, use the following `docker-compose` command from the `env/dev` directory:

```
docker-compose run --rm smart_backend ./run_tests.sh <args>
docker-compose run --rm backend ./run_tests.sh <args>
```

Where `<args>` are arguments to be passed to py.test. Use `py.test -h` to see all the options, but a few useful ones are highlighted below:
Expand Down
3 changes: 3 additions & 0 deletions backend/django/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

class CoreConfig(AppConfig):
name = "core"

def ready(self):
import core.signals # noqa: F401
1 change: 1 addition & 0 deletions backend/django/core/data/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ numpy==1.13.3
pandas==0.20.3
scikit-learn==0.19.0
scipy==0.19.1
string-grouper==0.5.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Text,Label,Score,Num Comments,Subreddit
<TEST> r/aww has a Discord server,,7284,18,O_O
<TEST> /r/Incorgnito: /r/aww Subreddit of the Week,,4911,87,
<TEST> What a beauty üòç,,4811,17,
"<TEST> I love how tender this baby is with this kitten, kudos parents! 🥰",,7377,25,
<TEST> Stray dog and cat in Romania.,,5744,50,
<TEST> Physics? I don't care...,,147,75,
<TEST> Oh boy oh boy oh boy!,,91,48,
<TEST> Casual super cat.,,325,81,
<TEST> Casual super cat.,,100,100,>_>
<TEST> Casual super cat.,,10,10,>_>
<TEST> Casual super cat.,,10,10,>_>
Loading

0 comments on commit cfbb7f0

Please sign in to comment.