Skip to content

Commit 5d5a380

Browse files
Merge pull request #1414 from redis/DOC-5093-rdi-image-update
DOC-5093 RDI image update
2 parents a94b032 + 29eb4d9 commit 5d5a380

17 files changed

+228
-10
lines changed

build/image_report.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Image report
2+
"""
3+
4+
from pylibs.hugotools import ShortcodeIterator
5+
6+
import argparse
7+
import os
8+
9+
10+
def scan_file(path: str) -> int:
11+
"""Scans a file for all `image` shortcodes.
12+
13+
Args:
14+
path (str): Path to file.
15+
16+
Returns:
17+
(int) Number of shortcodes found.
18+
"""
19+
20+
img_list = []
21+
22+
with open(path, encoding="utf_8") as md_file:
23+
text = md_file.read()
24+
25+
for img, pos_info in ShortcodeIterator(
26+
text, lambda t: t.tag == "image"
27+
):
28+
img_list.append((img, pos_info))
29+
30+
if len(img_list) > 0:
31+
print(f"File '{path}':")
32+
33+
for img in img_list:
34+
print(
35+
f" Line {img[1].line}: '{img[0].named_params['filename']}'"
36+
)
37+
38+
return len(img_list)
39+
40+
41+
parser = argparse.ArgumentParser(
42+
"Image report",
43+
"Scans a folder and report all Hugo image shortcodes found"
44+
)
45+
46+
parser.add_argument("pathname", help="Path of the folder to scan")
47+
48+
args = parser.parse_args()
49+
50+
print(f"Scanning '{args.pathname}'")
51+
52+
num_found = 0
53+
54+
for root, dirs, files in os.walk(args.pathname):
55+
for file in files:
56+
if file.endswith(".md"):
57+
fullpath = os.path.join(root, file)
58+
num_found += scan_file(fullpath)
59+
60+
if num_found == 0:
61+
print(f"No image shortcodes found in '{args.pathname}'")
62+
else:
63+
print(f"Found {num_found} image shortcodes.")

build/pylibs/hugotools.py

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
from enum import Enum
2+
from typing import Iterator, Match, Callable
3+
4+
import re
5+
6+
7+
class TextPosInfo:
8+
line: int
9+
start: int
10+
end: int
11+
12+
def __init__(self, line, start, end):
13+
self.line = line
14+
self.start = start
15+
self.end = end
16+
17+
18+
shortcode_re_pattern_start = r"(\n)|\{\{[<%]\s*"
19+
shortcode_re_body = r"(/)?([\w\-]+)\s*(.+?)?"
20+
shortcode_re_pattern_end = r"\s*[>%]\}\}"
21+
22+
shortcode_re_pattern = (
23+
shortcode_re_pattern_start +
24+
shortcode_re_body +
25+
shortcode_re_pattern_end
26+
)
27+
28+
29+
class ShortcodeTagType(Enum):
30+
"""Specifies open or close shortcode tag."""
31+
OPEN = 1
32+
CLOSE = 2
33+
34+
35+
class ShortcodeInfo:
36+
"""Represents the information in a shortcode.
37+
"""
38+
tag_type: ShortcodeTagType
39+
tag: str
40+
pos_params: list[str]
41+
named_params: dict[str, str]
42+
43+
def parse_params(self, param_str: str):
44+
param_re = "|".join([
45+
r'"(([^"]|(?<=\\)")*)"',
46+
r'((\w+)=([^"\s]+))',
47+
r'((\w+)="(([^"]|(?<=\\)")*)")',
48+
r'([^"=\s]+)'
49+
])
50+
51+
for match in re.finditer(param_re, param_str):
52+
if match is None:
53+
self.pos_params = []
54+
self.named_params = {}
55+
return
56+
57+
if match[1]:
58+
self.pos_params.append(re.sub(r'\\"', '"', match[1]))
59+
elif match[3]:
60+
self.named_params[match[4]] = match[5]
61+
elif match[6]:
62+
self.named_params[match[7]] = re.sub(r'\\"', '"', match[8])
63+
elif match[10]:
64+
self.pos_params.append(match[10])
65+
66+
def __init__(
67+
self, tag: str,
68+
tag_type: ShortcodeTagType,
69+
param_text: str = ""
70+
):
71+
self.tag = tag
72+
self.tag_type = tag_type
73+
self.pos_params = []
74+
self.named_params = {}
75+
self.parse_params(param_text or "")
76+
77+
def __str__(self) -> str:
78+
type_text: str
79+
80+
if self.tag_type == ShortcodeTagType.OPEN:
81+
type_text = "OPEN"
82+
else:
83+
type_text = "CLOSE"
84+
85+
result = f"{type_text} {self.tag}"
86+
87+
if self.pos_params or self.named_params:
88+
result += ":"
89+
90+
for pos_param in self.pos_params:
91+
result += f"\n '{pos_param}'"
92+
93+
for named_param, named_value in self.named_params.items():
94+
result += f"\n {named_param} = {named_value}"
95+
96+
return result
97+
98+
99+
class ShortcodeIterator:
100+
"""Iterates through all shortcodes in a string.
101+
"""
102+
re_iterator: Iterator[Match[str]]
103+
linenum: int
104+
sc_filter: Callable[[ShortcodeInfo], bool]
105+
106+
def __init__(
107+
self,
108+
text: str,
109+
sc_filter: Callable[[ShortcodeInfo], bool] = lambda x: True
110+
):
111+
self.re_iterator = re.finditer(shortcode_re_pattern, text)
112+
self.sc_filter = lambda self, x: sc_filter(x)
113+
self.linenum = 1
114+
115+
def __iter__(self):
116+
return self
117+
118+
def __next__(self) -> tuple[ShortcodeInfo, TextPosInfo]:
119+
next_match = self.re_iterator.__next__()
120+
121+
while True:
122+
if next_match[1]:
123+
self.linenum += 1
124+
elif next_match[2]:
125+
result = ShortcodeInfo(
126+
next_match[3], ShortcodeTagType.CLOSE
127+
)
128+
129+
if self.sc_filter(self, result):
130+
return (
131+
result,
132+
TextPosInfo(
133+
self.linenum,
134+
next_match.start(),
135+
next_match.end()
136+
)
137+
)
138+
else:
139+
result = ShortcodeInfo(
140+
next_match[3],
141+
ShortcodeTagType.OPEN,
142+
next_match[4]
143+
)
144+
145+
if self.sc_filter(self, result):
146+
return (
147+
result,
148+
TextPosInfo(
149+
self.linenum,
150+
next_match.start(),
151+
next_match.end()
152+
)
153+
)
154+
155+
next_match = self.re_iterator.__next__()

content/integrate/redis-data-integration/architecture.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ outside the Redis
5555
Enterprise cluster where the target database is kept. However, RDI keeps
5656
its state and configuration data and also the change data streams in a Redis database on the same cluster as the target. The following diagram shows the pipeline steps and the path the data takes on its way from the source to the target:
5757

58-
{{< image filename="images/rdi/ingest/ingest-dataflow.png" >}}
58+
{{< image filename="images/rdi/ingest/ingest-dataflow.webp" >}}
5959

6060
When you first start RDI, the target database is empty and so all
6161
of the data in the source database is essentially "change" data.
@@ -111,7 +111,7 @@ and to deploy and manage a pipeline. Use the pipeline editor
111111
diagram below shows the components of the control and management
112112
planes and the connections between them:
113113

114-
{{< image filename="images/rdi/ingest/ingest-control-plane.png" >}}
114+
{{< image filename="images/rdi/ingest/ingest-control-plane.webp" >}}
115115

116116
The following sections describe the VM configurations you can use to
117117
deploy RDI.
@@ -124,7 +124,7 @@ Both the active VM and the standby
124124
need access to the authentication secrets that RDI uses to encrypt network
125125
traffic. The diagram below shows this configuration:
126126

127-
{{< image filename="images/rdi/ingest/ingest-active-passive-vms.png" >}}
127+
{{< image filename="images/rdi/ingest/ingest-active-passive-vms.webp" >}}
128128

129129
See [Install on VMs]({{< relref "/integrate/redis-data-integration/installation/install-vm" >}})
130130
for more information.

content/integrate/redis-data-integration/data-pipelines/data-denormalization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ parent object (the "one") as a JSON document with the children (the "many") nest
3333
attribute in the parent. The diagram belows shows a nesting with the child objects in a map
3434
called `InvoiceLineItems`:
3535

36-
{{< image filename="/images/rdi/nest-flow.png" >}}
36+
{{< image filename="/images/rdi/ingest/nest-flow.webp" width="500px" >}}
3737

3838
You configure normalization with a `nest` block in the child entities' RDI job, as shown in this example:
3939

content/integrate/redis-data-integration/data-pipelines/data-pipelines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ data in Redis as
4848

4949
The diagram below shows the flow of data through the pipeline:
5050

51-
{{< image filename="/images/rdi/RDIPipeDataflow.drawio.svg" >}}
51+
{{< image filename="/images/rdi/ingest/RDIPipeDataflow.webp" >}}
5252

5353
## Pipeline configuration
5454

5555
RDI uses a set of [YAML](https://en.wikipedia.org/wiki/YAML)
5656
files to configure each pipeline. The following diagram shows the folder
5757
structure of the configuration:
5858

59-
{{< image filename="images/rdi/ingest/ingest-config-folders.svg" >}}
59+
{{< image filename="images/rdi/ingest/ingest-config-folders.webp" width="600px" >}}
6060

6161
The main configuration for the pipeline is in the `config.yaml` file.
6262
This specifies the connection details for the source database (such

content/integrate/redis-data-integration/data-pipelines/prepare-dbs/aws-aur-pgsql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In the [Relational Database Service (RDS) console](https://console.aws.amazon.co
2626
navigate to **Parameter groups > Create parameter group**. You will see the panel shown
2727
below:
2828

29-
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/CreateParamGroup.jpg" alt="Create parameter group panel" >}}
29+
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/CreateParamGroup.webp" alt="Create parameter group panel" >}}
3030

3131
Enter the following information:
3232

@@ -45,7 +45,7 @@ Select **Create** to create the parameter group.
4545
Navigate to **Parameter groups** in the console. Select the `rdi-aurora-pg`
4646
group you have just created and then select **Edit** . You will see this panel:
4747

48-
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/EditParamGroup.jpg" alt="Edit parameter group panel" >}}
48+
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/EditParamGroup.webp" alt="Edit parameter group panel" >}}
4949

5050
Search for the `rds.logical_replication` parameter and set its value to 1. Then,
5151
select **Save Changes**.
@@ -56,4 +56,4 @@ Go back to your target database on the RDS console, select **Modify** and then
5656
scroll down to **Additional Configuration**. Set
5757
the **DB Cluster Parameter Group** to the value `rdi-aurora-pg` that you have just added:
5858

59-
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/CreateDB6.jpg" alt="Additional Configuration panel" >}}
59+
{{<image filename="images/rdi/ingest/prepsrc/aurora-pgsql/CreateDB6.webp" alt="Additional Configuration panel" >}}

content/integrate/redis-data-integration/quick-start-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In this tutorial you will learn how to install RDI and set up a pipeline to inge
2626
The following diagram shows the structure of the pipeline we will create (see
2727
the [architecture overview]({{< relref "/integrate/redis-data-integration/architecture#overview" >}}) to learn how the pipeline works):
2828

29-
{{< image filename="images/rdi/ingest/ingest-qsg.png" >}}
29+
{{< image filename="images/rdi/ingest/ingest-qsg.webp" >}}
3030

3131
Here, the RDI *collector* tracks changes in PostgreSQL and writes them to streams in the
3232
RDI database in Redis. The *stream processor* then reads data records from the RDI
23.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)