Skip to content

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

@U8NWXD

Description

@U8NWXD

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions