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

Add infra for lettuce examples #875

Merged
merged 3 commits into from
Nov 21, 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
21 changes: 15 additions & 6 deletions build/components/component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
import glob
import os
import shutil

import semver
import uuid
from typing import Tuple
Expand Down Expand Up @@ -514,13 +516,20 @@ def _copy_examples(self):
if not example_id:
continue

example_metadata = {'source': f}
example_metadata = {
'source': f,
'language': self.get('language').lower()
}

base_path = os.path.join(dst, example_id)
mkdir_p(base_path)
rsync(example_metadata['source'], base_path)

mkdir_p(f'{dst}/{example_id}')
rsync(example_metadata['source'], f'{dst}/{example_id}/')
target_path = os.path.join(base_path, f'{self.get("id")}_{os.path.basename(f)}')
shutil.move(os.path.join(base_path, os.path.basename(f)), target_path)

example_metadata['target'] = f'{dst}/{example_id}/{os.path.basename(f)}'
e = Example(self.get('language'), example_metadata['target'])
example_metadata['target'] = target_path
e = Example(self.get('language'), target_path)
example_metadata['highlight'] = e.highlight
example_metadata['hidden'] = e.hidden
example_metadata['named_steps'] = e.named_steps
Expand All @@ -532,7 +541,7 @@ def _copy_examples(self):
examples[example_id] = {}

logging.info(f'Example {example_id} processed successfully.')
examples[example_id][self.get('language')] = example_metadata
examples[example_id][self.get('label')] = example_metadata

def apply(self) -> None:
logging.info(f'Applying client {self._id}')
Expand Down
16 changes: 9 additions & 7 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tagManagerId = "GTM-TKZ6J9R"
gitHubRepo = "https://github.com/redis/docs"

# Display and sort order for client examples
clientsExamples = ["Python", "Node.js", "Java", "Go", "C#", "RedisVL"]
clientsExamples = ["Python", "Node.js", "Java Sync", "Java Async", "Java Reactive", "Go", "C#", "RedisVL"]
searchService = "/convai/api/search-service"
ratingsService = "/docusight/api/rate"

Expand All @@ -57,12 +57,14 @@ rdi_db_types = "cassandra|mysql|oracle|postgresql|sqlserver"
rdi_cli_latest = "latest"

[params.clientsConfig]
"Python"={lang="python", quickstartSlug="python/redis-py"}
"Node.js"={lang="javascript", quickstartSlug="nodejs"}
"Java"={lang="java", quickstartSlug="java/jedis"}
"Go"={lang="go", quickstartSlug="go"}
"C#"={lang="C#", quickstartSlug="dotnet"}
"RedisVL"={lang="python", quickstartSlug="python/redis-vl"}
"Python"={quickstartSlug="redis-py"}
"Node.js"={quickstartSlug="nodejs"}
"Java sync"={quickstartSlug="jedis"}
"Java async"={quickstartSlug="lettuce"}
"Java reactive"={quickstartSlug="lettuce"}
"Go"={quickstartSlug="go"}
"C#"={quickstartSlug="dotnet"}
"RedisVL"={quickstartSlug="redis-vl"}

# Markup
[markup]
Expand Down
1 change: 1 addition & 0 deletions data/components/go_redis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "client",
"name": "go-redis",
"language": "Go",
"label": "Go",
"repository": {
"git_uri": "https://github.com/redis/go-redis"
},
Expand Down
2 changes: 2 additions & 0 deletions data/components/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"node_redis",
"redis_py",
"jedis",
"lettuce_async",
"lettuce_reactive",
"redis_vl"
],
"assets": [],
Expand Down
1 change: 1 addition & 0 deletions data/components/jedis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "client",
"name": "jedis",
"language": "Java",
"label": "Java Sync",
"repository": {
"git_uri": "https://github.com/redis/jedis"
},
Expand Down
16 changes: 16 additions & 0 deletions data/components/lettuce_async.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "lettuce_async",
"type": "client",
"name": "lettuce_async",
"language": "Java",
"label": "Java Async",
"repository": {
"git_uri": "https://github.com/redis/lettuce"
},
"examples": {
"git_uri": "https://github.com/redis/lettuce",
"dev_branch": "doctests",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to have the examples folder in the main branch? We've tried to do that with the other client libs so that errors against the latest build can be spotted quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the doctests branch just to make changes to the docs testable. As soon as the PR in lettuce is merged, it can be pointed to the main branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's excellent, thanks. Great idea :-)

"path": "src/test/java/io/redis/examples/async",
"pattern": "*.java"
}
}
16 changes: 16 additions & 0 deletions data/components/lettuce_reactive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "lettuce_reactive",
"type": "client",
"name": "lettuce_reactive",
"language": "Java",
"label": "Java Reactive",
"repository": {
"git_uri": "https://github.com/redis/lettuce"
},
"examples": {
"git_uri": "https://github.com/redis/lettuce",
"dev_branch": "doctests",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for async above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my reply above. Thanks

"path": "src/test/java/io/redis/examples/reactive",
"pattern": "*.java"
}
}
1 change: 1 addition & 0 deletions data/components/node_redis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "client",
"name": "node-redis",
"language": "Node.js",
"label": "Node.js",
"repository": {
"git_uri": "https://github.com/redis/node-redis"
},
Expand Down
1 change: 1 addition & 0 deletions data/components/nredisstack.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "client",
"name": "NRedisStack",
"language": "C#",
"label": "C#",
"repository": {
"git_uri": "https://github.com/redis/NRedisStack"
},
Expand Down
1 change: 1 addition & 0 deletions data/components/redis_py.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "client",
"name": "redis-py",
"language": "Python",
"label": "Python",
"repository": {
"git_uri": "https://github.com/redis/redis-py"
},
Expand Down
3 changes: 2 additions & 1 deletion data/components/redis_vl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"id": "redisvl",
"type": "client",
"name": "RedisVL",
"language": "RedisVL",
"language": "Python",
"label": "RedisVL",
"repository": {
"git_uri": "https://github.com/redis/redis-vl-python"
},
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/tabbed-clients-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{ range $client := $.Site.Params.clientsexamples }}
{{ $example := index $clientExamples $client }}
{{ $clientConfig := index $.Site.Params.clientsconfig $client }}
{{ $language := index $clientConfig "lang" }}
{{ $language := index $example "language" }}
{{ $quickstartSlug := index $clientConfig "quickstartSlug" }}

{{ if and ($example) (or (eq $lang "") (eq $lang $client)) }}
Expand Down