hawk_eye.core.asset_manager

Overview

This file contains functions for interacting with Google Cloud Storage to upload and download different assets. As of writting (2021), Image Recognition stores model training runs, testing dependencies, and components for data generation in the cloud.

For data generation, new data will be added whenever there is a test flight or competition where data is gathered.

Tests associated with this module will be uploaded to a bucket where its contents are deleted after 24hrs.

Todo

  • Come up with a scheme for versioning base shapes and fonts. We might ocasionally design better shapes, which can be introduced as a new version. A policy for updating users and removing the old versions needs to be established.

  • Come up with a policy for alerting users about new background archives. Is this just communicated from leads to members or another way?

Module

Functions to pull in data from the cloud.

This relies on Google Cloud Storage python API. Please see the Image Recognition lead to recieve the proper credentials for access to the bucket.

If you do not have Google Cloud APIs installed please run:

$ hawk_eye/setup/install_google_cloud.sh
hawk_eye.core.asset_manager.download_file(filename: str, destination: pathlib.Path) → None[source]

Download an object from Google Cloud Storage.

This function assumes the file is in .tar.gz format.

Parameters
  • filename – the path to the file on Google Cloud. This should not include the bucket name.

  • destination – the path to extract the tarball.

Raises

FileNotFoundError – if the object does not exist in Google Cloud.

hawk_eye.core.asset_manager.pull_all() → None[source]

Pull the backgrounds, base shapes and font files as specified in hawk_eye.data_generation.generate_config.py.

hawk_eye.core.asset_manager.pull_backgrounds() → None[source]

Pull the shape generation backgrounds.

This function utilizes the BACKGROUNDS_URLS in hawk_eye.data_generation.generate_config.py.

hawk_eye.core.asset_manager.pull_base_shapes() → None[source]

Pull the base shapes.

This function utilizes the BASE_SHAPES_URL in hawk_eye.data_generation.generate_config.py.

hawk_eye.core.asset_manager.pull_fonts() → None[source]

Pull the fonts used in data generation.

This function utilizes the FONTS_URL in hawk_eye.data_generation.generate_config.py.

hawk_eye.core.asset_manager.untar_and_move(filename: pathlib.Path, destination: pathlib.Path) → None[source]

Extract tarball to directory.

Parameters
  • filename – path to the archive to be extraced.

  • destination – where to extract the archive.

hawk_eye.core.asset_manager.upload_file(source_path: pathlib.Path, destination: str)[source]

A generic function for uploading a file from local storage to the cloud.

Parameters
  • source_path – a path to the local file

  • desination – where to upload the file

Raises

FileNotFoundError – if the object does not exist locally.