### Install libopengl0 for Habitat-Sim Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/getting-started/getting-started-on-windows-via-wsl.md This command installs the 'libopengl0' package, which is required for running Habitat-Sim. The '-y' flag automatically confirms the installation prompt. ```shell sudo apt -y install libopengl0 ``` -------------------------------- ### Setup uv Virtual Environment and Install Packages Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/UV_PROTOTYPE.md This snippet demonstrates how to set up a Python virtual environment using uv, install specific torch versions, and synchronize development and simulator packages. It requires uv to be installed and specifies Python 3.9.22. The --seed flag is necessary for building torch packages. ```shell uv venv -p 3.9.22 --seed uv pip install torch==1.13.1 # Use the version from pyproject.toml uv sync --extra dev --extra simulator_mujoco ``` -------------------------------- ### Download and Prepare Omniglot Dataset Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/getting-started/getting-started-on-windows-via-wsl.md This sequence installs the 'unzip' utility, creates a directory for the Omniglot dataset, clones the dataset repository, and then unzips the necessary background images and strokes files. This prepares the Omniglot dataset for use with Monty. ```shell sudo apt -y install unzip mkdir -p ~/tbp/data/ && cd "$_" git clone https://github.com/brendenlake/omniglot.git && cd omniglot/python unzip images_background.zip && unzip strokes_background.zip ``` -------------------------------- ### Clone tbp.monty Repository Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/getting-started/getting-started-on-windows-via-wsl.md Clones the tbp.monty repository from GitHub to a local directory within the WSL environment. Replace 'YOUR_GITHUB_USERNAME' with your actual GitHub username. This command assumes you have already forked the repository. ```shell git clone https://github.com/YOUR_GITHUB_USERNAME/tbp.monty ~/tbp ``` -------------------------------- ### Install github-readme-sync Dependencies Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/tools/github_readme_sync/README.md Installs the necessary dependencies for the github-readme-sync tool using pip. This command should be run from the root Monty directory. ```bash pip install -e '.[dev,github_readme_sync_tool]' ``` -------------------------------- ### Install Print Version Tool Dependencies (Python) Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/tools/print_version/README.md Installs the necessary dependencies for the Print Version tool using pip. This command should be run from the root Monty directory and assumes the project is set up according to the 'Getting Started' guide. ```shell pip install -e '.[dev,print_version_tool]' ``` -------------------------------- ### Setup Environment Variables for ReadMe Sync Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/tools/github_readme_sync/README.md Sets up essential environment variables required for the github-readme-sync tool to authenticate with ReadMe.com and specify image paths. ```bash export README_API_KEY= export IMAGE_PATH=thousandbrainsproject/tbp.monty/refs/heads/main/docs/figures ``` -------------------------------- ### View github-readme-sync CLI Help Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/tools/github_readme_sync/README.md Displays the help message for the github-readme-sync command-line interface, showing available subcommands and their arguments. ```bash python -m tools.github_readme_sync.cli -h ``` -------------------------------- ### Hierarchy File Example Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/rfcs/0001_github_2_readme_sync.md An example of a hierarchy file used to define the structure and ordering of documents and categories. This file guides the sync process to maintain the correct organization of documentation. ```markdown # category-name: Cateory Name - page-a - page-b - sub-page-1 ``` -------------------------------- ### Use an Action Sampler Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/implementing-actions.md Shows the usage of a concrete action sampler, `MyConstantSampler`, to create and sample an action. This demonstrates how to instantiate a sampler and obtain an action from it. ```python sampler = MyConstantSampler(actions=[Jump]) action = sampler.sample("agent_0") ``` -------------------------------- ### Markdown Video Embedding Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/contributing/style-guide.md Provides examples of embedding YouTube and Cloudinary videos using markdown link syntax. The tool automatically converts these links into embedded players, but they must be on their own line. ```markdown [Video Title](https://youtu.be/example-video-id) ``` ```markdown [Video Title](https://res.cloudinary.com/demo-cloud/video/upload/v12345/example-video.mp4) ``` -------------------------------- ### Running the Monty Experiment (Command Line) Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/tutorials/using-monty-in-a-custom-application.md This command executes the Monty Meets World 2D image inference experiment. It shows how to specify the experiment and optionally disable wandb logging or adjust scene parameters for testing. ```bash python run.py experiment=tutorial/monty_meets_world_2dimage_inference # To disable wandb logging: python run.py experiment=tutorial/monty_meets_world_2dimage_inference wandb_handlers: [] # To adjust scenes and versions for quick testing: python run.py experiment=tutorial/monty_meets_world_2dimage_inference config.eval_env_interface_args.scenes=[0,1,2] config.eval_env_interface_args.versions=[0,1] ``` -------------------------------- ### Python Mixin for Rectangle Area (State-Adding - Not Recommended) Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/contributing/style-guide/code-style-guide.md An example of a Python mixin that incorrectly adds state, which is discouraged. This pattern leads to incidental complexity by requiring state to be tracked in multiple places. ```python # Not OK, Mixin adds state class RectangleAreaMixin: def __init__(self, length: float, height: float) -> None: super().__init__() self._length = length self._height = height @property def area(self) -> float: return self._length * self.height class Rectangle(RectangleAreaMixin): def __init__(self, length: float, height: float) -> None: super().__init__(length, height) ``` -------------------------------- ### Python Mixin for Rectangle Area (State-Reading) Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/contributing/style-guide/code-style-guide.md An example of a Python mixin that correctly reads the state of the instance it's mixed with to compute the area. Mixins should not add state to avoid incidental complexity. ```python # OK, Mixin only reads state class RectangleAreaMixin: @property def area(self) -> float: return self._length * self._height class Rectangle(RectangleAreaMixin): def __init__(self, length: float, height: float) -> None: super().__init__() self._length = length self._height = height ``` -------------------------------- ### Initialize and Run MontyExperiment in Python Source: https://context7.com/thousandbrainsproject/tbp.monty/llms.txt This Python snippet shows how to instantiate and run the `MontyExperiment` class, which orchestrates training and evaluation loops. The experiment is typically configured via Hydra, and this example illustrates its usage within a context manager. ```python from tbp.monty.frameworks.experiments.monty_experiment import MontyExperiment from omegaconf import DictConfig # MontyExperiment is typically instantiated via Hydra config # The config specifies all experiment parameters config = DictConfig({ "seed": 42, "do_train": True, "do_eval": True, "n_train_epochs": 1, "n_eval_epochs": 1, "max_train_steps": 500, "max_eval_steps": 1000, "max_total_steps": 5000, "model_name_or_path": None, "min_lms_match": 1, "show_sensor_output": False, "supervised_lm_ids": "all", "monty_config": {}, "logging": {}, "env_interface_config": {}, }) # Run experiment using context manager with MontyExperiment(config) as experiment: experiment.run() # Output: Model saved to output_dir/run_name/model.pt ``` -------------------------------- ### Download Monty-Meets-World Datasets Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/getting-started/getting-started-on-windows-via-wsl.md These commands download and extract the 'numenta_lab.tgz' and 'worldimages.tgz' datasets, which are used for real-world testing in the Monty-Meets-World experiments. They ensure the target directory exists before downloading and unpacking the archives. ```shell mkdir -p ~/tbp/data/ && cd "$_" curl -L https://tbp-data-public-5e789bd48e75350c.s3.us-east-2.amazonaws.com/tbp.monty/numenta_lab.tgz | tar -xzf - curl -L https://tbp-data-public-5e789bd48e75350c.s3.us-east-2.amazonaws.com/tbp.monty/worldimages.tgz | tar -xzf - ``` -------------------------------- ### Detailed Experiment Setup and Execution in Python Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/docs/how-to-use-monty/tutorials/running-an-experiment-from-a-different-repository.md This comprehensive Python snippet shows a more detailed setup for running a supervised pretraining experiment. It includes configurations for logging, experiment arguments, Monty configuration, environment interfaces, and specific training environment settings. This is useful for complex experimental setups. ```python import os from pathlib import Path from tbp.monty.frameworks.run_env import setup_env setup_env() from tbp.monty.frameworks.config_utils.config_args import ( # noqa: E402 LoggingConfig, PatchAndViewMontyConfig, ) from tbp.monty.frameworks.config_utils.make_env_interface_configs import ( # noqa: E402 SupervisedPretrainingExperimentArgs, get_env_interface_per_object_by_idx, ) from tbp.monty.frameworks.environments import embodied_data as ED # noqa: E402 from tbp.monty.frameworks.experiments.pretraining_experiments import ( # noqa: E402 MontySupervisedObjectPretrainingExperiment, ) from tbp.monty.frameworks.run import run # noqa: E402 from tbp.monty.simulators.habitat.configs import ( # noqa: E402 PatchViewFinderMountHabitatEnvInterfaceConfig, ) first_experiment = dict( experiment_class=MontySupervisedObjectPretrainingExperiment, logging=LoggingConfig( log_parallel_wandb=False, run_name="test", output_dir=( Path(os.getenv("MONTY_LOGS")) / "projects" / "monty_runs" / "test" ).expanduser(), ), experiment_args=SupervisedPretrainingExperimentArgs( do_eval=False, max_train_steps=1, n_train_epochs=1, ), monty_config=PatchAndViewMontyConfig(), env_interface_config=PatchViewFinderMountHabitatEnvInterfaceConfig(), train_env_interface_class=ED.EnvironmentInterfacePerObject, train_env_interface_args=get_env_interface_per_object_by_idx(start=0, stop=1), ) run(first_experiment) ``` -------------------------------- ### Run Tutorial Tests Sequentially with Pytest Source: https://github.com/thousandbrainsproject/tbp.monty/blob/main/tests/tutorials/README.md This command executes integration tests in a single thread, which is recommended for tutorial tests due to their assumption of full machine access. It uses the pytest framework to run tests located in the 'test/integration' directory. ```bash pytest test/integration -n 1 ```