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 testing #21

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
45 changes: 24 additions & 21 deletions .github/workflows/pytest.yaml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Built from:
# https://docs.github.com/en/actions/guides/building-and-testing-python

name: Test and check code style
name: black

on: [push, pull_request]

jobs:
test:
black:

runs-on: ubuntu-latest

strategy:
Expand All @@ -16,7 +17,7 @@ jobs:
steps:

#----------------------------------------------
# check-out repo and set-up python
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
Expand All @@ -27,39 +28,41 @@ jobs:
python-version: ${{ matrix.python-version }}

#----------------------------------------------
# cache poetry installation
# install & configure poetry
#----------------------------------------------
- name: Cache Poetry files
id: cache-poetry
uses: actions/cache@v2
- name: Install Poetry
uses: snok/[email protected]
with:
path: ~/.local
key: ${{ runner.os }}-python-${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
virtualenvs-create: true
virtualenvs-in-project: true

#----------------------------------------------
# install & configure poetry
# load cached venv if cache exists
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# install dependencies
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
run: poetry install --no-interaction
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

#----------------------------------------------
# run tests
# install your root project, if required
#----------------------------------------------
- name: Run tests
env:
SHEET2LINKML_GOOGLE_SERVICE_ACCT: ${{ secrets.Sheet2LinkMLGoogleServiceAcct }}
run: poetry run pytest -svvv
- name: Install library
run: poetry install --no-interaction

#----------------------------------------------
# check formatting
# check formatting
#----------------------------------------------
- name: Code style with black
- name: Code formatting with black
run: |
# run black in check mode
# if files are not formatted correctly, the build will not go through
Expand Down
54 changes: 15 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Releases](https://github.com/cancerDHC/sheet2linkml/releases)

## [Unreleased]
* Feature: added a dummy Google Sheet, the expected schema, and a test to compare them.
* Feature: cleaned up GitHub Action for style checks and added PyTest.
* Feature: added support for storing Google API credentials in an environmental variable, and added it to
GitHub Actions.
* Feature: added check for Google Sheet ID.
* Feature: updated @cached_property with @property @lru_cache to support Python 3.7.
* Bug: updated CCDH Terminology API endpoint for enumerations.
* Bug: fixed code to correctly handle 404 responses from the TCCM Terminology Service.
* Bug: replaced unnecessary print() in GSheetModel with logging.error().

## [v1.2.0] - 2021-11-29
## [v1.0.0](https://github.com/cancerDHC/sheet2linkml/releases/tag/v1.0.0)

* Separate enums from codeable concepts

## [v1.1.1] - 2021-11-11

* Updated minimum Python version from 3.9 to 3.7, thanks to changes from v1.1.0
* First working release of `sheet2linkml`
* Package deployed to PyPI
* In its current state, it is meant to be used only as a dependency for ccdhmodel
* It is compatible with Python version 3.9 and higher

## [v1.1.0] - 2021-10-28

* Retroactive code style formatting of the entire codebase using Black
* Added a Github Action that checks if checked in code is Black formatted
* Modified the code to be compatible with Python versions 3.7 and 3.8 by using `typing.List` and `typing.Dict`
* Added this CHANGELOG
## [v1.0.1](https://github.com/cancerDHC/sheet2linkml/releases/tag/v1.0.1)

## [v1.0.1] - 2021-10-04
* Added `python-dotenv` to list of core dependencies

* Improved README
* Moved `python-dotenv` to list of core dependencies
## [v1.0.2]

## [v1.0.0] - 2021-09-30
* Retroactive black formatting of entire codebase
* Github Action that checks if checked in code is black formatted
* Compatible with Python versions 3.7 and 3.8

* Added CONTRIBUTING documentation
* Package deployed to PyPI
* In its current state, it is meant to be used only as a dependency for ccdhmodel
* It is compatible with Python version 3.9 and higher
## [v1.1.1]

## [v0.0.1] - 2021-09-29
* Update the version of Python that the package depends on in the pyproject.toml

* First working release of `sheet2linkml`
## [v1.2.0]

[Unreleased]: https://github.com/cancerDHC/sheet2linkml/compare/v1.2.0...HEAD
[v1.2.0]: https://github.com/cancerDHC/sheet2linkml/compare/v1.1.1...v1.2.0
[v1.1.1]: https://github.com/cancerDHC/sheet2linkml/compare/v1.1.0...v1.1.1
[v1.1.0]: https://github.com/cancerDHC/sheet2linkml/compare/v1.0.1...v1.1.0
[v1.0.1]: https://github.com/cancerDHC/sheet2linkml/compare/v1.0.0...v1.0.1
[v1.0.0]: https://github.com/cancerDHC/sheet2linkml/compare/v0.0.1...v1.0.0
[v0.0.1]: https://github.com/cancerDHC/sheet2linkml/releases/tag/v0.0.1
* Separate enums from codeable concepts
24 changes: 0 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,6 @@ poetry run black ~/path/to/directory

## Release process

The branch names follow the convention described by the [git flow](https://nvie.com/posts/a-successful-git-branching-model/)
branching model. Release branches are created to support the preparation of a new production release.

Steps to follow when issuing a new release:

```
git checkout -b release-1.2 develop # Switched to a new branch "release-1.2"

# minor bug fixes and preparing metadata for a release
# e.g., version number, build dates
# commit changes

# merge changes into "main"
git checkout main # switched to branch "main"
git merge --no-ff release-1.2 # merge into "main" with summary of changes

# merge changes into "develop"
git checkout develop # switched to branch "develop"
git merge --no-ff release-1.2 # merge into "develop" with summary of changes

# remove release branch
git branch -d release-1.2 # deleted branch release-1.2
```

Once the code has been merged into the `main` branch on this repo, there are two processes that need to be completed
to ensure a release is complete.

Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,17 @@ source .venv/bin/activate
python -m pip install sheet2linkml
```

## 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/).

## Command Line Client Usage

Identify the Google Sheet that you want to convert to LinkML. Note that sheet2linkml is not currently a general-purpose Google Sheet to LinkML converter. It will only work with Google Sheets that have been written in a particular, currently undefined format.

Contact your CCDH colleagues to obtain the correct sheet ID and assert it either in a `.env` file or in the shell, like this:

```shell
export CDM_GOOGLE_SHEET_ID=1oWS7cao-fgz2MKWtyr8h2dEL9unX__0bJrWKv6mQmM4
export CDM_GOOGLE_SHEET_ID=WbM2Jr869ofmdcSmhX_1E0aLWvnK2-gr47Mo_tzuQKWy
```

A `google_api_credentials.json` file is also required in the root of this repo as detailed in the Authorization section above.
A `google_api_credentials.json` file is also required in the root of this repo. Documentation is forthcoming.

And the user is responsible for defining
- `~/path/to/crdch_model.yaml`
Expand Down
Loading