Skip to content

Add a flag --skip-cached to skip already-downloaded models and collections #461

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

Open
wants to merge 3 commits into
base: gz-fuel-tools10
Choose a base branch
from

Conversation

khaledgabr77
Copy link
Contributor

🎉 New feature

Closes #150

Summary

This PR introduces a --skip-cached flag option to gz-fuel-tools10 (available through the gz fuel download command).
When the flag is set, any models that already exist in the local cache are skipped instead of downloaded again, saving time.

Both individual model downloads and collection downloads now respect this flag.

Behaviour before this PR

Every time running of gz fuel download re-download of all models, even if they were already present locally.

Behaviour after this PR

With --skip-cached, the CLI first checks the local cache and only downloads the models that are missing.

Test it

  1. Start a large collection download and interrupt it Press Ctrl+C partway through
gz fuel download -j 4  -u "https://fuel.gazebosim.org/1.0/openrobotics/collections/Gazebo classic model database"

Screenshot from 2025-04-25 02-11-25

  1. Resume with the new flag – already-downloaded models are skipped
gz fuel download -j 4 --skip-cached -u "https://fuel.gazebosim.org/1.0/openrobotics/collections/Gazebo classic model database"

Screenshot from 2025-04-25 02-00-33

You can repeat the same steps with an individual model URL too.

gz fuel download -u https://fuel.gazebosim.org/1.0/OpenRobotics/models/Ambulance -v 4
gz fuel download -u --skip-cached https://fuel.gazebosim.org/1.0/OpenRobotics/models/Ambulance -v 4

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@khaledgabr77 khaledgabr77 requested a review from nkoenig as a code owner April 25, 2025 19:04
@github-actions github-actions bot added 🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty labels Apr 25, 2025
@khaledgabr77 khaledgabr77 changed the title Feature/skip cached Add a flag --skip-cached to skip already-downloaded models and collections Apr 25, 2025
@ahcorde ahcorde self-requested a review April 28, 2025 22:24
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

You have introduced many changes which are not related with this PR, do you mind to restore them

@@ -228,7 +229,8 @@ class Cmd
'onlymodels' => '0',
'onlyworlds' => '0',
'defaults' => false,
'console' => false
'console' => false,
'skip_cached' => 'false'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'skip_cached' => 'false'
'skip_cached' => false

@@ -302,6 +304,9 @@ class Cmd
opts.on('--console', 'Output to console') do
options['console'] = true
end
opts.on('-s', '--skip-cached', 'Skip downloading resources already in cache') do
options['skip_cached'] = 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
options['skip_cached'] = 'true'
options['skip_cached'] = true

@@ -434,9 +439,9 @@ class Cmd
exit(-1)
end
when 'download'
Importer.extern 'int downloadUrl(const char *, const char *, const char *, const char *, unsigned int)'
Importer.extern 'int downloadUrl(const char *, const char *, const char *, const char *, unsigned int, const char *)'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Importer.extern 'int downloadUrl(const char *, const char *, const char *, const char *, unsigned int, const char *)'
Importer.extern 'int downloadUrl(const char *, const char *, const char *, const char *, unsigned int, bool)'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ahcorde
I followed the changes you suggested and updated both gz.cc and gz.hh to accept a bool parameter. However, when I tried to compile and run the code, I encountered the following issue:

Library error: Problem running [download]() from /root/gz_ws/install/lib/libgz-fuel_tools10.so.10.0.1

I need to determine whether this issue came from the Ruby script or the C++ implementation. Previously, when reading the file, I noticed that char was used to represent boolean values, so I followed the same approach. However, now I plan to recheck the full code to understand exactly where the issue is coming from.

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Apr 29, 2025
@khaledgabr77
Copy link
Contributor Author

You have introduced many changes which are not related with this PR, do you mind to restore them

You're right — I forgot to mention that the changes are related to running ament_uncrustify --reformat. After I finished working on each C++ file, I applied the reformatting using that command.
Do you still want me to revert the changes?

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

You have introduced many changes which are not related with this PR, do you mind to restore them

You're right — I forgot to mention that the changes are related to running ament_uncrustify --reformat. After I finished working on each C++ file, I applied the reformatting using that command. Do you still want me to revert the changes?

we are not using uncrustify in gazebo. Yes, restore the changes

@khaledgabr77
Copy link
Contributor Author

You have introduced many changes which are not related with this PR, do you mind to restore them

You're right — I forgot to mention that the changes are related to running ament_uncrustify --reformat. After I finished working on each C++ file, I applied the reformatting using that command. Do you still want me to revert the changes?

we are not using uncrustify in gazebo. Yes, restore the changes

I'm sorry for that, i restore changes now.

@khaledgabr77
Copy link
Contributor Author

I’ve restored the changes and will review the updates you requested later tomorrow.

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

some linters are failing

  /github/workspace/src/gz.cc:468:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/gz.cc:515:  If/else bodies with multiple statements require braces  [readability/braces] [4]
  /github/workspace/src/gz.cc:516:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/gz.cc:559:  If/else bodies with multiple statements require braces  [readability/braces] [4]
  /github/workspace/src/gz.cc:560:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/gz.cc:658:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
  /github/workspace/src/gz.hh:65:  Lines should be <= 80 characters long  [whitespace/line_length] [2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

Add option to skip cached models when downloading from command line
2 participants