Skip to content

Commit

Permalink
Add initial version of new standalone hint generation app
Browse files Browse the repository at this point in the history
  • Loading branch information
levon003 committed Dec 5, 2023
1 parent 503a79e commit 6b68628
Show file tree
Hide file tree
Showing 6 changed files with 3,151 additions and 2,797 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ repos:
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
language_version: python3.9
language_version: python3.10
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
Expand Down
37 changes: 31 additions & 6 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ A few notes about the app.

#### Deployment

Manually deployed via `levon003`'s account.
Manually deployed via `levon003`'s Streamlit account.

#### Authentication

Expand All @@ -90,15 +90,40 @@ AUTH_TOKEN = "argon2:$argon2id$v=19$m=10240,t=10,p=8$MuVIOw20jkOi1nKR90hPhA$H22n

To generate the auth_token:
```
>>> import notebook.auth.security
>>> notebook.auth.security.passwd()
Enter password: abc
Verify password: abc
'argon2:$argon2id$v=19$m=10240,t=10,p=8$MuVIOw20jkOi1nKR90hPhA$H22nY8aNyfztLYQCSj5NRw5/Cy2WOo6kl3K61RyaoZY'
>>> from streamlit_app import auth_utils
>>> import getpass
>>> auth_utils.passwd_hash(getpass.getpass())
Password: abc
'argon2:$argon2id$v=19$m=10240,t=10,p=8$VfrxYg66b419O8hFi+vCLA$HZXq1dU0+KMUbOBxJjLaweXoHguJH+2AkPL1EurOOys'
```

If the AUTH_TOKEN is provided in the secrets, can authenticate automatically via URL parameter, e.g. `{base_url}?auth_token=abc`.

Generate your own secure auth token.

First:

```
>>> from streamlit_app import auth_utils
>>> auth_token = auth_utils.generate_auth_token()
>>> auth_token
'21bbeab31ed2a3ebcd5563df65db64ba'
>>> auth_utils.passwd_hash(auth_token)
'argon2:$argon2id$v=19$m=10240,t=10,p=8$ECyPoKgu51axdr4rgktOCA$qmrYxYoSaVq4uCwm9W5csfltApcKBQRTHLdtQY9OVKI'
```

Second, put the generated token in `secrets.toml`:

```
AUTH_TOKEN="argon2:$argon2id$v=19$m=10240,t=10,p=8$ECyPoKgu51axdr4rgktOCA$qmrYxYoSaVq4uCwm9W5csfltApcKBQRTHLdtQY9OVKI"
```

Third, you can then authenticate with `{base_url}?auth_token=21bbeab31ed2a3ebcd5563df65db64ba`

#### Hint generation app

The standalone hint-generation app is hosted at `src/hint_generation/app.py`.

## Data

The Streamlit demo draws on data from a few sources.
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help install ensure-poetry install-precommits install-kernel test run-streamlit build-docker run-docker
.PHONY: help install ensure-poetry install-precommits install-kernel test run-streamlit run-hint-generation-streamlit build-docker run-docker

help:
@echo "Relevant targets are 'install' and 'test'."
Expand Down Expand Up @@ -49,3 +49,6 @@ remove-docker:

run-streamlit:
@streamlit run src/🤖_Math_QA.py --

run-hint-generation-streamlit:
@streamlit run src/hint_generation/app.py --
Loading

0 comments on commit 6b68628

Please sign in to comment.