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

chore: Update interdependent dependencies and revise command-line interface #94

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ b000027.txt
npm-debug.log*
yarn-debug.log*
yarn-error.log*
api.log

# Editor directories and files
.idea
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ disruptive and wastefully repetitive if performed in each visitor's browser.
a dotenv (`.env`) file with the database credentials.
+ Some details necessary for this step are found in
[configuring PostgreSQL](doc/install-postgres.md).
7. Run backscope: `python manage.py runserver`
7. Run backscope: `flask run`
+ See also detailed instructions for
[running backscope](doc/running-backscope.md).

Expand Down
Empty file removed api.log
Empty file.
19 changes: 3 additions & 16 deletions doc/directory_descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ As of 2022-11-01, this document might be outdated.

Auto generated

##### manage.py

The main entry point into the application

The main usage from this file is:

```bash
$ python3 manage.py db init
$ python3 manage.py db migrate
$ python3 manage.py db upgrade

$ python3 manage.py runserver
```

Any other target may be considered for future development

##### api.log

The log file for the flask application
Expand All @@ -36,6 +20,9 @@ Logging levels are set in flaskr/config.py

Refer to https://flask.palletsprojects.com/en/1.1.x/logging/ for more information

Note that this file should not be checked into git for versioning; it's now
in the .gitignore file, which should hopefully prevent that happening.

##### flaskr

Flaskr is the main application. It contains all entry points to the application. \_\_init\_\_.py contains all the application macros.
Expand Down
6 changes: 3 additions & 3 deletions doc/install-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ character indicates a "shell comment." You don't need to enter this
character or anything that follows it on a line.

```
> python manage.py db init # initializes tables inside database
> flask db init # initializes tables inside database
```

The previous command might issue a message about editing
`alembic.ini`, which is safe to ignore. The default works fine. Then continue
with:

```
> python manage.py db migrate # migrate data models
> python manage.py db upgrade # upgrade changes to database
> flask db migrate # migrate data models
> flask db upgrade # upgrade changes to database
> psql -U <backscope database user> -d <database name> # invokes data browser
db> \d
List of relations
Expand Down
8 changes: 4 additions & 4 deletions doc/resetting-the-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ commands that you have activated the virtual environment
dropdb <database_name>
createdb <database_name>
rm -rf migrations
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
```
flask db init
flask db migrate
flask db upgrade
```
11 changes: 1 addition & 10 deletions doc/running-backscope.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,16 @@ Running backscope
To run the development server:

```
python manage.py runserver
```

(You should also be able to do this via

```bash
export FLASK_APP=flaskr
flask run
```

if you prefer.)

By enabling debug mode, the server will automatically reload if code
changes, and will show an interactive debugger in the browser if an
error occurs during a request. To run the development server in "debug"
mode:

```
python manage.py runserver --debug
flask run --debug
```

In either of these modes, the command should print a serries of messages.
Expand Down
14 changes: 7 additions & 7 deletions doc/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ For guidance, consult the basic instructions on how to [set up your environment]
1. Go into the top-level directory of the Backscope repository.
2. Activate the Backscope virtual environment.
+ If you're using [`venv`](https://docs.python.org/3/library/venv.html) to manage virtual environments, and you've put Backscope's virtual environment in a directory called `.venv`, use the command `source .venv/bin/activate` to activate.
3. Call `python manage.py test`.
3. Execut the command `flask test`.
katestange marked this conversation as resolved.
Show resolved Hide resolved
+ In quiet mode, you'll see a string of characters representing passed (`.`), failed (`F`), and skipped (`s`) tests.
+ To see the tests' names as well as their outcomes, call `python manage.py test -v` or `python manage.py test --verbose`.
+ To see the tests' names as well as their outcomes, execute `flask test -v` or `flask test --verbose`.
+ This command is a wrapper for `python -m unittest [-v]` and `python -m unitpytest discover [-v] [-s START] [-p PATTERN] [-t TOP]`. For more options, call `unittest` or `unittest discover` directly.

### Look at the test output
Expand All @@ -57,7 +57,7 @@ Here are some examples of what test results can look like.
:arrow_down: The `..` below tells us that both tests passed.

```
> python manage.py test
> flask test
..
----------------------------------------------------------------------
Ran 2 tests in 1.650s
Expand All @@ -68,7 +68,7 @@ OK
:arrow_down: The `s.` below tells us that one test was skipped and the other passed. Running in verbose mode may print an explanation of why we're skipping the test. This message is passed to the `@unittest.skip()` decorator.

```
> python manage.py test
> flask test
s.
----------------------------------------------------------------------
Ran 2 tests in 0.934s
Expand All @@ -79,7 +79,7 @@ OK (skipped=1)
:arrow_down: The `F.` below tells us that one test failed and the other passed. A report from the failed test follows.

```
> python manage.py test
> flask test
F.
======================================================================
FAIL: test_endpoint (flaskr.nscope.test.test_get_oeis_values.TestGetOEISValues)
Expand All @@ -99,7 +99,7 @@ FAILED (failures=1)
:arrow_down: Testing in verbose mode, like below, shows the tests' names as well as their outcomes.

```
> python manage.py test -v
> flask test -v
test_endpoint (flaskr.nscope.test.test_get_oeis_values.TestGetOEISValues) ...
Testing response
Waiting for background work
Expand All @@ -115,4 +115,4 @@ ok
Ran 2 tests in 2.556s

OK
```
```
6 changes: 4 additions & 2 deletions flaskr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from flask import Flask
import click
from flask.cli import with_appcontext
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
import logging
from logging.handlers import RotatingFileHandler
import sys
Expand Down Expand Up @@ -65,7 +66,8 @@ def create_app(environment=None):

# Initialize the application
db.init_app(app)

Migrate(app, db)

# Add a command line interface to the application
app.cli.add_command(init_db_command)

Expand Down
56 changes: 0 additions & 56 deletions manage.py

This file was deleted.

24 changes: 13 additions & 11 deletions requirements-freeze.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
alembic==1.8.1
blinker==1.6.3
certifi==2023.7.22
charset-normalizer==2.1.1
click==7.1.2
click==8.1.7
cypari2==2.1.3
cysignals==1.11.2
Cython==0.29.36
Flask==1.1.4
flask-cors==3.0.10
Flask-Executor==0.10.0
Flask==3.0.0
Flask-Cors==3.0.10
Flask-Executor==1.0.0
Flask-Login==0.5.0
Flask-Migrate==2.7.0
Flask-Script==2.0.6
Flask-SQLAlchemy==2.5.1
Flask-SQLAlchemy==3.1.1
Flask-WTF==0.15.1
greenlet==2.0.2
idna==3.4
itsdangerous==1.1.0
Jinja2==2.11.3
itsdangerous==2.1.2
Jinja2==3.1.2
jsonify==0.5
Mako==1.2.2
MarkupSafe==1.1.1
MarkupSafe==2.1.3
numpy==1.23.2
psycopg2-binary==2.9.7
python-dateutil==2.8.2
python-dotenv==0.20.0
python-editor==1.0.4
requests==2.28.1
six==1.16.0
SQLAlchemy==1.4.40
SQLAlchemy==2.0.22
typing_extensions==4.8.0
urllib3==1.26.12
Werkzeug==1.0.1
Werkzeug==3.0.0
wheel==0.41.2
WTForms==2.3.3
28 changes: 28 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
import click
import unittest
from flaskr import create_app

app = create_app()

# this is a wrapper for 'unittest discover', and the help messages are copied
# from there
# https://docs.python.org/3/library/unittest.html#test-discovery
@app.cli.command()
@click.option('-v', '--verbose', 'verbosity',
count=True, default=0,
help='Verbose output'
)
@click.option('-s', '--start-directory', 'start_dir', default='.',
help='Directory to start discovery (. default)'
)
@click.option('-p', '--pattern', 'pattern', default='test*.py',
help='Pattern to match test files (test*.py default)'
)
@click.option('-t', '--top-level-directory', 'top_level_dir',
help='Top level directory of project (defaults to start directory)'
)
def test(verbosity, start_dir, pattern, top_level_dir):
test_suite = unittest.defaultTestLoader.discover(
start_dir=start_dir,
pattern=pattern,
top_level_dir=top_level_dir
)
unittest.TextTestRunner(verbosity=verbosity+1).run(test_suite)