You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Run the local dev server
Open a shell to the oppia-dev-server container: make shell.oppia-dev-server
Start a Python session python
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.
import models: from core.platform import models
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)]
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:
make shell.oppia-dev-server
python
import scripts.start
to get Python to look in the correct folders for imports.models
:from core.platform import models
storage_services
:storage_services = models.Registry.import_storage_services()
Now you can explore GCS as follows:
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
The text was updated successfully, but these errors were encountered: