Skip to content

Commit 004e680

Browse files
Merge pull request #289 from max-svistunov/ols-1651-portal-docs-fetcher
OLS-1651 Add script for fetching OpenShift documentation in the HTML format
2 parents f8cf6bb + 83c508b commit 004e680

File tree

7 files changed

+1380
-16
lines changed

7 files changed

+1380
-16
lines changed

pdm.lock.cpu

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdm.lock.gpu

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ dependencies = [
5353
"llama-index-embeddings-huggingface",
5454
"llama-index-readers-file",
5555
"faiss-cpu",
56+
"aiohttp>=3.8.0",
57+
"beautifulsoup4>=4.10.0",
5658
]
5759
requires-python = "==3.11.*"
5860
readme = "README.md"

scripts/asciidoctor-text/convert-it-all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def process_node(node: dict, distro: str, dir: str = "", file_list: list = []) -
6464
attributes = os.path.normpath(os.path.join(os.getcwd(), args.attributes))
6565
with open(attributes, "r") as fin:
6666
attributes = yaml.safe_load(fin)
67-
for key, value in attributes.items():
67+
for key, value in attributes.items(): # type: ignore
6868
attribute_list = [*attribute_list, "-a", key + "=%s" % value]
6969

7070
topic_map = os.path.normpath(os.path.join(os.getcwd(), args.topic_map))

scripts/generate_packages_to_prefetch.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,30 @@
4646
BUILDDEPS_SCRIPT_NAME = "pip_find_builddeps.py"
4747

4848

49-
def shell(command, directory):
49+
def shell(command: str, directory: str) -> bytes:
5050
"""Run command via shell inside specified directory."""
5151
return subprocess.check_output(command, cwd=directory, shell=True) # noqa: S602
5252

5353

54-
def copy_project_stub(directory):
54+
def copy_project_stub(directory: str) -> None:
5555
"""Copy all files that represent project stub into specified directory."""
5656
for project_file in PROJECT_FILES:
5757
shutil.copy(project_file, directory)
5858

5959

60-
def remove_torch_dependency(directory):
60+
def remove_torch_dependency(directory: str) -> None:
6161
"""Remove torch (specifically torch+cpu) dependency from the project.toml file."""
6262
shell("pdm remove torch", directory)
6363

6464

65-
def generate_requirements_file(work_directory):
65+
def generate_requirements_file(work_directory: str) -> None:
6666
"""Generate file requirements.txt that contains hashes for all packages."""
6767
shell("pip-compile -vv pyproject.toml --generate-hashes", work_directory)
6868

6969

70-
def remove_package(directory, source, target, package_prefix):
70+
def remove_package(
71+
directory: str, source: str, target: str, package_prefix: str
72+
) -> None:
7173
"""Remove package or packages with specified prefix from the requirements file."""
7274
package_block = False
7375

@@ -86,7 +88,7 @@ def remove_package(directory, source, target, package_prefix):
8688
fout.write(line)
8789

8890

89-
def remove_unwanted_dependencies(directory):
91+
def remove_unwanted_dependencies(directory: str) -> None:
9092
"""Remove all unwanted dependencies from requirements file, creating in-between files."""
9193
# the torch itself
9294
remove_package(directory, "requirements.txt", "step1.txt", "torch")
@@ -95,19 +97,19 @@ def remove_unwanted_dependencies(directory):
9597
remove_package(directory, "step1.txt", "step2.txt", "nvidia")
9698

9799

98-
def wheel_url(registry, wheel):
100+
def wheel_url(registry: str, wheel: str) -> str:
99101
"""Construct full URL to wheel."""
100102
return f"{registry}/{wheel}"
101103

102104

103-
def download_wheel(directory, registry, wheel):
105+
def download_wheel(directory: str, registry: str, wheel: str) -> None:
104106
"""Download selected wheel from registry."""
105107
url = wheel_url(registry, wheel)
106108
into = join(directory, wheel)
107109
urlretrieve(url, into) # noqa: S310
108110

109111

110-
def generate_hash(directory, registry, wheel, target):
112+
def generate_hash(directory: str, registry: str, wheel: str, target: str) -> None:
111113
"""Generate hash entry for given wheel."""
112114
output = shell(f"pip hash {wheel}", directory)
113115
hash_line = output.decode("ascii").splitlines()[1]
@@ -117,7 +119,7 @@ def generate_hash(directory, registry, wheel, target):
117119
fout.write(f" {hash_line}\n")
118120

119121

120-
def generate_list_of_packages(work_directory):
122+
def generate_list_of_packages(work_directory: str) -> None:
121123
"""Generate list of packages, take care of unwanted packages and wheel with Torch package."""
122124
copy_project_stub(work_directory)
123125
if PROCESS_SPECIAL_PACKAGES:
@@ -135,7 +137,7 @@ def generate_list_of_packages(work_directory):
135137
shutil.copy(join(work_directory, "requirements.txt"), "requirements.txt")
136138

137139

138-
def generate_packages_to_be_build(work_directory):
140+
def generate_packages_to_be_build(work_directory: str) -> None:
139141
"""Generate list of packages that will need to be build."""
140142
# download helper script to generate list of packages
141143
url = f"{CACHITO_URL}/{BUILDDEPS_SCRIPT_PATH}/{BUILDDEPS_SCRIPT_NAME}"

0 commit comments

Comments
 (0)