Skip to content

Commit

Permalink
Update typesense upload (#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel authored Aug 6, 2024
1 parent a92859d commit b1c4c93
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,27 @@ jobs:
- name: Upload tutorials search file
uses: actions/upload-artifact@v3
with:
name: tutorials-search-file
name: tutorials-file
path: ./public/tutorials/typesense.json

- name: Upload quickstarts search file
uses: actions/upload-artifact@v3
with:
name: quickstarts-file
path: ./public/get-started/quickstarts/typesense.json

- name: Upload components models file
uses: actions/upload-artifact@v3
with:
name: components-models-file
path: ./public/components/typesense.json

- name: Upload services models file
uses: actions/upload-artifact@v3
with:
name: services-models-file
path: ./public/services/typesense.json

deploy:
environment:
name: github-pages
Expand All @@ -69,10 +81,10 @@ jobs:
runs-on: ubuntu-latest
if: github.repository_owner == 'viamrobotics'
steps:
- name: Download the tutorials search file
- name: Download the tutorials metadata file
uses: actions/download-artifact@v3
with:
name: tutorials-search-file
name: tutorials-file
- name: Upload tutorials documents
run: |
jq -c '.[]' typesense.json > documents.jsonl
Expand All @@ -81,6 +93,23 @@ jobs:
-T documents.jsonl \
"https://cgnvrk0xwyj9576lp-1.a1.typesense.net/collections/tutorials/documents/import?action=upsert"
upload-quickstarts-page-entries:
needs: deploy
runs-on: ubuntu-latest
if: github.repository_owner == 'viamrobotics'
steps:
- name: Download the quickstarts metadata file
uses: actions/download-artifact@v3
with:
name: quickstarts-info-file
- name: Upload quickstarts documents
run: |
jq -c '.[]' typesense.json > documents.jsonl
curl -H "X-TYPESENSE-API-KEY: ${{secrets.TYPESENSE_TUTORIALS_API_KEY}}" \
-X POST \
-T documents.jsonl \
"https://cgnvrk0xwyj9576lp-1.a1.typesense.net/collections/tutorials/documents/import?action=upsert"
generate-index:
needs: deploy
if: github.repository_owner == 'viamrobotics'
Expand Down Expand Up @@ -122,6 +151,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: components-models-file
path: "components.json"
- name: Download the services models file
uses: actions/download-artifact@v3
with:
name: services-models-file
path: "services.json"
- run: pip install -r .github/workflows/requirements.txt
- name: "Update modular resources"
run: python3 .github/workflows/get_modular_resources.py
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/get_modular_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ async def main():
json_m)
print(insert_resp)

# Get built-in resources from typesense.json
with open('typesense.json') as f:
# Get built-in resources from components.json
with open('components.json') as f:
resources = json.load(f)
for r in resources:
print("RESOURCE")
Expand All @@ -71,6 +71,19 @@ async def main():
print("INSERTED")
print(insert_resp)

# Get built-in resources from services.json
with open('services.json') as f:
resources = json.load(f)
for r in resources:
print("RESOURCE")
print(r)
r["last_updated"] = time_now
r["total_organization_usage"] = int(r["total_organization_usage"])
r["total_robot_usage"] = int(r["total_robot_usage"])
print(r)
insert_resp = typesense_client.collections['resources'].documents.upsert(r)
print("INSERTED")
print(insert_resp)

# Create a request to list registry items and get the response from the app
request = ListRegistryItemsRequest(organization_id=cloud._organization_id)
Expand Down
4 changes: 3 additions & 1 deletion layouts/_default/list.typesense.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- $.Scratch.Add "index" slice -}}
{{- $section := $.Site.GetPage "section" .Section -}}
{{- range .Site.AllPages -}}
{{- if eq .Section $section.Section -}}
{{- if or (and (.IsDescendant $section) (and (not .Draft) (and (not .Params.private) (not .Params.empty_node)))) $section.IsHome -}}
{{- if eq .Section "tutorials" -}}
{{- if or (eq .Section "tutorials") (and (eq .Section "get-started") (eq .Parent.LinkTitle "Quickstarts")) -}}
{{- $.Scratch.Set "latestDate" .Date.UTC.Unix -}}
{{- if .Params.updated -}}
{{- $.Scratch.Set "latestDate" ((time .Params.updated).UTC.Unix) -}}
Expand Down Expand Up @@ -197,4 +198,5 @@
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}

0 comments on commit b1c4c93

Please sign in to comment.