Skip to content

Commit 96798af

Browse files
authored
Refactor/rename article to attachment (#321)
* refactor: rename parameter article to attachment, change validate_doc to flag * docs: rename article to attachment * chore: add warning that article is missing for readme generation * revert: remove warning that article is missing for generating readme
1 parent 153f674 commit 96798af

File tree

8 files changed

+56
-51
lines changed

8 files changed

+56
-51
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ It also generates advices and recommendations for the repository.
3636

3737
OSA is currently under development, so not all features are implemented.
3838

39-
40-
4139
---
4240

4341
## How it works?
@@ -170,18 +168,18 @@ Run Open-Source-Advisor using the following command:
170168
[<img align="center" src="https://img.shields.io/badge/Pip-3776AB.svg?style={badge_style}&logo=pypi&logoColor=white" />](https://pypi.org/project/pip/)
171169

172170
```sh
173-
python -m osa_tool.run -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--article {article}] [--convert-notebooks {notebook_paths}]
171+
python -m osa_tool.run -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--attachment {article}] [--convert-notebooks {notebook_paths}]
174172
```
175173

176174
**Using `docker`** &nbsp;
177175
[<img align="center" src="https://img.shields.io/badge/Docker-2CA5E0.svg?style={badge_style}&logo=docker&logoColor=white" />](https://www.docker.com/)
178176

179177
```sh
180-
docker run --env-file .env {image-name} -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--article {article}] [--convert-notebooks {notebook_paths}]
178+
docker run --env-file .env {image-name} -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--attachment {article}] [--convert-notebooks {notebook_paths}]
181179
```
182180

183-
The --article option enables you to choose a README template for a repository based on an article. You can provide
184-
either a link to a PDF file of the article or a path to a local PDF file after the --article option. If you are using
181+
The --attachment option enables you to choose a README template for a repository based on an article. You can provide
182+
either a link to a PDF file of the article or a path to a local PDF file after the --attachment option. If you are using
185183
Docker, ensure that you upload the PDF file to the OSA folder before building the image, then, specify the path as
186184
/app/OSA/... or just use volume mounting to access the file.
187185

@@ -201,7 +199,7 @@ documentation, see the [Workflow Generator README](./osa_tool/workflow/README.md
201199
| `--top_p` | Nucleus sampling probability | `None` |
202200
| `--temperature` | Sampling temperature to use for the LLM output (0 = deterministic, 1 = creative). | `None` |
203201
| `--max_tokens` | Maximum number of tokens the model can generate in a single response | `None` |
204-
| `--article` | Link to the pdf file of the article | `None` |
202+
| `--attachment` | Path to a local PDF or .docx file, or a URL to a PDF resource | `None` |
205203
| `-m`, `--mode` | Operation mode for repository processing: `basic`, `auto` (default), or `advanced`. | `auto` |
206204
| `--delete-dir` | Enable deleting the downloaded repository after processing | `disabled` |
207205
| `--no-fork` | Avoid create fork for target repository | `False` |

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,18 @@ Run Open-Source-Advisor using the following command:
137137
[<img align="center" src="https://img.shields.io/badge/Pip-3776AB.svg?style={badge_style}&logo=pypi&logoColor=white" />](https://pypi.org/project/pip/)
138138

139139
```sh
140-
python -m osa_tool.run -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--article {article}]
140+
python -m osa_tool.run -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--attachment {article}]
141141
```
142142

143143
**Using `docker`** &nbsp;
144144
[<img align="center" src="https://img.shields.io/badge/Docker-2CA5E0.svg?style={badge_style}&logo=docker&logoColor=white" />](https://www.docker.com/)
145145

146146
```sh
147-
docker run --env-file .env {image-name} -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--article {article}]
147+
docker run --env-file .env {image-name} -r {repository} [--api {api}] [--base-url {base_url}] [--model {model_name}] [--attachment {article}]
148148
```
149149

150-
The --article option enables you to choose a README template for a repository based on an article. You can provide
151-
either a link to a PDF file of the article or a path to a local PDF file after the --article option. If you are using
150+
The --attachment option enables you to choose a README template for a repository based on an article. You can provide
151+
either a link to a PDF file of the article or a path to a local PDF file after the --attachment option. If you are using
152152
Docker, ensure that you upload the PDF file to the OSA folder before building the image, then, specify the path as
153153
/app/OSA/... or just use volume mounting to access the file.
154154

@@ -168,7 +168,7 @@ documentation, see the [GitHub Action Workflow Generator README](../osa_tool/git
168168
| `--top_p` | Nucleus sampling probability | `None` |
169169
| `--temperature` | Sampling temperature to use for the LLM output (0 = deterministic, 1 = creative). | `None` |
170170
| `--max_tokens` | Maximum number of tokens the model can generate in a single response | `None` |
171-
| `--article` | Link to the pdf file of the article | `None` |
171+
| `--attachment` | Path to a local PDF or .docx file, or a URL to a PDF resource | `None` |
172172
| `-m`, `--mode` | Operation mode for repository processing: `basic`, `auto` (default), or `advanced`. | `auto` |
173173
| `--delete-dir` | Enable deleting the downloaded repository after processing | `disabled` |
174174
| `--no-fork` | Avoid create fork for target repository | `False` |

osa_tool/config/settings/arguments.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ top_p:
7272
description: "Nucleus sampling probability (1.0 = all tokens considered)."
7373
example: 0.8, 0.95
7474

75-
article:
76-
aliases: [ "--article" ]
75+
attachment:
76+
aliases: [ "--attachment" ]
7777
type: str
7878
description: |
79-
Select a README template for a repository with an article.
80-
Or provide a link to the pdf file.
79+
Path to a local PDF file (for articles) or .docx file (for documents).
80+
Alternatively, accept a publicly accessible HTTP/HTTPS URL pointing to a PDF resource.
8181
const: ""
82-
example: "path/to/file"
82+
example: path/to/document.docx, "https://example.com/article.pdf"
8383

8484
translate_dirs:
8585
aliases: [ "--translate-dirs" ]
@@ -173,10 +173,8 @@ validate_paper:
173173

174174
validate_doc:
175175
aliases: ["--validate-doc"]
176-
type: str
176+
type: flag
177177
description: "Check whether the experiments proposed in an attached documentation file can be reproduced using the selected repository."
178-
const: ""
179-
example: "path/to/file"
180178

181179
workflow:
182180
generate_workflows:

osa_tool/config/settings/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mode = "auto"
2525
web_mode = false
2626
# output = ""
2727
# branch = ""
28-
# article = ""
28+
# attachment = ""
2929
translate_dirs = false
3030
translate_readme = []
3131
# convert_notebooks = []

osa_tool/run.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from osa_tool.docs_generator.docs_run import generate_documentation
1919
from osa_tool.docs_generator.license import compile_license_file
2020
from osa_tool.git_agent.git_agent import GitHubAgent, GitLabAgent, GitverseAgent
21-
from osa_tool.logger import setup_logging, logger
21+
from osa_tool.logger import logger, setup_logging
2222
from osa_tool.organization.repo_organizer import RepoOrganizer
2323
from osa_tool.osatreesitter.docgen import DocGen
2424
from osa_tool.osatreesitter.osa_treesitter import OSA_TreeSitter
@@ -32,7 +32,12 @@
3232
)
3333
from osa_tool.translation.dir_translator import DirectoryTranslator
3434
from osa_tool.translation.readme_translator import ReadmeTranslator
35-
from osa_tool.utils import delete_repository, parse_folder_name, rich_section, osa_project_root
35+
from osa_tool.utils import (
36+
delete_repository,
37+
osa_project_root,
38+
parse_folder_name,
39+
rich_section,
40+
)
3641
from osa_tool.validation.doc_validator import DocValidator
3742
from osa_tool.validation.paper_validator import PaperValidator
3843
from osa_tool.validation.report_generator import (
@@ -120,9 +125,9 @@ def main():
120125
git_agent.upload_report(analytics.filename, analytics.output_path)
121126

122127
# NOTE: Must run first - switches GitHub branches
123-
if path_to_doc := plan.get("validate_doc"):
128+
if plan.get("validate_doc"):
124129
rich_section("Document validation")
125-
content = DocValidator(config).validate(path_to_doc)
130+
content = DocValidator(config).validate(plan.get("attachment"))
126131
va_re_gen = ValidationReportGenerator(config, git_agent.metadata, sourcerank)
127132
va_re_gen.build_pdf("Document", content)
128133
if create_fork:
@@ -131,7 +136,7 @@ def main():
131136
# NOTE: Must run first - switches GitHub branches
132137
if plan.get("validate_paper"):
133138
rich_section("Paper validation")
134-
content = PaperValidator(config).validate(plan.get("article"))
139+
content = PaperValidator(config).validate(plan.get("attachment"))
135140
va_re_gen = ValidationReportGenerator(config, git_agent.metadata, sourcerank)
136141
va_re_gen.build_pdf("Paper", content)
137142
if create_fork:
@@ -171,7 +176,7 @@ def main():
171176
# Readme generation
172177
if plan.get("readme"):
173178
rich_section("README generation")
174-
readme_agent = ReadmeAgent(config, plan.get("article"), plan.get("refine_readme"), git_agent.metadata)
179+
readme_agent = ReadmeAgent(config, plan.get("attachment"), plan.get("refine_readme"), git_agent.metadata)
175180
readme_agent.generate_readme()
176181

177182
# Readme translation

osa_tool/scheduler/README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,33 @@ In **custom mode**:
7373

7474
- A list of editable actions is displayed.
7575
- Available commands:
76-
- `help` or `?` — displays a table with descriptions of all editable keys.
77-
- `multi-bool` — enables batch editing of boolean-type keys.
78-
- `done` — finishes the editing session and displays the current plan.
76+
- `help` or `?` — displays a table with descriptions of all editable keys.
77+
- `multi-bool` — enables batch editing of boolean-type keys.
78+
- `done` — finishes the editing session and displays the current plan.
7979
- To edit an action, enter its name.
8080
- For each selected action:
81-
- If it is a **boolean value** (True/False), a prompt will request setting it to:
82-
- `y` — enable
83-
- `n` — disable
84-
- `skip` — leave unchanged
85-
- If it is a **string** or **list**:
86-
- A new value can be entered.
87-
- Leave empty to skip.
88-
- Enter `None` to explicitly disable the value.
89-
- Before entering a new value, the system will display:
90-
- A short description.
91-
- Allowed values (if available).
92-
- An example (if available).
93-
- The current value.
81+
- If it is a **boolean value** (True/False), a prompt will request setting it to:
82+
- `y` — enable
83+
- `n` — disable
84+
- `skip` — leave unchanged
85+
- If it is a **string** or **list**:
86+
- A new value can be entered.
87+
- Leave empty to skip.
88+
- Enter `None` to explicitly disable the value.
89+
- Before entering a new value, the system will display:
90+
- A short description.
91+
- Allowed values (if available).
92+
- An example (if available).
93+
- The current value.
9494

9595
Once the user type `done`:
9696

9797
- The updated tables with planned actions and inactive actions will be displayed again.
9898
- The program will prompt the user one more time to confirm the updated plan
9999
- Available options:
100-
- Confirm with `y` or **Enter**
101-
- Cancel with `n`
102-
- Re-enter manual editing mode with `custom`
100+
- Confirm with `y` or **Enter**
101+
- Cancel with `n`
102+
- Re-enter manual editing mode with `custom`
103103

104104
This interactive loop continues until the user explicitly confirms or cancels the operation.
105105

@@ -120,7 +120,7 @@ to the repository.
120120
| top_p | `--top_p` | str | Nucleus sampling probability | `null` ||
121121
| temperature | `--temperature` | str | Sampling temperature to use for the LLM output (0 = deterministic, 1 = creative). | `null` ||
122122
| max_tokens | `--max_tokens` | str | Maximum number of tokens the model can generate in a single response | `1500` ||
123-
| article | `--article` | str | README template for a repository with an article, or a link to a PDF file | `null` ||
123+
| attachment | `--attachment` | str | Path to a local PDF or .docx file, or a URL to a PDF resource | `null` ||
124124
| translate_dirs | `--translate-dirs` | flag | Enable automatic translation of directory names into English | `false` ||
125125
| convert_notebooks | `--convert-notebooks` | list | Convert Jupyter notebooks to `.py` format. Provide paths, or leave empty for repo directory |||
126126
| delete_dir | `--delete-dir` | flag | Delete the downloaded repository after processing | `false` ||
@@ -132,7 +132,7 @@ to the repository.
132132
| report | `--report` | flag | Analyze the repository and generate a PDF report | `false` ||
133133
| readme | `--readme` | flag | Generate a `README.md` file based on repository content | `false` ||
134134
| refine_readme | `--refine-readme` | flag | Enable advanced README refinement. This process requires a powerful LLM model (such as GPT-4 or equivalent) for optimal results | `false` ||
135-
| requirements | `--requirements ` | flag | Generate or refine a requirements.txt file based on repository content. | `false` ||
135+
| requirements | `--requirements` | flag | Generate or refine a requirements.txt file based on repository content. | `false` ||
136136
| organize | `--organize` | flag | Organize the repository by adding standard `tests` and `examples` directories if missing | `false` ||
137137
| about | `--about` | flag | Generate About section with tags | `false` ||
138138
| generate_workflows | `--generate-workflows` | flag | Generate GitHub Action workflows for the repository | `false` ||
@@ -149,3 +149,5 @@ to the repository.
149149
| branches | `--branches` | list | Branches to trigger workflows on | `[]` ||
150150
| codecov_token | `--codecov-token` | flag | Use Codecov token for coverage upload | `false` ||
151151
| include_codecov | `--include-codecov` | flag | Include Codecov coverage step in unit tests workflow | `true` ||
152+
| validate_paper | `--validate-paper` | flag | Check whether the experiments proposed in an attached research paper can be reproduced using the selected repository | `false` ||
153+
| validate_doc | `--validate-paper` | flag | Check whether the experiments proposed in an attached documentation file can be reproduced using the selected repository | `false` ||

osa_tool/validation/doc_validator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _encode_image(self, image_path: str):
5151
with open(image_path, "rb") as image_file:
5252
return base64.b64encode(image_file.read()).decode("utf-8")
5353

54-
def validate(self, path_to_doc: str) -> str:
54+
def validate(self, path_to_doc: str | None) -> str:
5555
"""
5656
Validate a documentation file against the code repository.
5757
@@ -61,6 +61,8 @@ def validate(self, path_to_doc: str) -> str:
6161
Returns:
6262
str: Validation result from the language model.
6363
"""
64+
if not path_to_doc:
65+
raise ValueError("Document is missing! Please pass it using --attachment argument.")
6466
try:
6567
# self.describe_image("/home/ilya/OSA/docx2txt-test-dir/image19.jpeg")
6668
doc_info = self.process_doc(path_to_doc)

osa_tool/validation/paper_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from osa_tool.config.settings import ConfigLoader
2+
from osa_tool.logger import logger
23
from osa_tool.models.models import ModelHandler, ModelHandlerFactory
34
from osa_tool.readmegen.context.article_content import PdfParser
45
from osa_tool.readmegen.context.article_path import get_pdf_path
5-
from osa_tool.logger import logger
66
from osa_tool.validation.code_analyzer import CodeAnalyzer
77
from osa_tool.validation.prompt_builder import PromptBuilder
88

@@ -42,7 +42,7 @@ def validate(self, article: str | None) -> str:
4242
Exception: If an error occurs during validation.
4343
"""
4444
if not article:
45-
raise ValueError("Article is missing! Please pass it using --article argument.")
45+
raise ValueError("Article is missing! Please pass it using --attachment argument.")
4646
try:
4747
paper_info = self.process_paper(article)
4848
code_files = self.code_analyzer.get_code_files()

0 commit comments

Comments
 (0)