Skip to content

Commit

Permalink
Merge branch 'sebastianbana/sc-26081/fix-namekit-lambda-deployments' …
Browse files Browse the repository at this point in the history
…into staging
  • Loading branch information
BanaSeba committed Jan 9, 2025
2 parents 5c6900f + f90bc93 commit 15e9d2d
Show file tree
Hide file tree
Showing 85 changed files with 2,796 additions and 1,626 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"namehashlabs.org",
"@namehash/seo",
"@namehash/internal",
"namerank.io",
"nameai.dev",
"namekit.io",
"namegraph.dev"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/namerank-python-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Install dependencies
working-directory: ./apps/api.namerank.io
run: poetry install
run: poetry install --extras "lambda"

- name: Run tests
working-directory: ./apps/api.namerank.io
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/typescript-packages-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- "nameguard-js"
- "nameguard-react"
- "namekit-react"
- "namerank-sdk"

name: Test ${{ matrix.package }}
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion apps/api.nameguard.io/terraform/deploy_lambda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ if ! docker push ${ECR_URL}:latest; then
exit 1
fi

IMAGE_URI="${ECR_URL}:latest"
IMAGE_URI=`docker inspect --format='{{index .RepoDigests 0}}' ${ECR_URL}:latest`
echo "Using Image URI: ${IMAGE_URI}"

# Export individual environment variables for Terraform
Expand Down
2 changes: 1 addition & 1 deletion apps/api.namerank.io/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ WORKDIR /app
RUN yum install gcc -y
COPY pyproject.toml poetry.lock LICENSE README.md ./
COPY namerank ./namerank/
RUN pip install --no-cache-dir .[namerank]
RUN pip install --no-cache-dir .[lambda]
CMD [ "namerank.root_api.handler" ]
22 changes: 21 additions & 1 deletion apps/api.namerank.io/LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
TODO
MIT License

Copyright (c) 2023 NameHash

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 3 additions & 3 deletions apps/api.namerank.io/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
## API
The API extends the NameGuard API and is fully compatible with it.

NameRank-specific endpoints are under the [rank.namekit.io/namerank](https://www.rank.namekit.io/namerank) path prefix.
NameRank-specific endpoints are under the [api.namerank.io/namerank](https://www.api.namerank.io/namerank) path prefix.

API documentation is available at [rank.namekit.io/namerank/docs](https://rank.namekit.io/namerank/docs) and [rank.namekit.io/docs](https://rank.namekit.io/docs) for NameGuard.
API documentation is available at [api.namerank.io/namerank/docs](https://api.namerank.io/namerank/docs) and [api.namerank.io/docs](https://api.namerank.io/docs) for NameGuard.

Lambda is publicly accessible under given domain [rank.namekit.io](https://rank.namekit.io)
Lambda is publicly accessible under given domain [api.namerank.io](https://api.namerank.io)

# AWS deploy
## Requirements
Expand Down
36 changes: 28 additions & 8 deletions apps/api.namerank.io/namerank/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,44 @@ class NLPLabelAnalysis(BaseModel):

inspection: inspector_models.InspectorResult = Field(description='The result of the label inspection')
status: LabelStatus = Field(description='The normalization status of the label')
probability: float = Field(description='The probability of the label')
log_probability: float = Field(description='The natural logarithm of the probability')
word_count: int = Field(description='The number of words in the label')
top_tokenization: Optional[list[str]] = Field(description='The most likely tokenization of the label')
tokenizations: list[dict] = Field(description='All possible tokenizations of the label')
probability: float = Field(
description='The probability that this label represents a meaningful word or phrase in natural language, based on statistical language models. Higher values indicate the label is more likely to be meaningful text rather than random characters.',
ge=0.0,
le=1.0,
)
log_probability: float = Field(
description='The natural logarithm of the probability score. Log probabilities are often more useful for comparing labels since they convert multiplicative relationships to additive ones and better handle very small probabilities.',
le=0.0,
)
word_count: int = Field(
description='The minimum number of words across all valid tokenizations of the label that contain no gaps. '
'Will be 0 if no valid tokenization without gaps is found. For example, labels containing only '
'numbers or special characters may have a word_count of 0.'
'Note: this is not the number of words in the top_tokenization, but the minimum number of words across all valid tokenizations without gaps.',
ge=0,
)
top_tokenization: Optional[list[str]] = Field(
description="The recommended tokenization of the label into words. We give priority to tokenizations that don't have gaps and have fewer words, even if they are less probable. Will be None if: "
'no valid tokenization is found, or the label is not normalized, or the tokenization process was interrupted by recursion limit, or word_count is 0. '
'When present, this contains the tokens from the tokenization with the fewest words (and highest probability among ties) that has no gaps.'
)
tokenizations: list[dict] = Field(
description='Up to 1000 possible tokenizations of the label, ordered by probability from highest to lowest. Each dict '
'contains the tokenization and its probability score. Will be an empty list if no valid '
'tokenizations are found. For very long or complex labels, not all possible tokenizations may be included.'
)


class NameRankReport(BaseModel):
purity_score: float = Field(
title='Purity score of the input',
description='For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0.',
description='Score indicating the purity/cleanliness of the name. For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0. The score ranges from 0.0 to 1.0 inclusive, where 0.0 indicates lowest purity and 1.0 indicates highest purity.',
ge=0.0,
le=1.0,
)

interesting_score: float = Field(
title='Interesting score of the input',
description='For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0.',
description='Score indicating how interesting/memorable the name is. For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0. The score ranges from 0.0 to 1.0 inclusive, where 0.0 indicates least interesting and 1.0 indicates most interesting.',
ge=0.0,
le=1.0,
)
Expand Down
6 changes: 3 additions & 3 deletions apps/api.namerank.io/namerank/root_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from mangum import Mangum

# root app
app = nameguard_app
app = namerank_app

# namerank as sub-app
app.mount('/namerank', namerank_app)
# nameguard as sub-app
app.mount('/nameguard', nameguard_app)

handler = Mangum(app)
Loading

0 comments on commit 15e9d2d

Please sign in to comment.