<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Francesco Viganò on Medium]]></title>
        <description><![CDATA[Stories by Francesco Viganò on Medium]]></description>
        <link>https://medium.com/@francesco.vigano?source=rss-a27913e1d268------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IKohyaIVpGWHD-A-</url>
            <title>Stories by Francesco Viganò on Medium</title>
            <link>https://medium.com/@francesco.vigano?source=rss-a27913e1d268------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:02:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@francesco.vigano/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create a Report Inventory with Looker Studio Pro]]></title>
            <link>https://medium.com/google-cloud/create-a-report-inventory-with-looker-studio-pro-78af055da3fb?source=rss-a27913e1d268------2</link>
            <guid isPermaLink="false">https://medium.com/p/78af055da3fb</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[looker-studio]]></category>
            <dc:creator><![CDATA[Francesco Viganò]]></dc:creator>
            <pubDate>Fri, 28 Jul 2023 22:41:05 GMT</pubDate>
            <atom:updated>2024-04-18T16:26:18.640Z</atom:updated>
            <content:encoded><![CDATA[<h3>INTRODUCTION</h3><p><strong>Looker Studio Pro</strong> enables organizations to retrieve all assets (reports, data sources) through <a href="https://developers.google.com/looker-studio/integrate/api/reference/assets/search">APIs</a>. All assets within an organization are accessible to Looker Studio editors or viewers defined at the <a href="https://support.google.com/looker-studio/answer/12814824?sjid=6645438244716776821-EU#:~:text=Optional%3A%20Add%20principals%20to%20the%20project">organizational level</a>, allowing them to list all available assets and check which users and groups those assets have been shared with.</p><p>In this article I will show how to configure a GCP project and the Looker Studio organization to create an inventory of all reports and data sources available both in personal and shared workspaces.</p><h3>MEET THE LOOKER STUDIO ASSET MANAGER</h3><p>Let me introduce Lorenzo, a fictitious character that has recently joined the organization. One of his tasks is to identify all reports that have been created over the years.</p><p>Lorenzo accesses Looker Studio and since this is the first time he logs in with his brand new credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*m765008LSRfOOjjZ2FIPbg.png" /></figure><p>Apparently he has no access to any resource, so to accomplish his mission he needs to do something else!</p><p>Lorenzo has learned about <a href="https://cloud.google.com/blog/products/data-analytics/an-introduction-to-looker-studio-pro">Looker Studio Pro features</a> and <a href="https://developers.google.com/looker-studio/integrate/api/reference">Looker Studio APIs</a>, so he decides to create a Python application to meet his goals.</p><h3>BECOME LOOKER STUDIO ASSET EDITOR</h3><p>Since the company has already activated Looker Studio Pro and linked a GCP project (see <a href="https://support.google.com/looker-studio/answer/12814824?hl=en">documentation</a>), Lorenzo asks the project Owner to be configured as <strong>Data Studio Asset Editor</strong> in the GCP project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMQZ2PgvvfHYMJcWQEL2XA.png" /></figure><p>Now Lorenzo is allowed to View and Edit <strong>all assets</strong> defined within the Looker Studio Pro organization, no matter where they are stored (see also this <a href="https://support.google.com/looker-studio/answer/12814824?hl=en#:~:text=Optional%3A%20Add%20principals%20to%20the%20project">page</a>).</p><p>Data Studio Asset Editor will allow Lorenzo to also modify report sharing configuration and, if required, move reports to <a href="https://support.google.com/looker-studio/answer/12791815?hl=en"><strong>team workspaces</strong></a>.</p><h3>AUTHENTICATE WITH GOOGLE SDK</h3><p>To start using the APIs, Lorenzo needs to authenticate using Google SDK. To do so, he follows these <a href="https://developers.google.com/looker-studio/integrate/api">instructions</a> to authorize an app and Google admin console to further provide all required authorizations.</p><p><em>NOTE: I provide some detailed instructions with screenshots in the APPENDIX if you need some reference guide. Follow all the instructions!</em></p><p><em>Please see Google official </em><a href="https://developers.google.com/identity/protocols/oauth2"><em>documentation</em></a><em> for more information about OAuth 2.0.</em></p><p>Once the app has been authorized, Lorenzo follows these <a href="https://github.com/googleapis/google-api-python-client">instructions</a> to create a virtual environment and install <strong>Google API Client Python library.</strong></p><p>He also imports some libraries:</p><pre>import os<br>import requests<br>import hashlib<br>from google_auth_oauthlib.flow import Flow<br>import google.auth.transport.requests<br>from urllib.parse import unquote<br>import re<br>import socket<br>import sys</pre><p>and authenticates using the Python SDK:</p><pre>scopes=[&quot;https://www.googleapis.com/auth/datastudio&quot;,&quot;https://www.googleapis.com/auth/userinfo.profile&quot;]<br>client_secrets_path=&quot;PATH_TO_YOUR_CLIENT_CREDENTIALS&quot;<br>_SERVER = &quot;studio.vigano.com&quot; # your redirect url without https<br>_PORT = 80 #http port<br>_REDIRECT_URI = f&quot;http://{_SERVER}:{_PORT}&quot;<br>flow = Flow.from_client_secrets_file(client_secrets_path, scopes=scopes)<br>flow.redirect_uri = _REDIRECT_URI<br>passthrough_val = hashlib.sha256(os.urandom(1024)).hexdigest()<br>authorization_url, state = flow.authorization_url(https://medium.com/%3Cbr%3E%20%20access_type=&quot;offline&quot;,%3Cbr%3E%20%20state=passthrough_val,%3Cbr%3E)<br>print(&quot;Paste this URL into your browser: &quot;)<br>print(authorization_url)<br>print(&quot;\nWaiting for authorization and callback to: {}&quot;.format(_REDIRECT_URI))<br>code = unquote(get_authorization_code(passthrough_val))<br>flow.fetch_token(code=code)</pre><p><em>NOTE:</em></p><ul><li><em>We are using the function</em><strong><em> get_authorization_code</em></strong><em> . Function code is available in this public </em><a href="https://github.com/googleads/google-ads-python/blob/HEAD/examples/authentication/generate_user_credentials.py"><em>repository</em></a><em>. You can copy and adapt to your needs. <br>Essentially the function creates a socket to handle the HTTP request containing auth tokens. <br>Notice that the _SERVER is the same URL (without http) specified in the allower redirect URLs when we created our credentials (see APPENDIX also to configure the hosts file).</em></li><li><em>The function also calls another function (</em><strong><em>parse_raw_query_params</em></strong><em>) defined in the same repository.</em></li><li><em>Your code should access the downloaded json credentials file (see APPENDIX for more information).</em></li></ul><p><em>Another end to end example is available </em><a href="https://developers.google.com/identity/protocols/oauth2/web-server#example"><em>here</em></a><em>.</em></p><p>When Lorenzo executes the code, he obtains a URL that he copies and pastes in a web browser. After authenticating with his credentials, the code collects the token required to interact with Looker Studio APIs.</p><h3>LIST ALL LOOKER STUDIO ASSETS</h3><p>With the token, Lorenzo extracts all reports by calling the <a href="https://developers.google.com/looker-studio/integrate/api/reference/assets/search">Assets:search API</a> as follows:</p><pre>headers={}<br>headers [&quot;Authorization&quot;] = &#39;Bearer &#39; +flow.credentials.token<br>params = {&#39;assetTypes&#39;: [&#39;REPORT&#39;],&#39;pageSize&#39;:MAXREPORTS}<br>r = requests.get(&#39;https://datastudio.googleapis.com/v1/assets:search&#39;, headers=headers,params=params,)</pre><p><em>NOTE:</em></p><ul><li><strong><em>assets:search</em></strong><em> does not support pagination. Use a MAXREPORTS big enough to extract all your assets</em></li><li><em>if you want to extract data sources, just replace REPORT with DATA_SOURCE (see </em><a href="https://developers.google.com/looker-studio/integrate/api/reference/types#AssetType"><em>AssetType</em></a><em>). </em><strong><em>The API accepts a single asset type or it returns an empty result.</em></strong></li></ul><p>For instance Lorenzo can print all extracted assets as follows:</p><pre>if r.status_code == 200:<br>  json_response=r.json()<br>  assets =json_response[&quot;assets&quot;]<br>  for asset in assets :<br>    print(asset)</pre><p><em>NOTE: refer to the </em><a href="https://developers.google.com/looker-studio/integrate/api/reference/types#Asset"><em>asset</em></a><em> documentation for a reference of all relevant fields returned by the API for each asset. Notice that the asset identifier is </em><strong><em>name.</em></strong></p><p>Just adapting the code, Lorenzo extracts all required information with almost no effort.</p><h3>ALL ASSETS NOW AVAILABLE IN THE UI</h3><p>Just after listing all assets, Lorenzo now refreshes the Looker Studio portal. All reports are now listed, so he interacts with them, moves reports to proper team workspaces or changes report sharing settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIqD_yRU9aleJFsdp1J5fQ.png" /></figure><h3>EXTRACTING AND MANAGING RIGHTS WITH APIs</h3><p>The UI is nice, but over the years the organization has created thousands of reports and Lorenzo is required to bring some order, especially avoiding that untrusted reports are widely shared.</p><p>First of all, Lorenzo extracts all permissions associated to assets returned by Asset:search with the <a href="https://developers.google.com/looker-studio/integrate/api/reference/permissions/get">get method</a>:</p><pre>asset = #put here how the asset id is initialized<br>r = requests.get(&#39;https://datastudio.googleapis.com/v1/assets/{}/permissions&#39;.format(asset), headers=headers)</pre><p>If needed, Lorenzo can revoke permissions of a given set of users as follows:</p><pre>members =[&#39;user:ls-user@myorganization.com&#39;]<br>r = requests.post(&#39;https://datastudio.googleapis.com/v1/assets/{}/permissions:revokeAllPermissions&#39;.format(asset), headers=headers, data={&#39;members&#39; : members})<br>r.json()</pre><p><em>NOTE: check the </em><a href="https://developers.google.com/looker-studio/integrate/api/reference/types#Member"><em>Member object</em></a><em> to understand how prefixes are used by the API.</em></p><p>Similarly he <a href="https://developers.google.com/looker-studio/integrate/api/reference/permissions/addMembers">add</a>s new permissions with the Permissions:addMember method</p><h3>FINAL COMMENTS</h3><p>Lorenzo has now gained visibility over all Reports and Data Sources defined within his organization. Using <a href="https://support.google.com/looker-studio/answer/9690662?hl=en">Looker Studio Audit Log Events</a> he can monitor what reports are created, edited or shared, being also able to monitor where reports are stored (personal workspaces, team workspaces).</p><h3>APPENDIX — CREATE CREDENTIALS and AUTHORIZE APP</h3><p>In this section we provide some detailed instructions to configure your app.</p><h4>0. [Optional Step] Create a GCP project</h4><p>Optional step. You can use any existing GCP project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oaMwa8QSzCYRPTMJ7GGhUA.png" /></figure><h4>1. Activate Looker Studio APIs</h4><p>After selecting the new project, search for Looker studio APIs (<a href="http://datastudio.googleapis.com/">datastudio.googleapis.com</a>) and activate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/0*enJpB4dDV2yzjXXv" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSkO4-I_qzcDXygM1jlF-g.png" /></figure><p>You should now see that the APIs have been enabled in this project.</p><h4>2. Create Credentials</h4><p>Using the link provided by the UI when you enable the APIs, let us now create credentials to interact with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2BzkenOHmInAlQMlVDytw.png" /></figure><p>Follow the wizard using the same options unless specified otherwise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djeWyVks9Wo277mlhGbZ4g.png" /></figure><p>Choose the app name and provide email addresses of people in your organization that can be reached if support is needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44VA2rozqFWinxKpu2CczA.png" /></figure><p>Leave defaults in scopes and continue with the wizard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUFBtZEHAZ22S2c3OTlbRg.png" /></figure><p>Let us now define the OAuth Client ID. Notice that I have added <a href="http://127.0.0.1:8080/">http://studio.vigano.com</a> as a redirect URI since in my code I will create a <strong>local service</strong> to gather credentials generated during the authentication process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*Ui2BeX-CRLnMd7dAZtyAoA.png" /></figure><p>Since in my code I am referring to a local service, we need to map studio.vigano.com to my local computer. To do so, the easiest way is to modify your hosts file (or similar configuration depending on your operative system) adding an entry like</p><blockquote>127.0.0.1 studio.vigano.com</blockquote><p>Unfortunately the Looker Studio APIs do not allow you to specify localhost (127.0.0.1) as redirect URL nor another IP address.</p><p>Once you are familiar with the process, you might consider here a different configuration that best meets your requirements and use cases.</p><p>When you select the Create button, your credentials will be created. <strong>Copy</strong> the Client ID and <strong>download</strong> your credentials as a json file. You can also close the wizard selecting <strong>Done</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icu0hQGuq44luHuACkllVg.png" /></figure><h4>3. Authorize App</h4><p>Go to <a href="http://admin.google.com/">admin.google.com</a> and find <a href="https://admin.google.com/ac/owl/domainwidedelegation">domain-wide delegation</a> (Security &gt; API Controls &gt; Domain-wide Delegation) and click <strong>Add new</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*9abXe-102tiPzj_5BEojgQ.png" /></figure><p>Let us now add the Client ID copied in the previous step and these two APIs in the OAuth scopes</p><ul><li><a href="https://www.googleapis.com/auth/datastudio">https://www.googleapis.com/auth/datastudio</a></li><li><a href="https://www.googleapis.com/auth/userinfo.profile">https://www.googleapis.com/auth/userinfo.profile</a></li></ul><p>Remember to authorize the client and you should now able to see your application among authorized apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anUBH-JCyL8y4PdCx6KcLA.png" /></figure><p>Now you can proceed to create a new authentication token and interact with Looker Studio APIs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78af055da3fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/create-a-report-inventory-with-looker-studio-pro-78af055da3fb">Create a Report Inventory with Looker Studio Pro</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choose the IDE you want and develop on Vertex AI Workbench (Part I)]]></title>
            <link>https://medium.com/google-cloud/choose-the-ide-you-want-and-develop-on-vertex-ai-workbench-part-i-94d19ca1d2ff?source=rss-a27913e1d268------2</link>
            <guid isPermaLink="false">https://medium.com/p/94d19ca1d2ff</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Francesco Viganò]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 08:34:18 GMT</pubDate>
            <atom:updated>2022-09-06T14:25:16.262Z</atom:updated>
            <content:encoded><![CDATA[<p>Notebooks are the de-facto development standard tools for data science, and Google Cloud provides <a href="https://cloud.google.com/vertex-ai-workbench">Vertex AI Workbench</a> to make data scientists more productive. <br>Still, other development IDEs (e.g. VSCode, Pycharm, etc.) offer interesting features (debugging, autocompletion, etc.) and developers feel more productive using those tools, especially at the time of writing libraries and support code.</p><p>In this series, we are going to present how two of the most common development IDEs, VSCode and Pycharm, can be configured on your local machine to work with a remote Vertex AI Workbench.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QpaypfJSV2ti9hr78YC8g.png" /><figcaption>A data scientist using locally installed IDEs to interact with remote Vertex AI Workbench instances</figcaption></figure><p>In this article, we start with VSCode and we briefly present how to create a Vertex AI Workbench instance, more precisely an User Managed Notebook. Then we discuss how you can connect to a notebook with VSCode. <br>We tried to provide a detailed step by step guide. It might seem complex at first since <strong>apparently</strong> many steps are involved, but it is actually pretty simple.</p><h3><strong>Create User Managed Notebooks</strong></h3><p>To illustrate how to use VSCode with Vertex Notebooks, we create two<a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/introduction"> User Managed Notebooks</a>. As we will see there are a few architectural differences characterizing each option.</p><p>Providing all the details about how to create a user managed notebook is beyond our objectives. Refer to the <a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/create-user-managed-notebooks-instance-console-quickstart">documentation</a> to read more information about how to create a notebook. Also, consider that a user managed notebook is created in a subnet of a VPC (see also the <a href="https://cloud.google.com/compute/docs/instances/create-start-instance#create_a_vm_instance_in_a_specific_subnet">documentation</a>): you must ensure that you can reach your notebooks from your laptop.</p><p>We create a first notebook using a <a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/custom-container">custom container image</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*jlHihVsnWBdrd0dZ" /></figure><p>and a second notebook using Google <a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/images">provided images</a> like, for instance, Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*Kc7aj8VDcSd2clGV" /></figure><p>Once each instance is available, we <a href="https://cloud.google.com/vertex-ai/docs/workbench/user-managed/create-new#open_the_notebook_2">connect</a> with the JupyterLab installed on each machine and we <strong>clone</strong> the Vertex AI demos github <a href="https://github.com/GoogleCloudPlatform/vertex-ai-samples">repository</a>.</p><p>In the custom-image notebook you should obtain something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*xn3q2kawkyg2EUoo" /></figure><p>While in the python-image machine you should get something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*MwTkLV8s9KmFIl71" /></figure><p>Cloning the sample repository allows us to compare what you see when you connect with the JypyterLab and when you connect with IDEs to the very same instance.</p><p>We can now continue configuring the machine where you installed VSCode and that we will use to connect with these instances.</p><h3><strong>Install GCloud CLI</strong></h3><p>To work seamlessly with Google Cloud services we recommend installing the <a href="https://cloud.google.com/sdk/docs/install">GCloud CLI</a> on your working environment. This configuration applies for any IDE of your choice.</p><h3><strong>Configure Visual Studio Code</strong></h3><p>To start working with VSCode and Vertex AI Notebooks, we recommend to install the following VSCode extensions:</p><ul><li><a href="https://marketplace.visualstudio.com/items?itemName=GoogleCloudTools.cloudcode">Cloud Code</a>: it integrates with Google Cloud services, like for instance Google Compute engine (GCE). At the moment, to work with GCE, you need to install the <a href="https://cloud.google.com/code/docs/vscode/insiders">pre-release version</a>.</li><li><a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack">Remote Development:</a> it allows you to open any folder in a container or on a remote machine, and take advantage of VS Code’s full feature set</li></ul><h3><strong>Configure Your Credentials and Project</strong></h3><p>To connect with the Vertex AI Notebook machine, we need its IP (depending on your configuration you might use its private or public IP) and configure key certificates. To do so, we can use Cloud Code extension.</p><ul><li>You can login directly from Visual Studio code selecting the Cloud Code extension and following steps suggested by the extension.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*1mCXuGJejqda6G-D" /></figure><ul><li>Once logged in, you can select your GCP project using Cloud Code</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*cc_YnWiYId9e30lD" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/0*d-47PgbKKxEgo7XS" /></figure><ul><li>All notebooks we have created in the previous step are now displayed in the GCE section of the Cloud Code extension.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*krVPm4_PfpDIX29V" /></figure><ul><li>We use the SSH button to connect with<strong> each instance</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*WqQYLkgBgicgPu3J" /></figure><p>In doing so:</p><ol><li>cloud connect will configure private keys on your device</li><li>you can also test your connectivity from your local machine with the remote instance</li><li>cou can collect a few settings that will be required later. For instance, when connected, the terminal will display something like:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*60bTR_fl3-uExqsI" /></figure><p>Where</p><ol><li>admin_vigano is my user</li><li>python-image is the host we are connected with.</li></ol><p><strong>Take note of these settings.</strong></p><p>You might experience issues trying to SSH into the remote notebook. In case it does not work, refer to the <a href="https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh">documentation</a> to identify the issue. A good starting point is represented by the <a href="https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh#run_the_troubleshooting_tool">troubleshooting tool </a>and often firewall rules are a common suspect.</p><h3><strong>Connect to a User Managed Notebook</strong></h3><p>To illustrate how to connect to a user managed notebook, we start first with the python-image machine (the one created starting from Google provided images).</p><ul><li>Use Ctrl + Shift + P (or VSCode Palette) and select <strong>Remote-SSH: Connect to Host</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*cal6mwqwKBzF620b" /></figure><p>From the following list, select <strong>Configure SSH Hosts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/0*4O72L8D_V-VwweQ9" /></figure><p>and choose the file you want to edit (in our case we edited the first option, home/vigano/.ssh/config)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*Y1zCO9R5GoQOx8zS" /></figure><p>and add an entry similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/0*MJEIjE-9L2R8ibfB" /></figure><p>depending on your network settings, you can use the name of the instance, its private or public IP where</p><ul><li><strong>Host</strong>: is the name that VSCode will display later. You can choose what name you like the most (i.e. the name of the Vertex AI Workbench instance)</li><li><strong>HostName</strong>: the private or public IP of your notebook (depending on your network settings)</li><li><strong>IdentityFile</strong>: is the private key that has been created when we connected with Cloud Code with the instances. You should find it in the .ssh folder of your user directory</li><li><strong>User</strong>: corresponds to your Cloud Identify user (with underscores and few changes). We recommended to take note of your user in a previous step, so you should have already at hand.</li><li>Use Ctrl + Shift + P (or VSCode Palette) and select <strong>Remote-SSH: Connect to Host. </strong>You should see also the host configured in the previous step and you can connect</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/0*E1KHkTo10rbQBoqY" /></figure><p>In case you are requested to confirm the fingerprint of the machine, select “Continue”</p><p>On the left bottom corner VSCode will report that you are successfully connected to the instance as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/0*BLyGfI8DSRaK4_m1" /></figure><ul><li>Once connected, if you open folder <strong>/home/jupyter/ </strong>you will see the same folder structure we observed when we connected with JupyterLab through the console</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/0*RseF12oTDdG-5JiE" /></figure><ul><li><strong>To start working with Python and Jupyter you need to install Python and Jupyter extensions on the remote host</strong>.<br>Notice that if you open a notebook (e.g. vertex-ai-samples/notebooks/official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb) and you select the kernel, VSCode suggests you to install Python and Jupyter extensions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KBeimBuv-QSi4PFu" /></figure><ul><li>Install Jupyter and Python extensions <strong>on the remote notebook</strong> to remotely interact with the Vertex AI Workbench as if you were working on your local machine. For instance, you can interactively execute Python code on remote environments or execute Jupyter notebooks within VSCode leveraging kernels defined on Vertex AI Workbench.<br>Remember to select <strong>Install in SSH</strong> (you want these extension working on the remote instance, not on your local machine).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*H-F-YnXFegtYQIq8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*yqe35VQwoEINeqDn" /></figure><h3><strong>Connect to a Custom User Managed Notebook</strong></h3><p>To use VSCode with a Vertex AI Workbench obtained starting from a custom container (e.g. our custom-image machine) a few additional steps are required:</p><ul><li>Connect to the instance following the same procedure described in the previous section.</li><li>If you check /home/jupyter directory you will find the cloned content, but you will not find libraries, environments or code configured on your container.<br>In fact, your custom container is executed on a docker instance on the virtual machine:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/0*UulswJKhwAQMezym" /></figure><ul><li>To be able to connect to the container with VSCode, your user must belong to the docker group of the remote machine. Add your user as follows:</li></ul><pre>sudo usermod -aG docker $USER</pre><p>You need to reset (or stop / start) the Vertex AI Workbench to apply this configuration.</p><ul><li>Connect again with the instance with VSCode. Once connected, select from the command palette ( or Ctrl + Shift + P) <strong>Remote-Containers: Attach to Running Container.<br>Ensure you are executing this command from a VSCode window connected to the remote machine!</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*qC16nwFGEGTzHmHw" /></figure><p>VSCode connects to docker and return the list of containers available on the instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/0*kYN0niCLDvg9hJDA" /></figure><ul><li>select the <strong>payload-container</strong> and VSCode will update the UI (or open a new window) showing on the bottom left corner that it is connected with the selected container.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/0*10S6sq--zWKyE5lr" /></figure><ul><li>Install Jupyter and Python extensions <strong>on the remote container</strong> to remotely interact with the Vertex AI Workbench as if you were working on your local machine. For instance, you can interactively execute Python code on remote environments or execute Jupyter notebooks within VSCode leveraging kernels defined within the custom container.<br>Remember to select <strong>Install in Container</strong> (you want these extension working on the remote container, not on your local machine).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*_73YiZu_km25RZE7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*L9lqwicEMwhICIjc" /></figure><h3><strong>Conclusions</strong></h3><p>In this article we discussed how to connect to Vertex AI Workbench from VSCode, a widely adopted development IDE.In particular, we have shown how to work with standard and custom images, highlighting a few differences.</p><p>In subsequent article we will explore how to connect with Vertex AI Workbench with PyCharm</p><h3><strong>Acknowledgements</strong></h3><p>I would like to thank Ivan Nardini and Saeed Aghabozorgi for their suggestions and feedbacks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94d19ca1d2ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/choose-the-ide-you-want-and-develop-on-vertex-ai-workbench-part-i-94d19ca1d2ff">Choose the IDE you want and develop on Vertex AI Workbench (Part I)</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>