How to use the datalab.utils 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 / kernel / module_tests.py View on Github external
def test_create_python_module(self):
    datalab.utils.commands._modules._create_python_module('bar', 'y=1')
    self.assertIsNotNone(sys.modules['bar'])
    self.assertEqual(1, sys.modules['bar'].y)
github googledatalab / pydatalab / datalab / ml / _job.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.

"""Implements Cloud ML Operation wrapper."""


import datalab.utils
import datalab.context
from googleapiclient import discovery
import yaml


class Job(datalab.utils.Job):
  """Represents a Cloud ML job."""

  def __init__(self, name, context=None):
    """Initializes an instance of a CloudML Job.

    Args:
      name: the name of the job. It can be an operation full name
          ("projects/[project_id]/jobs/[operation_name]") or just [operation_name].
      context: an optional Context object providing project_id and credentials.
    """
    super(Job, self).__init__(name)
    if context is None:
      context = datalab.context.Context.default()
    self._context = context
    self._api = discovery.build('ml', 'v1', credentials=self._context.credentials)
    if not name.startswith('projects/'):
github googledatalab / pydatalab / datalab / stackdriver / commands / _monitoring.py View on Github external
list_resource_parser.add_argument(
      '-t', '--type',
      help='The resource type(s) to list; can include wildchars.')
  list_resource_parser.set_defaults(func=_list_resource_descriptors)

  list_group_parser = list_parser.subcommand(
      'groups',
      ('List the Stackdriver groups in this project.'))
  list_group_parser.add_argument(
      '-p', '--project', help='The project on which to execute the request.')
  list_group_parser.add_argument(
      '-n', '--name',
      help='The name of the group(s) to list; can include wildchars.')
  list_group_parser.set_defaults(func=_list_groups)

  return datalab.utils.commands.handle_magic_line(line, cell, parser)