def _configure_for_task_emulator(server_host: str, server_port: Union[str, int]): from gumo.core import configure as core_configure from gumo.datastore import configure as datastore_configure from gumo.task import configure as task_configure from gumo.task_emulator import configure as task_emulator_configure core_configure() datastore_configure() task_configure() task_emulator_configure( server_host=server_host, server_port=server_port, )
import os from gumo.core import configure as core_configure from gumo.datastore import configure as datastore_configure from gumo.task import configure as task_configure if os.environ.get('GOOGLE_CLOUD_PROJECT') is None: os.environ['GOOGLE_CLOUD_PROJECT'] = 'gumo-task' if os.environ.get('DATASTORE_EMULATOR_HOST_FOR_TEST'): os.environ['DATASTORE_EMULATOR_HOST'] = os.environ[ 'DATASTORE_EMULATOR_HOST_FOR_TEST'] elif os.environ.get('DATASTORE_EMULATOR_HOST') is None: os.environ['DATASTORE_EMULATOR_HOST'] = '127.0.0.1:8082' os.environ['CLOUD_TASKS_EMULATOR_ENABLED'] = 'true' core_configure() datastore_configure() task_configure(default_queue_name='gumo-default-queue', )
import os import uuid from gumo.core import configure as core_configure from gumo.datastore import configure as datastore_configure from gumo.datastore.infrastructure import DatastoreRepositoryMixin logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) logger = logging.getLogger(__name__) app = flask.Flask(__name__) app.config['JSON_AS_ASCII'] = False app.config['DEBUG'] = True core_configure( google_cloud_project='levii-playground', google_cloud_location='asia-northeast1', ) if 'DATASTORE_EMULATOR_HOST' in os.environ: datastore_configure( use_local_emulator=True, emulator_host=os.environ['DATASTORE_EMULATOR_HOST'], ) else: datastore_configure(use_local_emulator=False) class SampleRepository(DatastoreRepositoryMixin): def save(self, name: str, structured: bool = False): entity = self.DatastoreEntity( key=self.datastore_client.key('Book', str(uuid.uuid4())))
import os from gumo.core import configure as core_configure if os.environ.get('GOOGLE_APPLICATION_CREDENTIALS') is None: os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '/path/to/credential.json' core_configure( google_cloud_project='gumo-sample', google_cloud_location='asia-northeast1', )