|
1 | 1 | # TACOS citation detector |
2 | 2 |
|
3 | | -A lambda to apply a pre-trained algorithm to predict whether a given search string is in the form of a citation. |
4 | | - |
5 | | -## Repo Setup (delete this section and above after initial function setup) |
6 | | - |
7 | | -1. Rename "my_function" to the desired initial function name across the repo. (May be helpful to do a project-wide find-and-replace). |
8 | | -2. Update Python version if needed (note: AWS lambda cannot currently support versions higher than 3.9). |
9 | | -3. Install all dependencies with `make install` to create initial Pipfile.lock with latest dependency versions. |
10 | | -4. Add initial function description to README and update initial required ENV variable documentation as needed. |
11 | | -5. Update license if needed (check app-specific dependencies for licensing terms). |
12 | | -6. Check Github repository settings: |
13 | | - - Confirm repo branch protection settings are correct (see [dev docs](https://mitlibraries.github.io/guides/basics/github.html) for details) |
14 | | - - Confirm that all of the following are enabled in the repo's code security and analysis settings: |
15 | | - - Dependabot alerts |
16 | | - - Dependabot security updates |
17 | | - - Secret scanning |
18 | | -7. Create a Sentry project for the app if needed (we want this for most apps): |
19 | | - - Send initial exceptions to Sentry project for dev, stage, and prod environments to create them. |
20 | | - - Create an alert for the prod environment only, with notifications sent to the appropriate team(s). |
21 | | - - If *not* using Sentry, delete Sentry configuration from my_function.py and test_my_function_.py, and remove sentry_sdk from project dependencies. |
22 | | - |
23 | | -# predict |
24 | | - |
25 | | -This function will perform the following work: |
| 3 | +A lambda to apply a pre-trained algorithm to predict whether a given search string is in the form of a citation. This |
| 4 | +function will perform the following work: |
26 | 5 |
|
27 | 6 | 1. Receives a set of parameters (submitted to the lambda via POST) |
28 | 7 | 2. Loads a pickle file containing a pre-trained machine learning model. |
29 | 8 | 3. Submits the parameters to the model to generate a binary prediction. |
30 | 9 | 4. Returns the result of that prediction. |
31 | 10 |
|
| 11 | +This lambda's operation is placed in context of our larger discovery ecosystem in the following diagram. The lambda is |
| 12 | +responsible for the shaded region. |
| 13 | + |
| 14 | +```mermaid |
| 15 | +sequenceDiagram |
| 16 | + participant User |
| 17 | + participant UI |
| 18 | + participant Tacos |
| 19 | + box PaleVioletRed Citation detector |
| 20 | + participant Lambda |
| 21 | + participant S3 |
| 22 | + end |
| 23 | + User->>UI: "popcorn" |
| 24 | + UI->>Tacos: "popcorn" |
| 25 | + Tacos-->Tacos: Extract features from "popcorn" |
| 26 | + Tacos-->Tacos: Load Lambda URL from Config Vars |
| 27 | + Tacos->>Lambda: {"features": {...}} |
| 28 | + Lambda-->Lambda: Load S3 address from ENV |
| 29 | + Lambda-->Lambda: Load default model filename "knn" from ENV |
| 30 | + Lambda-->>S3: Request "knn" model |
| 31 | + S3-->>Lambda: pkl file |
| 32 | + Lambda-->Lambda: Generate prediction |
| 33 | + Lambda->>Tacos: {"prediction": false} |
| 34 | +``` |
| 35 | + |
32 | 36 | ## Development |
33 | 37 |
|
34 | 38 | - To preview a list of available Makefile commands: `make help` |
@@ -65,14 +69,6 @@ This function will perform the following work: |
65 | 69 | "You have successfully called this lambda!" |
66 | 70 | ``` |
67 | 71 |
|
68 | | -## Running a Specific Handler Locally with Docker |
69 | | - |
70 | | -If this repo contains multiple lambda functions, you can call any handler you copy into the container (see Dockerfile) by name as part of the `docker run` command: |
71 | | - |
72 | | -```bash |
73 | | -docker run -p 9000:8080 predict:latest lambdas.<a-different-module>.lambda_handler |
74 | | -``` |
75 | | - |
76 | 72 | ## Environment Variables |
77 | 73 |
|
78 | 74 | ### Required |
|
0 commit comments