Exemple #1
0
    def _dump_metadata(self):
        display.display(display.Link(
            'https://console.cloud.google.com/mlengine/models/{}/versions/{}?project={}'.format(
                self._model_id, self._version_id, self._project_id),
            'Version Details'
        ))
        display.display(display.Markdown('''
## Online Prediction

### REST endpoint
The REST endpoint for online prediction is as follows:
```
POST https://ml.googleapis.com/v1/{}:predict
```
Try the REST endpoint in [Google OAuth 2.0 Playgound](https://developers.google.com/oauthplayground/#step3\
&apisSelect=https://www.googleapis.com/auth/cloud-platform&postData={{"instances":[]}}\
&url=https://ml.googleapis.com/v1/{}:predict&content_type=application/json&http_method=POST).

### GCloud command
```bash
gcloud ml-engine predict --model {}  \
                   --version {} \
                   --json-instances instances.json
```
        '''.format(self._version_name, self._version_name, self._model_id, self._version_id)))
Exemple #2
0
def _dump_metadata(job, region):
    display.display(
        display.Link(
            'https://console.cloud.google.com/dataproc/jobs/{}?project={}&region={}'
            .format(
                job.get('reference').get('jobId'),
                job.get('reference').get('projectId'), region), 'Job Details'))
def display_job_link(project_id, job):
    location = job.get('location')
    job_id = job.get('id')
    display.display(
        display.Link(href='https://console.cloud.google.com/dataflow/'
                     'jobsDetail/locations/{}/jobs/{}?project={}'.format(
                         location, job_id, project_id),
                     text='Job Details'))
Exemple #4
0
    def test_display_tensorboard(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = False

        display.display(display.Tensorboard('gs://job/dir'))

        mock_json.dump.assert_called_with(
            {'outputs': [{
                'type': 'tensorboard',
                'source': 'gs://job/dir'
            }]}, mock.ANY)
    def test_display_html(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = False

        display.display(display.HTML('<p>test</p>'))

        mock_json.dump.assert_called_with(
            {'outputs': [{
                'type': 'web-app',
                'html': '<p>test</p>'
            }]}, mock.ANY)
    def test_display_link(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = False

        display.display(display.Link('https://test/link', 'Test Link'))

        mock_json.dump.assert_called_with(
            {
                'outputs': [{
                    'type': 'web-app',
                    'html': '<a href="https://test/link">Test Link</a>'
                }]
            }, mock.ANY)
Exemple #7
0
    def test_display_link(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = False

        display.display(display.Link('https://test/link', 'Test Link'))

        mock_json.dump.assert_called_with(
            {
                'outputs': [{
                    'type': 'markdown',
                    'source': '## [Test Link](https://test/link)',
                    'storage': 'inline'
                }]
            }, mock.ANY)
Exemple #8
0
    def test_display_markdown(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = False

        display.display(display.Markdown('# test'))

        mock_json.dump.assert_called_with(
            {
                'outputs': [{
                    'type': 'markdown',
                    'source': '# test',
                    'storage': 'inline'
                }]
            }, mock.ANY)
    def test_display_html_append(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = True
        mock_json.load.return_value = {
            'outputs': [{
                'type': 'web-app',
                'html': '<p>test 1</p>'
            }]
        }

        display.display(display.HTML('<p>test 2</p>'))

        mock_json.dump.assert_called_with(
            {
                'outputs': [{
                    'type': 'web-app',
                    'html': '<p>test 1</p>'
                }, {
                    'type': 'web-app',
                    'html': '<p>test 2</p>'
                }]
            }, mock.ANY)
Exemple #10
0
    def test_display_markdown_append(self, mock_open, mock_os, mock_json):
        mock_os.path.isfile.return_value = True
        mock_json.load.return_value = {
            'outputs': [{
                'type': 'markdown',
                'source': '# test 1',
                'storage': 'inline'
            }]
        }

        display.display(display.Markdown('# test 2'))

        mock_json.dump.assert_called_with(
            {
                'outputs': [{
                    'type': 'markdown',
                    'source': '# test 1',
                    'storage': 'inline'
                }, {
                    'type': 'markdown',
                    'source': '# test 2',
                    'storage': 'inline'
                }]
            }, mock.ANY)
Exemple #11
0
def _dump_job_metadata(project_id, job_id, job):
    display.display(
        display.Link(
            'https://console.cloud.google.com/mlengine/jobs/{}?project={}'.
            format(job_id, project_id), 'Job Details'))
    display.display(
        display.Link(
            'https://console.cloud.google.com/logs/viewer?project={}&resource=ml_job/job_id/{}&interval=NO_LIMIT'
            .format(project_id, job_id), 'Logs'))
    if 'trainingInput' in job and 'jobDir' in job['trainingInput']:
        display.display(display.Tensorboard(job['trainingInput']['jobDir']))
Exemple #12
0
def _display_job_link(project_id, job_id):
    display.display(display.Link(
        href= 'https://console.cloud.google.com/bigquery?project={}'
            '&j={}&page=queryresults'.format(project_id, job_id),
        text='Query Details'
    ))
Exemple #13
0
 def _dump_metadata(self):
     display.display(display.Link(
         'https://console.cloud.google.com/mlengine/models/{}/versions/{}?project={}'.format(
             self._model_short_name, self._version_id, self._project_id),
         'Version Details'
     ))
def _dump_metadata(cluster, region):
    display.display(display.Link(
        'https://console.cloud.google.com/dataproc/clusters/{}?project={}&region={}'.format(
            cluster.get('clusterName'), cluster.get('projectId'), region),
        'Cluster Details'
    ))
Exemple #15
0
 def _dump_metadata(self):
     display.display(
         display.Link(
             'https://console.cloud.google.com/mlengine/models/{}?project={}'
             .format(self._model_id, self._project_id), 'Model Details'))