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

Update sheet2linkml so that it can be run from the root directory of this package #96

Merged
merged 24 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3636e07
Modified sheet2linkml so it can be used from outside its own directory.
gaurav Sep 7, 2021
e0a183a
Cleaned up target `regen-google-sheet`.
gaurav Sep 7, 2021
504ee47
Fixed error in Pipfile, improved documentation.
gaurav Sep 7, 2021
f9aa6e8
Fixed path to sheet2linkml.
gaurav Sep 7, 2021
d7ad334
Regenerated model with latest from Google Sheets.
gaurav Sep 7, 2021
b59d619
Reactivated `gh-deploy` target in Makefile.
gaurav Sep 7, 2021
71ba9ad
Added gsheet authentication information to .gitignore.
gaurav Sep 7, 2021
c59b5f8
Regenerated artifacts.
gaurav Sep 7, 2021
a653af7
Added .env to GitHub.
gaurav Sep 7, 2021
48cb0b5
Removed .env -- let's just put that into Makefile.
gaurav Sep 7, 2021
d71f96e
Added Google Sheet ID to Makefile.
gaurav Sep 7, 2021
c4bd720
Renamed `regen-google-sheets` to `generate-model`.
gaurav Sep 7, 2021
1a89c98
Updated READMEs with updated instructions.
gaurav Sep 7, 2021
645363d
Removed google-sheets/output, no longer used.
gaurav Sep 7, 2021
5a9b73b
Moved logging.ini into the project root.
gaurav Sep 7, 2021
be05c1e
Moved sheet2linkml into /vendor, closes #95.
gaurav Sep 7, 2021
4a8710c
Fixed path to logging.ini.
gaurav Sep 7, 2021
fdbd831
Regenerated model.
gaurav Sep 7, 2021
78bca84
Regenerated artifacts.
gaurav Sep 7, 2021
ed2c847
Added `install-dev` target for Pipfile dev dependencies.
gaurav Sep 10, 2021
d26003c
Added `-o` as an alt option for `--output`.
gaurav Sep 10, 2021
8915c5d
Fixed reference to vendor/sheet2linkml/README.md.
gaurav Sep 15, 2021
11839eb
Fixed link.
gaurav Sep 15, 2021
21e1a06
Added basic instructions for running sheet2linkml.
gaurav Sep 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local
# Google API authentication information
google_api_credentials.json
token.pickle
sheets.googleapis.com-python.json

# From LinkML template (https://github.com/linkml/linkml-template/blob/1c94efc880b607b36786b87e164455a099618ffa/.gitignore)
Pipfile
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ PKG_T_CSV = $(PKG_DIR)/csv
ENV = PIPENV_IGNORE_INSTALLED=1
RUN = $(ENV) pipenv run
GEN_OPTS = --log_level WARNING
CDM_GOOGLE_SHEET_ID=1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4

# ----------------------------------------
# TOP LEVEL TARGETS
Expand Down Expand Up @@ -304,17 +305,16 @@ docserve: gen-docs

# Regenerate from Google Sheets. Note that this uses a *separate* Pipenv in the
# generators/google-sheets directory, so we have to run pipenv install on it separately.
regen-google-sheets:
cd generators/google-sheets && pipenv install && pipenv run python sheet2linkml.py && cp output/CDM_Dictionary_v1_Active.yaml ../../model/schema/crdch_model.yaml && cd -
generate-model: install
CDM_GOOGLE_SHEET_ID=$(CDM_GOOGLE_SHEET_ID) $(RUN) python vendor/sheet2linkml/sheet2linkml.py --output model/schema/crdch_model.yaml

# MAM 20210806 not sure how this fits into the linkml model template's doc building/publsihing approach
# shoudn't it be using $(RUN) not ${RUN} ?
# Deploy changes to the `dev` version on the gh-pages branch.
# Note that this is not dependent on stage-docs, since you
# would generate the docs (usually as part of a `make all`)
# before you deploy it in a separate step.
#gh-deploy: pipenv-install
# ${RUN} mike deploy dev -p
gh-deploy: install
$(RUN) mike deploy dev -p

#### MAM 20210729
pypi:
Expand Down
31 changes: 21 additions & 10 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ verify_ssl = true
name = "pypi"

[packages]
linkml = {editable = true, ref = "ccdh-dev", git = "https://github.com/cancerDHC/linkml.git"} # required by cancerDHC
linkml-runtime = "~=1.0, >=1.0.3"
# For LinkML, we use the `ccdh-dev` branch, which we manually keep in sync with LinkML's main branch
# as well as some additional changes required for CRDCH generation.
linkml = {editable = true, ref = "ccdh-dev", git = "https://github.com/cancerDHC/linkml.git"}

# Since we use the development version of LinkML, we also use the development version of linkml-runtime.
# This may sometimes cause issues between this and LinkML.
linkml-runtime = {editable = true, git = "https://github.com/linkml/linkml-runtime.git"}

pyparsing = "<=2.4.7"
rdflib-pyld-compat = "*" # resinstating after removal by migration to linkml model template

[dev-packages]
black = "==v21.5b1" # from old generators/google-sheets/Pipfile
mike = "*"
mkdocs-material = "*"
pydantic = {extras = ["dotenv"], version = "*"} # from old generators/google-sheets/Pipfile
pygsheets = "*" # from old generators/google-sheets/Pipfile
pyparsing = "<=2.4.7" # indirectly from old generators/google-sheets/Pipfile
pyyaml = "*" # For reading and writing YAML files.

# Packages needed for testing.
pytest = "~=6.2.4"
pyyaml = "*" # from old generators/google-sheets/Pipfile
requests = "*" # from old generators/google-sheets/Pipfile
tox = "*"
twine = "*" # should this go in make-venv/Pipfile ?

# Packages needed by sheet2linkml.
black = "==v21.5b1" # Used for code linting.
requests = "*" # For making HTTP requests.
pygsheets = "*" # For accessing Google Sheets.
python-dotenv = "*" # For reading .env files.

# Packages needed for building and publishing documentation.
mike = "*"
mkdocs-material = "*"

[pipenv]
allow_prereleases = true # added by migration to linkml model template

Expand Down
565 changes: 270 additions & 295 deletions Pipfile.lock

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ Model documentation in Markdown can also be generated for this repository, and i

### Automated generation of YAML

The model YAML files are programmatically generated from [the Google Sheet](https://docs.google.com/spreadsheets/d/1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4/). The code that generates the YAMLs are in the [`./generators/google-sheets`](./generators/google-sheets) directory. The `regen-google-sheet` target in the Makefile can update the schema from Google Sheets automatically.
The CRDC-H model is currently in development on [a Google Sheet](https://docs.google.com/spreadsheets/d/1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4/).
This repository contains a program in the [`./generators/google-sheets`](./generators/google-sheets) directory,
gaurav marked this conversation as resolved.
Show resolved Hide resolved
called `sheet2linkml`, which can read the Google Sheet using the Google Drive API and generate a LinkML representation
of the model.

In order to run this program, 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)
sujaypatil96 marked this conversation as resolved.
Show resolved Hide resolved
are also available from the [`pygsheets` documentation](https://pygsheets.readthedocs.io/), which is the package we use to
access Google Sheets.

Once this is setup, run `make generate-model` to update the schema from Google Sheets. The first time you run this script,
you will see a browser page asking you to log in. Follow the instructions. The script will download a token and store it
locally. You won't need to log in in the future.

### Generation of LinkML artifacts

Expand Down
Loading