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

Fix pit crew missing models and authorship logic #522

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ def download_models(
sync_names=True, export_path=export_path)
else:
model_downloaded = pit_crew.download_model(
model_name, author_name, sync_names=True)
model_name, author_name, sync_names=True)[0]
if model_downloaded:
break
else:
logger.warning("Retrying %d of 5 times...", i)
logger.warning("Retrying %d of 5 times..." % i)

if not model_downloaded:
logger.error(
Expand Down
21 changes: 12 additions & 9 deletions rmf_building_map_tools/pit_crew/pit_crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_missing_models(model_names, model_path=None,
(model_name, author_name)!
model_path (str, optional): Overall path to model directory.
Defaults to None. If None, function will use "~/.gazebo/models" or
"~/.ignition/fuel" depending on the value of ign.
"~/.gz/fuel" depending on the value of ign.
config_file (str, optional): Name of the config file to parse when
checking local models. Defaults to "model.config".
cache_file_path (str, optional): The path to the model cache file.
Expand All @@ -144,7 +144,7 @@ def get_missing_models(model_names, model_path=None,
- Missing models are models that are not in your local directory
and also missing from Fuel.
"""
for key, model_name in enumerate(model_names):
for model_name in model_names:
if isinstance(model_name, ModelNames) or isinstance(model_name, tuple):
assert len(model_name) == 2, \
"Invalid model name tuple given: %s!" % model_name
Expand Down Expand Up @@ -224,7 +224,8 @@ def get_missing_models(model_names, model_path=None,
logger.warning("Model %s in local model directory"
" is not by the requested author %s!"
% (model_name, author_name))
elif model_name in fuel_models:
elif model_name in fuel_models and \
fuel_models[model_name] == author_name:
output['downloadable'].append((model_name_original,
fuel_models[model_name]))

Expand All @@ -248,7 +249,7 @@ def get_local_model_name_tuples(path=None, config_file="model.config",
Args:
path (str, optional): Overall path to model directory.
Defaults to None. If None, function will use "~/.gazebo/models" or
"~/.ignition/fuel" depending on the value of ign.
"~/.gz/fuel" depending on the value of ign.
config_file (str, optional): Name of the config file to parse.
Defaults to "model.config".
default_author_name (str, optional): The author name to use if no
Expand All @@ -269,7 +270,7 @@ def get_local_model_name_tuples(path=None, config_file="model.config",

if path is None:
if ign:
path = "~/.ignition/fuel/"
path = "~/.gz/fuel/"
else:
path = "~/.gazebo/models/"
logger.warning("No local model path given! Using default %s instead!"
Expand Down Expand Up @@ -504,7 +505,7 @@ def download_model(model_name, author_name, version="tip",
"tip", which will download the latest model.
download_path (str, optional): The root directory for downloading
and unzipping the models into. Defaults to None. If None, function
will use "~/.ignition/fuel/fuel.gazebosim.org" or
will use "~/.gz/fuel/fuel.gazebosim.org" or
"~/.gazebo/models" depending on the state of the ign argument.
sync_names (bool, optional): Change downloaded model.sdf model name to
match folder name. Defaults to False.
Expand All @@ -523,7 +524,7 @@ def download_model(model_name, author_name, version="tip",
if download_path is None:
if ign:
download_path = os.path.expanduser(
"~/.ignition/fuel/fuel.gazebosim.org"
"~/.gz/fuel/fuel.gazebosim.org"
)
else:
download_path = os.path.expanduser("~/.gazebo/models")
Expand Down Expand Up @@ -626,13 +627,13 @@ def download_model_fuel_tools(model_name, author_name,
# Currently, ignition fuel download can only download to this folder.
# Fuel tools creates this folder if it does not yet exist
download_path = os.path.expanduser(
"~/.ignition/fuel/fuel.gazebosim.org"
"~/.gz/fuel/fuel.gazebosim.org"
)
# Command line
url_model_name = parse.quote(model_name)
full_url = ("https://fuel.gazebosim.org/1.0" +
'/' + author_name + '/models' + '/' + url_model_name)
full_command = full_command = ("ign fuel download -u "
full_command = full_command = ("gz fuel download -u "
+ full_url + " -v 4")
subprocess.call([full_command], shell=True)
child = subprocess.Popen([full_command], shell=True,
Expand Down Expand Up @@ -671,6 +672,8 @@ def download_model_fuel_tools(model_name, author_name,
(subdirname))
pass
break
if len(sub_dirs) == 0:
raise RuntimeError("Model not found in Fuel portal")
latest_ver = max(sub_dirs)
extract_path = os.path.join(extract_path, str(latest_ver))

Expand Down
Loading