Skip to content

Commit ddd1720

Browse files
authored
translate introduction to english and option for name_prefix in generator (#4657)
1 parent 3505562 commit ddd1720

File tree

2 files changed

+43
-50
lines changed

2 files changed

+43
-50
lines changed

ydb/tests/olap/docs/generator/__main__.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,18 @@
1212
from optparse import OptionParser
1313

1414

15-
NAME_PREFIX = 'ydb.tests.olap.'
16-
FILE_NAME_PREFIX = '/'.join(NAME_PREFIX.split('.'))
17-
18-
1915
class ModulePrinter:
2016
def __init__(self, options, module: types.ModuleType) -> None:
2117
self._options = options
2218
self._module = module
2319
self._output = None
2420

25-
@staticmethod
26-
def _get_anchor(obj: any, with_module: bool) -> str | None:
21+
def _get_anchor(self, obj: any, with_module: bool) -> str | None:
2722
def _is_interest_module(module_name: str) -> bool:
28-
return module_name.startswith(NAME_PREFIX)
23+
return module_name.startswith(self._options.name_prefix)
2924

3025
def _get_module_anchor(module_name: str) -> str:
31-
return f'./{ModulePrinter._get_stricted_name(module_name)}.md' if with_module else ''
26+
return f'./{self._get_stricted_name(module_name)}.md' if with_module else ''
3227

3328
if inspect.ismodule(obj) and _is_interest_module(obj.__name__):
3429
return _get_module_anchor(obj.__name__)
@@ -38,13 +33,11 @@ def _get_module_anchor(module_name: str) -> str:
3833
return f'{_get_module_anchor(obj.__module__)}#{obj.__qualname__.replace("_", "")}'
3934
return None
4035

41-
@staticmethod
42-
def _get_docs_link(obj: any, link_text: str, no_link_text: str | None = None) -> str:
43-
link = ModulePrinter._get_anchor(obj, with_module=True)
36+
def _get_docs_link(self, obj: any, link_text: str, no_link_text: str | None = None) -> str:
37+
link = self._get_anchor(obj, with_module=True)
4438
return f'[{link_text}]({link})' if link is not None else no_link_text
4539

46-
@staticmethod
47-
def get_doc(obj) -> dict:
40+
def get_doc(self, obj) -> dict:
4841
def _subst_links(descr: str) -> str:
4942
if isinstance(obj, type):
5043
# class
@@ -66,13 +59,13 @@ def _subst_links(descr: str) -> str:
6659
if module is None:
6760
try:
6861
evaluted = eval(name, obj_globals, obj_locals)
69-
link = ModulePrinter._get_docs_link(evaluted, '{#T}', name)
62+
link = self._get_docs_link(evaluted, '{#T}', name)
7063
except BaseException as e:
7164
error(f'cannot evalute {name}: {e}')
7265
link = name
7366
else:
74-
name = ModulePrinter._get_stricted_name(name)
75-
link = ModulePrinter._get_docs_link(module, '{#T}', name)
67+
name = self._get_stricted_name(name)
68+
link = self._get_docs_link(module, '{#T}', name)
7669
tmp.append((start, end, link))
7770
for start, end, link in reversed(tmp):
7871
descr = descr[:start] + link + descr[end:]
@@ -172,7 +165,7 @@ def print_class(self, cl: type, level: int):
172165
subclasses = self.get_subclasses(cl)
173166
functions = self.get_functions(cl)
174167
self.print_toc(subclasses, functions)
175-
if cl.__base__ is not None and cl.__base__.__module__.startswith(NAME_PREFIX):
168+
if cl.__base__ is not None and cl.__base__.__module__.startswith(self._options.name_prefix):
176169
self.print_header('Inherits', 6)
177170
self._output.write(f'{self._get_docs_link(cl.__base__, "{#T}", f"{cl.__base__.__module__}.{cl.__base__.__qualname__}")}\n')
178171
doc = self.get_doc(cl)
@@ -246,18 +239,17 @@ def _get_link(a: any) -> str:
246239
self._output.write(f'{ann_str}{ret_descr}\n')
247240
self.print_examples(doc)
248241

249-
@staticmethod
250-
def _get_stricted_name(module: types.ModuleType | str) -> str:
242+
def _get_stricted_name(self, module: types.ModuleType | str) -> str:
251243
if isinstance(module, types.ModuleType):
252-
return ModulePrinter._get_stricted_name(module.__name__)
253-
if module.startswith(NAME_PREFIX):
254-
return module[len(NAME_PREFIX) :]
244+
return self._get_stricted_name(module.__name__)
245+
if module.startswith(self._options.name_prefix):
246+
return module[len(self._options.name_prefix) :]
255247
return module
256248

257249
def print_module(self) -> None:
258250
name = self._get_stricted_name(self._module)
259251
submodules = inspect.getmembers(
260-
self._module, lambda x: inspect.ismodule(x) and inspect.getfile(x).startswith(FILE_NAME_PREFIX)
252+
self._module, lambda x: inspect.ismodule(x) and x.__name__.startswith(self._options.name_prefix)
261253
)
262254
subclasses = self.get_subclasses(self._module, lambda x: inspect.getmodule(x) == self._module)
263255
functions = self.get_functions(self._module, lambda x: inspect.getmodule(x) == self._module)
@@ -276,7 +268,7 @@ def print_module(self) -> None:
276268
def generate_toc(self):
277269
name = self._get_stricted_name(self._module)
278270
submodules = inspect.getmembers(
279-
self._module, lambda x: inspect.ismodule(x) and inspect.getfile(x).startswith(FILE_NAME_PREFIX)
271+
self._module, lambda x: inspect.ismodule(x) and x.__name__.startswith(self._options.name_prefix)
280272
)
281273
children = [ModulePrinter(module=sub, options=self._options).generate_toc() for _, sub in submodules]
282274
toc = {'name': name, 'href': f'scenario_tests/{name}.md'}
@@ -289,6 +281,7 @@ def main():
289281
getLogger().setLevel('INFO')
290282
parser = OptionParser(usage='usage: %prog [options]')
291283
parser.add_option('-o', '--output-dir', dest='out_dir', help='Output dir')
284+
parser.add_option('-p', '--name-prefix', dest='name_prefix', help='root module name prefix', default='ydb.tests.olap.')
292285
options, _ = parser.parse_args()
293286
if os.path.exists(options.out_dir):
294287
shutil.rmtree(options.out_dir)

ydb/tests/olap/docs/scenario_tests/introduction.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
# Цели и задачи
1+
# Goals and objectives
22

3-
Исполнение на произвольном кластере произвольных сценариев
4-
Составление отчетов о результатах запусков
5-
Генерация разнопрофильной нагрузки на кластер
6-
Выявление ошибок и проблем
3+
Execution of arbitrary scenarios on an arbitrary cluster
4+
Compiling reports on launch results
5+
Generating a multi-profile load on a cluster
6+
Identifying errors and problems
77

8-
# Технологии
8+
# Technologies
99

10-
* Система регулярного запуска задач
11-
`Arcadia Ci + Sandbox`
12-
* Среда для написания тестов
13-
`Pytest + ya make`
14-
* Инструмент для построения визуальных отчетов
15-
`Allure + ya make`
16-
* Система хранения и представления данных
17-
`YDB + DataLens`
10+
* Regular task launch system
11+
`Arcadia Ci + Sandbox`
12+
* Environment for writing tests
13+
`Pytest + ya make`
14+
* Tool for creating visual reports
15+
`Allure + ya make`
16+
* Data storage and presentation system
17+
`YDB+DataLens`
1818

19-
# Запуски
19+
# Launches
2020

21-
Запускается на регулярной основе в [Arcadia CI](https://a.yandex-team.ru/projects/kikimr/ci/actions/launches?dir=kikimr%2Ftests%2Facceptance%2Folap%2Fyatests&id=run_scenario_tests_auto).
22-
Описание запусков в [a.yaml](https://a.yandex-team.ru/arcadia/kikimr/tests/acceptance/olap/yatests/a.yaml?rev=r13836177#L102).
21+
Runs on a regular basis in [Arcadia CI](https://a.yandex-team.ru/projects/kikimr/ci/actions/launches?dir=kikimr%2Ftests%2Facceptance%2Folap%2Fyatests&id=run_scenario_tests_auto).
22+
Description of launches in [a.yaml](https://a.yandex-team.ru/arcadia/kikimr/tests/acceptance/olap/yatests/a.yaml?rev=r13836177#L102).
2323

24-
# Написание сценариев
24+
# Scenarios writing
2525

26-
## Общий подход
26+
## General approach
2727

28-
Код лежит в [Аркадии](https://a.yandex-team.ru/arcadia/kikimr/tests/acceptance/olap/yatests/scenario)
29-
Сценарии пишутся на языке `Python 3` в файлах, имена которых начинаются с префикса `test_`. Файлы нужно прописать в [ya.make](https://a.yandex-team.ru/arcadia/kikimr/tests/acceptance/olap/yatests/scenario/ya.make) в секции `TEST_SRCS`.
28+
The code is in [Github](https://github.com/ydb-platform/ydb/tree/main/ydb/tests/olap/scenario)
29+
Scenarios are written in `Python 3` in files whose names begin with the `test_` prefix. The files need to be registered in [ya.make](https://github.com/ydb-platform/ydb/tree/main/ydb/tests/olap/scenario/ya.make) in the `TEST_SRCS` section.
3030

31-
В качестве **наборов сценариев** принимаются классы с именами, начинающимися с `Test`.
31+
Classes with names starting with `Test` are accepted as **sets of scenarios**.
3232

33-
В качестве сценариев воспринимаются функции-члены классов-наборов сценариев, имена которых начинаются на `scenario_`.
33+
Scenarios are considered to be member functions of scenario classes whose names begin with `scenario_`.
3434

35-
В классе-наборе сценариев можно определить методы `setup_class` и `teardown_class`, которые будут выполняться соответственно перед и после исполнения набора сценариев.
35+
In a scenario set class, you can define `setup_class` and `teardown_class` methods that will be executed before and after the scenario set execution, respectively.
3636

37-
Для написания сценариев используются [Хелперы](./scenario.helpers.md)
37+
To write scenarios, use [Helpers](./scenario.helpers.md)
3838

39-
{% cut "Пример сценария" %}
39+
{% cut "Sample scenario" %}
4040

4141
```python
4242
class TestSchenarioSimple(BaseTestSet):

0 commit comments

Comments
 (0)