Skip to content
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

Arnej/add Lab 101 hints #1584

Merged
merged 6 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions examples/training-artifacts/101/ch1/actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
actions to take at the start of training:

- ensure you're able to login using a google
or github account on https://console.vespa-cloud.com/

- You do not need to create your own "tenant"
(the organization / billing entity in vespa cloud);
if you contact Radu he will give you access to the
"training1" tenant.

- we'll assume you have installed standard developer tools:
* git
* curl
- also recommended:
* jq

- ensure you have the "vespa" CLI tool installed:
https://github.com/vespa-engine/vespa/releases/tag/v8.447.14

vespa auth login
vespa auth show
vespa config set target cloud
# replace "myusername" with your user name
vespa config set application training1.myusername-test1

git clone https://github.com/vespa-engine/sample-apps.git
cd sample-apps/examples/training-artifacts/101/ch1
# you are "here"
cd ecommerce
vespa auth cert
vespa deploy --wait 900
cd ..
vespa document put f1f2-doc.json
vespa document get id:ecommerce:product::1
vespa visit
vespa query "yql=select * from product where true"
vespa query "yql=select * from product where true" | jq ".root.children"
vespa document remove id:ecommerce:product::1

- if you want to see usage of the underlying REST api, try these:
vespa document -v put f1f2-doc.json
vespa document -v get id:ecommerce:product::1
vespa query -v "yql=select field1 from product where true"
vespa document -v remove id:ecommerce:product::1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<validation-overrides>
<allow until='2024-12-15'>indexing-change</allow>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't provide a validation-overrides because I thought this is a common problem people bump into and they'll "discover" how to do it.

But your change might just remove some unnecessary boilerplate, so +1. It's just that we might need to refresh these. Any better ideas than Slack reminders? :)

<allow until='2024-12-15'>schema-removal</allow>
</validation-overrides>
1 change: 1 addition & 0 deletions examples/training-artifacts/101/ch1/f1f2-doc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "id:ecommerce:product::1", "fields": {"field1": "foo", "field2": "and bar"}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<validation-overrides>
<!-- <allow until='2024-09-20'>indexing-change</allow> -->
</validation-overrides>
<allow until='2024-12-15'>indexing-change</allow>
<allow until='2024-12-15'>schema-removal</allow>
</validation-overrides>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<validation-overrides>
<allow until='2024-12-15'>indexing-change</allow>
<allow until='2024-12-15'>schema-removal</allow>
</validation-overrides>
70 changes: 70 additions & 0 deletions examples/training-artifacts/101/ch3/queries.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### group by item. Show first 3
vespa query "yql=select * from purchase where true | all(
group(item)
max(3)
each(
output(count())
)
)"

vespa query "yql=select * from purchase where true limit 0 | all(
group(item)
order(-count())
max(3)
each(
output(count() as(count_per_item))
)
)"

### use total $$$ instead of count. But output count as well
vespa query "yql=select * from purchase where true limit 0 | all(
group(item)
order(-sum(price))
each(
output(sum(price) as(revenue))
output(count())
)
)"

### sales by day
vespa query "yql=select * from purchase where true limit 0 | all(
group(
time.date(date)
)
each(
output(sum(price) as(revenue_per_day))
output(count())
)
)" | jq ".root.children[].children[].children[]"

### sales by day, by item
vespa query "yql=select * from purchase where true limit 0 | all(
group(time.date(date))
each(
output(sum(price) as(revenue_per_day))
output(count())
all(
group(item)
order(-sum(price))
each(
output(sum(price) as(revenue_per_item_per_day))
output(count())
)
)
)
)" | jq ".root.children[].children[].children[]"


### top items, but also show 3 sample orders
vespa query "yql=select * from purchase where true limit 0 | all(
group(item)
order(-sum(price))
each(
output(sum(price) as(revenue))
output(count())
max(3)
each(
output(summary())
)
)
)"
9 changes: 5 additions & 4 deletions examples/training-artifacts/101/ch3/queries.http
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ curl -H "Content-Type:application/json" https://ebe5e25b.d78af55d.z.vespa-app.cl
time.date(date)
)
each(
output(sum(price))
output(sum(price) as(revenue))
output(count())
)
)"
Expand All @@ -56,7 +56,7 @@ curl -H "Content-Type:application/json" https://ebe5e25b.d78af55d.z.vespa-app.cl
"yql": "select * from purchase where true | all(
group(time.date(date))
each(
output(-sum(price))
output(sum(price))
output(count())

# within each bucket, take all orders
Expand All @@ -67,7 +67,7 @@ curl -H "Content-Type:application/json" https://ebe5e25b.d78af55d.z.vespa-app.cl
# order by revenue descending, like we did before
order(-sum(price))
each(
output(sum(price))
output(sum(price) as(revenue_per_item_per_day))
output(count())
)
)
Expand Down Expand Up @@ -102,5 +102,6 @@ curl -H "Content-Type:application/json" https://ebe5e25b.d78af55d.z.vespa-app.cl
"yql": "select * from purchase where true | all(
group(item)
output(count())
output(max(price))
)"
}'
}'
56 changes: 56 additions & 0 deletions examples/training-artifacts/101/ch4/query-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"yql": "select * from product where —--->WHERE QUERY CLAUSE GOES HERE <—-----",
"presentation.summary": "medium",
"ranking.profile": "closeness",
"approximate_query_string": "Face Painting Stencil - QuickEZ/Gears #34",
"input.query(q_embedding)": [
0.015, 0.024, 0.046, -0.019, -0.036, -0.023, -0.027, -0.093,
-0.053, 0.055, -0.012, 0.082, 0.024, 0.023, 0.024, -0.038,
0.037, -0.048, -0.1, -0.037, -0.045, 0.033, 0.023, -0.002,
-0.024, -0.035, -0.021, -0.032, -0.097, -0.187, -0.003,
0.044, -0.019, -0.021, 0.022, -0.026, 0.002, 0.048, 0.006,
-0.041, 0.007, 0.062, -0.045, 0.019, 0.057, -0.027, 0.036,
0.0, 0.052, 0.027, 0.0, -0.006, -0.007, -0.032, -0.064, 0.12,
-0.036, -0.004, 0.026, 0.054, -0.037, 0.062, -0.339, -0.007,
0.05, 0.024, 0.015, -0.009, -0.082, 0.018, 0.038, -0.019,
-0.077, 0.028, 0.06, -0.016, 0.015, -0.02, 0.003, -0.087,
-0.045, 0.052, -0.023, -0.017, -0.019, 0.033, -0.041, -0.056,
0.006, -0.011, -0.028, -0.02, -0.023, -0.009, -0.054, 0.054,
-0.014, 0.004, 0.062, 0.283, 0.035, 0.038, 0.09, -0.042,
0.035, 0.012, -0.02, 0.036, -0.023, -0.011, -0.037, 0.008,
-0.072, 0.044, 0.056, 0.029, -0.035, -0.045, 0.026, 0.079,
-0.056, 0.022, -0.052, 0.007, -0.02, -0.013, -0.059, 0.059,
-0.001, 0.02, 0.016, 0.058, -0.053, 0.003, -0.025, -0.002,
0.052, -0.036, -0.017, 0.019, -0.007, -0.046, 0.154, -0.011,
0.054, 0.046, 0.025, -0.0, -0.035, -0.059, 0.017, -0.002,
0.036, 0.059, 0.073, -0.02, -0.05, -0.034, -0.029, 0.001,
0.042, -0.024, 0.074, 0.149, 0.033, 0.004, 0.064, 0.011,
0.072, -0.004, -0.028, 0.001, 0.037, 0.018, -0.025, 0.029,
-0.015, 0.015, 0.035, -0.043, 0.018, 0.039, -0.05, -0.031,
-0.025, 0.039, -0.058, 0.015, 0.018, 0.104, -0.025, 0.099,
-0.097, 0.021, 0.036, 0.055, 0.04, 0.02, 0.008, -0.014,
-0.011, -0.033, 0.046, -0.05, 0.004, -0.014, 0.007, 0.026,
-0.024, -0.036, 0.011, -0.042, 0.044, 0.029, 0.032, 0.036,
0.071, 0.017, 0.053, 0.061, 0.024, 0.006, -0.104, -0.065,
0.03, 0.02, -0.015, -0.013, -0.014, -0.034, 0.073, 0.029,
0.016, 0.033, 0.047, -0.009, -0.045, 0.011, -0.011, -0.034,
0.053, 0.007, -0.058, 0.017, 0.029, -0.07, 0.0, -0.059,
-0.008, 0.121, -0.004, -0.03, 0.078, 0.04, -0.048, -0.005,
-0.147, 0.0, -0.058, 0.092, -0.051, -0.028, 0.007, -0.015,
-0.046, -0.06, -0.06, -0.007, -0.066, -0.001, 0.039, 0.049,
0.044, 0.012, 0.046, 0.007, 0.008, 0.039, -0.093, 0.01,
-0.002, -0.025, -0.01, 0.055, -0.032, 0.013, -0.049, 0.01,
0.02, -0.038, -0.016, -0.06, 0.036, -0.0, 0.114, -0.011,
0.045, 0.028, -0.023, 0.004, -0.057, 0.019, -0.016, -0.002,
-0.103, -0.027, -0.017, 0.026, -0.028, 0.004, -0.005, -0.004,
0.018, 0.052, 0.029, -0.061, 0.01, 0.069, 0.008, -0.158,
-0.055, 0.075, 0.01, -0.013, -0.042, 0.081, -0.053, 0.024,
-0.033, 0.088, 0.044, 0.014, 0.015, 0.014, 0.047, 0.008,
0.037, -0.02, -0.108, 0.001, 0.01, 0.11, -0.014, 0.03, 0.0,
-0.016, -0.08, -0.073, 0.006, 0.01, -0.039, 0.064, -0.024,
0.002, 0.127, 0.029, -0.05, 0.031, -0.01, 0.082, 0.004,
0.015, -0.029, 0.017, -0.005, -0.007, 0.022, -0.043, -0.004,
0.041, -0.004, -0.018, 0.018, -0.0, -0.012, 0.035, 0.001,
-0.053, 0.064, -0.019, 0.011, -0.02, -0.097, -0.032
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<validation-overrides>
<allow until='2024-12-15'>indexing-change</allow>
<allow until='2024-12-15'>schema-removal</allow>
</validation-overrides>