-
Notifications
You must be signed in to change notification settings - Fork 116
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
Dtype changes #481
base: main
Are you sure you want to change the base?
Dtype changes #481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Wasp (Semgrep) - SAST Check | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
|
||
schedule: | ||
- cron: '0 */24 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
wasp-scan: | ||
name: Wasp scan | ||
runs-on: | ||
group: security-lrg | ||
steps: | ||
- name: Setting permission | ||
run: sudo chown runner:runner -R .* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: The wildcard pattern .* in chown is overly broad and could affect hidden files. Use a more specific path like '.' |
||
|
||
- name: Repository checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Running Wasp scan | ||
uses: freshactions/wasp@latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Using @latest tag for actions can be dangerous. Pin to a specific version for security and stability |
||
env: | ||
WASP_LOG_LEVEL: DEBUG | ||
WASP_SAVE_JSON: true | ||
WASP_SAVE_HTML: true | ||
WASP_SAVE_CSV: true | ||
WASP_FRESHRELEASE_PR_PROJECT_KEY: ${{ vars.SECURITY_APPSEC_FRESHRELEASE_PROJECT_KEY }} | ||
WASP_DRY_RUN: ${{ vars.SECURITY_APPSEC_WASP_DRY_RUN }} | ||
|
||
WASP_FRESHRELEASE_URL: ${{ vars.SECURITY_APPSEC_FRESHRELEASE_URL }} | ||
WASP_FRESHRELEASE_PR_ISSUE_TYPE: ${{ vars.SECURITY_APPSEC_FRESHRELEASE_PR_ISSUE_TYPE }} | ||
|
||
WASP_TOKEN: ${{ secrets.SECURITY_APPSEC_WASP_TOKEN }} | ||
WASP_FRESHRELEASE_TOKEN: ${{ secrets.SECURITY_APPSEC_FRESHRELEASE_TOKEN }} | ||
WASP_SLACK_TOKEN: ${{ secrets.SECURITY_APPSEC_SLACK_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.SECURITY_APPSEC_GH_TOKEN }} | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: Wasp scan report archive | ||
retention-days: ${{ vars.SECURITY_APPSEC_WASP_RESULT_RETENTION_DAYS }} | ||
path: | | ||
wasp-report.csv | ||
wasp-report.json | ||
wasp-report.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ __pycache__/ | |
# C extensions | ||
*.so | ||
|
||
# Pycharn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: 'Pycharn' is misspelled, should be 'PyCharm' |
||
.idea | ||
models/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Ignoring 'models/' directory may prevent tracking of important model files that should be version controlled. Consider being more specific about which model files to ignore |
||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
#export OTEL_TRACES_SAMPLER=parentbased_always_off | ||
export OTEL_RESOURCE_ATTRIBUTES=service.name=${SHERLOCK_SERVICE_NAME},host.name=${POD_NAME},host.ip=${POD_IP} | ||
export OTEL_EXPORTER_OTLP_ENDPOINT=http://${HOST_IP}:5680 | ||
infinity_emb v2 --model-id /models --dtype ${DTYPE} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: The hardcoded /models path assumes a specific directory structure. Consider making this configurable via environment variable |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,11 @@ | |
RerankInput, | ||
ReRankResult, | ||
) | ||
from infinity_emb.log_handler import UVICORN_LOG_LEVELS, logger | ||
from infinity_emb.log_handler import ( | ||
UVICORN_LOG_LEVELS, | ||
logger, | ||
StructuredLoggingMiddleware, | ||
) | ||
from infinity_emb.primitives import ( | ||
Device, | ||
Dtype, | ||
|
@@ -129,6 +133,7 @@ async def validate_token( | |
|
||
instrumentator = Instrumentator().instrument(app) | ||
app.add_exception_handler(errors.OpenAIException, errors.openai_exception_handler) | ||
app.add_middleware(StructuredLoggingMiddleware) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: StructuredLoggingMiddleware should be added before other middleware like CORSMiddleware to ensure all requests are properly logged |
||
|
||
@app.get("/health", operation_id="health", response_class=responses.ORJSONResponse) | ||
async def _health() -> dict[str, float]: | ||
|
@@ -220,13 +225,13 @@ async def _embeddings(data: OpenAIEmbeddingInput): | |
if isinstance(data.input, str): | ||
data.input = [data.input] | ||
|
||
logger.debug("[📝] Received request with %s inputs ", len(data.input)) | ||
logger.info("[📝] Received request with %s inputs ", len(data.input)) | ||
start = time.perf_counter() | ||
|
||
embedding, usage = await engine.embed(sentences=data.input) | ||
|
||
duration = (time.perf_counter() - start) * 1000 | ||
logger.debug("[✅] Done in %s ms", duration) | ||
logger.info("[✅] Done in %s ms", duration) | ||
|
||
return OpenAIEmbeddingResult.to_embeddings_response( | ||
embeddings=embedding, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: pull_request_target is a security risk as it runs with repository secrets on external PR code. Consider using pull_request instead if repository secrets are not needed, or add explicit ref validation