Skip to content

feat: initialize documentation directory #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/rai_whoami/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ This embodiment info is then used to create a system prompt for LLM-based agents

### Directory Structure

Prepare your robot documentation directory as follows:
Initialize the documentation directory:

```bash
initialize-docs documentation_dir
```

Populate your robot documentation directory:

```
documentation_dir/
Expand All @@ -37,7 +43,7 @@ documentation_dir/
To generate the system prompt from your documentation directory:

```bash
python src/rai_whoami/rai_whoami/build_whoami.py documentation_dir [--output_dir output_dir] [--build-vector-db]
build-whoami documentation_dir [--output_dir output_dir] [--build-vector-db]
```

Generated files will be saved in the `output_dir / generated` directory or `documentation_dir / generated` if not specified.
Expand Down
5 changes: 3 additions & 2 deletions src/rai_whoami/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rai_whoami"
version = "0.0.1"
version = "0.0.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why bump by 4 numbers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syncing with pypi. We are doing manual build & publish, which in the nearest future should be done automatically with auto version bump.

description = "Package to extract embodiment information from robot documentation"
authors = ["Maciej Majek <[email protected]>"]
readme = "README.md"
Expand All @@ -23,7 +23,8 @@ faiss-cpu = "*"
pypdf = "^5.4.0"

[tool.poetry.scripts]
build-whoami = "rai_whoami.build_whoami:build_whoami"
build-whoami = "rai_whoami.build_whoami:main"
initialize-docs = "rai_whoami.initialize_docs_directory:main"


[build-system]
Expand Down
6 changes: 5 additions & 1 deletion src/rai_whoami/rai_whoami/build_whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def build_whoami(args: argparse.Namespace) -> None:
info.to_directory(args.output_dir)


if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser()
parser.add_argument("documentation_dir", type=Path)
parser.add_argument("--build-vector-db", default=False, action="store_true")
Expand All @@ -54,3 +54,7 @@ def build_whoami(args: argparse.Namespace) -> None:
if args.output_dir is None:
args.output_dir = args.documentation_dir / "generated"
build_whoami(args)


if __name__ == "__main__":
main()
51 changes: 51 additions & 0 deletions src/rai_whoami/rai_whoami/initialize_docs_directory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
from pathlib import Path

SUBDIRECTORIES = [
"images",
"documentation",
"urdf",
]


def initialize_docs_directory(args: argparse.Namespace) -> None:
documentation_dir = Path(args.documentation_dir)
if os.path.exists(documentation_dir):
print(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, decided to go with the simples option for such scripts.

f"Directory {documentation_dir} already exists. Remove it or use different folder."
)
return

os.makedirs(documentation_dir)
print(f"Initialized documentation directory at {documentation_dir}")
for subdirectory in SUBDIRECTORIES:
os.makedirs(documentation_dir / subdirectory)
print(
f"Initialized subdirectory {subdirectory} at {documentation_dir / subdirectory}"
)


def main():
parser = argparse.ArgumentParser()
parser.add_argument("documentation_dir", type=Path)
args = parser.parse_args()
initialize_docs_directory(args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
initialize_docs_directory(args)
initialize_docs_directory(**vars(args))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never seen that, I will keep the same style as other script files.



if __name__ == "__main__":
main()