Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for authorizing sheet2linkml on Google Drive #27

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

gaurav
Copy link
Collaborator

@gaurav gaurav commented Dec 7, 2021

This PR adds a section to the README describing how to authorize sheet2linkml to access Google Drive. It also adds a check for the google_api_credentials.json file, so that it can point you to this error rather than raising a FileNotFound exception.

Copy link
Member

@turbomam turbomam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis is a big improvement, but I still struggle with setting this up fresh. Maybe it's not worth agonizing over if everybody else gets it.

Comment on lines +38 to +46
## Authorization

sheet2linkml uses the [`pygsheets` library](https://github.com/nithinmurali/pygsheets) in order to access sheets in
Google Drive. To authorize it to access your Google Sheets, you will need to create and download Google Drive client credentials. First,
[enable the Google Drive API](https://developers.google.com/drive/api/v3/enable-drive-api). After the API is enabled,
[create and download the client credentials](https://www.iperiusbackup.net/en/how-to-enable-google-drive-api-and-get-client-credentials/)
from the [Google API Console](https://console.developers.google.com/). Save the file as `google_api_credentials.json` in
the root directory of this project. [Detailed instructions and screenshots](https://pygsheets.readthedocs.io/en/stable/authorization.html)
are also available from the [`pygsheets` documentation](https://pygsheets.readthedocs.io/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation is great.

Did you intentionally put CRs and/or LFs at the end of each line? Maybe you don't trust the way that it would be wrapped when rendered with different tools?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating a new Google Cloud project can be a complex steps and the pygsheets documentation is incomplete or even wrong in a few spots. WHen I select. or create a new project, there's no “Enable Apis and services” link or button. There is an "Enable and explore APIs" link under "Getting started" on the left hand side, but that takes some scrolling down. THere's also an "APIs and Services" link in the upper left hamburger selection menu. Both of those take the user to a place where “Enable Apis and services” is prominent.

I also don't see how to get to the Credential screen thought the left hand menu like they recommend. Maybe our succinct hints should say that a lot of these pages can be found with the prominent search bar at the top of most pages.

I think we should also confirm that OAuth is our recommended credential type as opposed to Service Accounts or anything else.

  • Desktop app

And there's a step for creating the OAuth credential, plus one for consenting

Can I confirm these:

  • Internal user type
  • App name, user support email and Developer Contact Information should be filled in, but nothing else?
  • the scopes screen can be skipped

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even after downloadinggoogle_api_credentials.json, placing it in the root folder, and setting

export CDM_GOOGLE_SHEET_ID=WbM2Jr869ofmdcSmhX_1E0aLWvnK2-gr47Mo_tzuQKWy

googleapiclient.errors.HttpError: <HttpError 404 when requesting https://sheets.googleapis.com/v4/spreadsheets/WbM2Jr869ofmdcSmhX_1E0aLWvnK2-gr47Mo_tzuQKWy?fields=properties%2Csheets%2Fproperties%2CspreadsheetId%2CnamedRanges&includeGridData=false&alt=json returned "Requested entity was not found.". Details: "Requested entity was not found."

Is that the wrong sheet ID? I seem to remember something like that before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THe README in this repo says export CDM_GOOGLE_SHEET_ID=WbM2Jr869ofmdcSmhX_1E0aLWvnK2-gr47Mo_tzuQKWy

The Makefile in cancerDHC/ccdhmodel says CDM_GOOGLE_SHEET_ID=1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4

Using 1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4 here worked. The readme should be updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a PR for the correct Sheet ID now

Copy link
Member

@turbomam turbomam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested some clarifications. After following my own instructions for setting up authentication and using the right Google Sheet ID, I could run sheet2linkml.

Except

...

Thu Dec 9 14:24:57 2021 [entity.py] INFO: Generating LinkML for Entity named Treatment from worksheet "Treatment" containing 18 attributes
...
RuntimeError: Error accessing TCCM Terminology Service: <Response [404]>

@turbomam
Copy link
Member

turbomam commented Dec 9, 2021

RuntimeError: Error accessing TCCM Terminology Service: <Response [404]>

I guess there are already some PRs to address this, so I will approve this PR.

@sujaypatil96 sujaypatil96 requested review from turbomam and removed request for turbomam December 9, 2021 20:39
@sujaypatil96 sujaypatil96 merged commit 7e4fe03 into develop Dec 9, 2021
@sujaypatil96 sujaypatil96 deleted the add-sheet2linkml-google-connection-code branch December 9, 2021 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants