Skip to content

Commit

Permalink
Merge pull request #875 from uglide/add_lettuce_examples
Browse files Browse the repository at this point in the history
Add infra for lettuce examples
  • Loading branch information
andy-stark-redis authored Nov 21, 2024
2 parents 317329f + 123f843 commit 25cfd40
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 15 deletions.
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",
"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",
"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

0 comments on commit 25cfd40

Please sign in to comment.