def main() -> int: config = PlannerConfig( task_fetcher=get_task_fetcher("hard_coded"), scheduling_algorithm=get_algorithm("right_based"), plan_writer=PlanWriter(), ) planner = Planner(config=config) return asyncio.run(planner.run())
def handle_delivery(message, sys=None): logger.info("Got: " + str(message)) try: message = message.decode() except (UnicodeDecodeError, AttributeError): e = sys.exc_info()[0] logger.info("Parsing Error: " + str(e)) parsed_json_message = json.loads(message) owner = parsed_json_message['owner'] tosca_file_name = 'tosca_template' tosca_template_json = parsed_json_message['toscaTemplate'] input_current_milli_time = lambda: int(round(time.time() * 1000)) # rabbit = DRIPLoggingHandler(host=rabbitmq_host, port=5672, user=owner) # logger.addHandler(rabbit) try: tosca_folder_path = os.path.join(tempfile.gettempdir(), "planner_files", str(input_current_milli_time())) except NameError: import sys millis = int(round(time.time() * 1000)) tosca_folder_path = os.path.dirname( os.path.abspath(sys.argv[0])) + os.path.join( tempfile.gettempdir(), "planner_files", str(millis)) if not os.path.exists(tosca_folder_path): os.makedirs(tosca_folder_path) input_tosca_file_path = os.path.join(tosca_folder_path, tosca_file_name + ".yml") with open(input_tosca_file_path, 'w') as outfile: outfile.write(yaml.dump(tosca_template_json)) conf = {'url': "http://host"} spec_service = SpecService(conf) test_planner = Planner(tosca_path=input_tosca_file_path, spec_service=spec_service) tosca_template = test_planner.resolve_requirements() tosca_template = test_planner.set_node_templates_properties() template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary( tosca_template) Planner(yaml_dict_tpl=template_dict, spec_service=spec_service) logger.info("template ----: \n" + yaml.dump(template_dict)) response = {'toscaTemplate': template_dict} output_current_milli_time = int(round(time.time() * 1000)) response["creationDate"] = output_current_milli_time if queue_name == "planner_queue": logger.info("Planning") logger.info("Returning plan") logger.info("Output message:" + json.dumps(response)) return json.dumps(response)
def run_test(self, input_tosca_file_path): conf = {'url': "http://host"} spec_service = SpecService(conf) test_planner = Planner(input_tosca_file_path, spec_service) test_tosca_template = test_planner.resolve_requirements() template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template) test_tosca_template = test_planner.set_node_templates_properties() template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template) logger.info("template ----: \n" + yaml.dump(template_dict)) print(yaml.dump(template_dict)) ToscaTemplate(yaml_dict_tpl=copy.deepcopy(template_dict)) test_response = {'toscaTemplate': template_dict} response = {'toscaTemplate': template_dict} output_current_milli_time = int(round(time.time() * 1000)) response["creationDate"] = output_current_milli_time response["parameters"] = [] # print("Output message:" + json.dumps(response)) self.assertEqual(True, True)
import argparse from planner.planner import Planner if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("map_name", type=str, help="Name of the map") parser.add_argument('source', type=str, help='Name of source node') parser.add_argument('destination', type=str, help='Name of destination node') args = parser.parse_args() planner = Planner(args.map_name) path = planner.get_path(args.source, args.destination) print("Path from {} to {}: {}".format(args.source, args.destination, path)) mean, variance = planner.get_estimated_duration(path) print("mean: ", mean) print("variance: ", variance)
action='store', help='Path to the config file') parser.add_argument('--experiment', type=str, action='store', help='Experiment_name') parser.add_argument('--approach', type=str, action='store', help='Approach name') args = parser.parse_args() config_params = get_config_params(args.file, experiment=args.experiment, approach=args.approach) config = Configurator(config_params, component_modules=_component_modules) components_ = config.config_ccu() kwargs = { "planner": Planner(**config_params.get("planner")), "performance_tracker": components_.get("performance_tracker") } for name, c in components_.items(): if hasattr(c, 'configure'): c.configure(**kwargs) ccu = CCU(components_) ccu.run()
from planner.event import Event import planner.planner as planner from planner.planner import Planner import googledistancematrix as gdm from googledistancematrix import querent from googledistancematrix.querent import Querent import settings, globals settings.init() gdm_querent = gdm.querent.Querent( api_key=settings.GOOGLE_DISTANCE_MATRIX_API_KEY) gdm_querent.set_travel_mode(querent.TravelMode.TRANSIT) p = Planner() p.set_home("Str d Pariser Kommune 30") p.set_planning_times(globals.to_minutes(8, 0), globals.to_minutes(20, 0)) p.set_max_events(3) p.add_event( Event("Kuchenbacken", Event.EventType.SPECIFIC, start=globals.to_minutes(17, 45), end=globals.to_minutes(19, 00), place="Str d Pariser Kommune 30"), [30, 6, 2019]) p.add_event( Event("Buch lesen", Event.EventType.SPECIFIC,
def restore(path, user_id): planner = globals.restore_object(path, str(user_id)) if not planner: planner = Planner() globals.store_object(planner, path, user_id) return planner
from planner.planner import Planner import argparse if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("map_name", type=str, help="Name of the map") parser.add_argument("min_n_runs", type=int, help="Minimum number of runs per edge") parser.add_argument("min_n_obstacles", type=int, help="Minimum number of obstacles per edge") parser.add_argument("max_n_obstacles", type=int, help="Maximum number of obstacles per edge") args = parser.parse_args() obstacle_interval = list( range(args.min_n_obstacles, args.max_n_obstacles + 1)) print("obstacle interval: ", obstacle_interval) config_file = 'planner/config/config.yaml' edge_info_path = '../ropod_rosbag_processing/ropod_rosbag_processing/angela/results/' planner = Planner() planner.generate_map(config_file, edge_info_path, args.min_n_runs, obstacle_interval, args.map_name)
from planner.planner import Planner from mapper.map import Map # Temporary testing code if __name__ == '__main__': cspace_map = Map(-10, -10, 10, 10, 4) planner = Planner() # print(planner.find_open(cspace_map)) # seems to work correctly # print(planner.has_neighbor_in((3, 3), [(4, 4)])) # works # print(planner.adjacent((3, 3))) # works
from planner.planner import Planner parser = argparse.ArgumentParser() parser.add_argument('robot_id', type=str, help='example: robot_001') parser.add_argument('--file', type=str, action='store', help='Path to the config file') parser.add_argument('--experiment', type=str, action='store', help='Experiment_name') parser.add_argument('--approach', type=str, action='store', help='Approach name') args = parser.parse_args() config_params = get_config_params(args.file, experiment=args.experiment, approach=args.approach) config = Configurator(config_params, component_modules=_component_modules) components = config.config_robot(args.robot_id) robot = Robot(**components) for name, c in components.items(): if hasattr(c, 'configure'): c.configure(planner=Planner(**config_params.get("executor"))) robot.run()
from googledistancematrix.querent import Querent import pickle import settings, globals, logging settings.init() unpickle = True gdm_querent = gdm.querent.Querent( api_key=settings.GOOGLE_DISTANCE_MATRIX_API_KEY) gdm_querent.set_travel_mode(querent.TravelMode.TRANSIT) if not unpickle: # create new planner object and pickle it p = Planner() p.set_home("Str d Pariser Kommune 30") p.set_planning_times(globals.to_minutes(8, 0), globals.to_minutes(20, 0)) p.set_max_events(8) p.import_ics("marc_uni.ics") pickle.dump(p, open("planner_pickle.pkl", "wb"), protocol=pickle.HIGHEST_PROTOCOL) else: # try to load an existing pickled planner object try: p = pickle.load(open("planner_pickle.pkl", "rb")) except FileNotFoundError:
parser = argparse.ArgumentParser() parser.add_argument('robot_id', type=str, help='example: robot_001') parser.add_argument('--file', type=str, action='store', help='Path to the config file') parser.add_argument('--experiment', type=str, action='store', help='Experiment_name') parser.add_argument('--approach', type=str, action='store', help='Approach name') args = parser.parse_args() config_params = get_config_params(args.file, experiment=args.experiment, approach=args.approach) config = Configurator(config_params, component_modules=_component_modules) components = config.config_robot_proxy(args.robot_id) for name, c in components.items(): if hasattr(c, 'configure'): c.configure(planner=Planner(**config_params.get("planner"))) robot = RobotProxy(**components, d_graph_watchdog=config_params.get("d_graph_watchdog")) robot.run()
def get_planned_dates(releaseId, arch): multiPlanner = Planner() release = multiPlanner.build_object(releaseId, arch) # release = the_planner.get_Releases2(releaseId) print_dates(release)
import dateutil.parser as dp from java.time import LocalDate, ZoneId import com.xebialabs.xlrelease.api.XLReleaseServiceHolder as XLReleaseServiceHolder import com.xebialabs.xlrelease.api.v1.forms.ReleasesFilters as ReleasesFilters # import com.xebialabs.xlrelease.api.v1.FolderApi as folderApi # import com.xebialabs.xlrelease.api.v1.FolderApi as folderApi import org.slf4j.LoggerFactory as LoggerFactory logger = LoggerFactory.getLogger("David Tile") import planner.planner reload(planner.planner) from planner.planner import Planner the_planner = Planner() HTTP_SUCCESS = sets.Set([200, 201, 202, 203, 204, 205, 206, 207, 208]) HTTP_ERROR = sets.Set([ 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 412, 413, 414, 415 ]) filterReleaseTags = list(releaseTags) filterReleaseFolders = list(folderFilter) filterStatuses = ["FAILED", "COMPLETED", "SKIPPED", "ABORTED"] releaseApi = XLReleaseServiceHolder.getReleaseApi() appServices = XLReleaseServiceHolder.getApiServices() taskApi = XLReleaseServiceHolder.getTaskApi() # logger.info(str(appServices)) svcs = XLReleaseServiceHolder.getApiServices() for api in svcs:
def threaded_function(args): while not done: connection.process_data_events() sleep(5) if __name__ == "__main__": logging.basicConfig(level=logging.INFO) if sys.argv[1] == "test_local": tosca_path = "../TOSCA/" input_tosca_file_path = tosca_path + '/application_example_updated.yaml' conf = {'url': "http://host"} spec_service = SpecService(conf) test_planner = Planner(input_tosca_file_path, spec_service) test_tosca_template = test_planner.resolve_requirements() test_tosca_template = test_planner.set_node_templates_properties() template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary( test_tosca_template) logger.info("template ----: \n" + yaml.dump(template_dict)) ToscaTemplate(yaml_dict_tpl=copy.deepcopy(template_dict)) test_response = {'toscaTemplate': template_dict} logger.info("Output message:" + json.dumps(test_response)) else: logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2]) global channel global connection
from planner.plannertoimage import PlannerToImage from planner.planner import Planner import globals from datetime import datetime as dt if __name__ == "__main__": planner = Planner() planner.set_home("Str d Pariser Kommune 30") planner.set_planning_times( globals.to_minutes(8, 0), globals.to_minutes(20, 0) ) planner.set_max_events(8) planner.import_ics('import_planner_draw.ics') #planner.import_ics('exported_calendar.ics') print(planner) PlannerToImage(planner, dt.today()).draw_image('test_image.png') #PlannerToImage(planner, dt(2019,4,11)).draw_image('test_image.png')