Skip to content
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

Add quality of life scripts #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pipenv run python scripts/run-container.py experiments/detection/subjects/$1/experiment.yml $2
1 change: 1 addition & 0 deletions detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pipenv run python scripts/recover-system.py experiments/detection/subjects/$1/experiment.yml
Copy link
Member

Choose a reason for hiding this comment

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

add missing shebang to first line. also, can we move this to the scripts directory? (same comments apply to the above file.)

60 changes: 60 additions & 0 deletions scripts/run-container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""This script is used to statically recover run-time architectures for entire ROS systems."""
Copy link
Member

Choose a reason for hiding this comment

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

is this true? looks like copypasta

import argparse
import os
import sys
import tempfile
import typing as t

from loguru import logger
logger.remove()

import rosdiscover
import rosdiscover.cli

import yaml

from common.config import (
DetectionExperimentConfig,
ExperimentConfig,
NodeSources,
Copy link
Member

Choose a reason for hiding this comment

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

looks like there's a few unused imports and deadcode?

RecoveryExperimentConfig,
ROSDiscoverConfig,
load_config
)

def main() -> None:
# remove all existing loggers
stderr_logger = logger.add(
sys.stderr,
colorize=True,
format="<bold><level>{level}:</level></bold> {message}",
level="INFO",
)

parser = argparse.ArgumentParser("statically recovers ROS system architectures")
parser.add_argument(
"configuration",
help="the path to the configuration file for this experiment",
)
parser.add_argument(
"version",
help="buggy or fixed",
)
args = parser.parse_args()

experiment_filename: str = args.configuration
version: str = args.version
if not os.path.exists(experiment_filename):
error(f"configuration file not found: {experiment_filename}")

if not version in ["buggy", "fixed"]:
error(f"version needs to be buggy or fixed")
config = load_config(experiment_filename)
image = config[version]["image"]
os.system(f'docker run -it --rm {image}')


if __name__ == "__main__":
main()