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 info to wiki explaining how to probe local emulated GCS #423

Open
U8NWXD opened this issue Dec 10, 2024 · 0 comments
Open

Add info to wiki explaining how to probe local emulated GCS #423

U8NWXD opened this issue Dec 10, 2024 · 0 comments
Labels

Comments

@U8NWXD
Copy link
Member

U8NWXD commented Dec 10, 2024

When working on code that interacts with Google Cloud Storage (GCS), it's often useful to be able to explore the files that exist in our local emulated GCS. You can do this as follows:

  1. Run the local dev server
  2. Open a shell to the oppia-dev-server container: make shell.oppia-dev-server
  3. Start a Python session python
  4. Depending on what Oppia tools you want to use, you may need to run import scripts.start to get Python to look in the correct folders for imports.
  5. import models: from core.platform import models
  6. Set up storage_services: storage_services = models.Registry.import_storage_services()

Now you can explore GCS as follows:

# The `abc` is the GCS bucket name, which you can put anything for.
>>> storage_services.listdir('abc', 'exploration_suggestions/25/assets')
[EmulatorBlob(name=exploration_suggestions/25/assets/image/img_20241203_121203_tn09emjdm7_height_472_width_314_micro.svg, content_type=image/svg+xml), EmulatorBlob(name=exploration_suggestions/25/assets/image/img_20241203_121203_tn09emjdm7_height_472_width_314_compressed.svg, content_type=image/svg+xml), EmulatorBlob(name=exploration_suggestions/25/assets/image/img_20241203_121203_tn09emjdm7_height_472_width_314.svg, content_type=image/svg+xml)]

You can also mutate files in GCS. See the available functions here: https://github.com/oppia/oppia/blob/develop/core/platform/storage/dev_mode_storage_services.py

@seanlip seanlip changed the title How to probe local emulated GCS Add info to wiki explaining how to probe local emulated GCS Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants