How to use the datalab.context.Context function in datalab

To help you get started, we’ve selected a few datalab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googledatalab / pydatalab / legacy_tests / bigquery / dataset_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / bigquery / udf_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / storage / bucket_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / bigquery / view_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / kernel / bigquery_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / bigquery / jobs_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / legacy_tests / storage / api_tests.py View on Github external
def _create_context():
    project_id = 'test'
    creds = mock.Mock(spec=google.auth.credentials.Credentials)
    return datalab.context.Context(project_id, creds)
github googledatalab / pydatalab / datalab / mlalpha / _cloud_runner.py View on Github external
def run(self, job_id=None):
    """Submit a training job to the CloudML service.

    Args:
      job_id: id for the training job. If None, a UUID will be generated.

    Returns: job info returned from service.
    """
    if job_id is None:
      job_id = self._create_default_job_name()
    job = {
        'job_id': job_id,
        'training_input': self._job_request,
    }
    context = datalab.context.Context.default()
    cloudml = discovery.build('ml', 'v1beta1', credentials=context.credentials,
                              discoveryServiceUrl=_CLOUDML_DISCOVERY_URL)
    request = cloudml.projects().jobs().create(body=job,
                                               parent='projects/' + context.project_id)
    request.headers['user-agent'] = 'GoogleCloudDataLab/1.0'
    return request.execute()