Skip to content

Commit

Permalink
resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Feb 1, 2022
2 parents 5f276b3 + 22803e8 commit d8c21e5
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: Build and test linkml-runtime

on: [push, pull_request]
on: [pull_request]

jobs:
test:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
run: poetry install --no-interaction

- name: Build source and wheel archives
run: poetry build
run: |
poetry version $(git describe --tags --abbrev=0)
poetry build
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
Expand Down
6 changes: 0 additions & 6 deletions AUTHORS

This file was deleted.

49 changes: 23 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contribution Guidelines

When contributing to this repository, please first discuss the change you wish to make via an issue, email, or any other method, with the owners of this repository before issuing a pull request.
When contributing to this repository, please first discuss the changes you wish to make via an issue, email, or any other method, with the owners of this repository before issuing a pull request.

## How to contribute

Expand All @@ -13,14 +13,7 @@ You can use the [Issues](https://github.com/linkml/linkml-runtime/issues) tab to
* Describe the behavior you observed after following the steps and point out what exactly is the problem with that behavior.
* Explain which behavior you expected to see instead and why.
* Provide screenshots of the expected or actual behaviour where applicable.

## General contribution instructions

1. Follow the [Github docs](https://docs.github.com/en/get-started/quickstart/fork-a-repo) to make a copy (a fork) of the repository to your own Github account.
2. [Clone the forked repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) to your local machine so you can begin making changes.
3. Make sure this repository is set as the [upstream remote repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-for-a-fork) so you are able to fetch the latest commits.
4. Push all your changes to a development branch, which is ideally a copy of the `main` branch of this repository.
5. Create pull requests from the development branch into the `main` branch when the code is ready to be merged into production.
* Tag the issue with appropriate label names. For ex., if your issue is about a bug that needs to be fixed in the repo, tag the issue with the `bug` label from the list of [labels](https://github.com/linkml/linkml-runtime/labels). If an appropriate label name doesn't exist, create one, with a name that clearly encapsulates the topic of the issue.

### The development lifecycle

Expand All @@ -31,50 +24,54 @@ You can use the [Issues](https://github.com/linkml/linkml-runtime/issues) tab to

Note: All the development must be done on a branch on your fork.

> An LBL engineer must review and accept your pull request. A code review (which happens with both the contributor and the reviewer present) is required for contributing.
> A code review (which happens with both the contributor and the reviewer present) is required for contributing.
## Development environment setup

1. Install [poetry](https://python-poetry.org/docs/#installation).
2. Clone the [linkml-runtime](https://github.com/linkml/linkml-runtime) repository.
2. Install all the dependencies from your project, which are typically specified in a `poetry.lock` file.

```
git clone https://github.com/linkml/linkml-runtime.git
poetry install
```

3. Change directory to the cloned `linkml-runtime` repo.
3. Run any python scripts or CLI commands by prefixing with `poetry run`.

```
cd linkml-runtime
poetry run python your_script.py # ex of how to run standalone python script
poetry run pytest # ex of how to invoke CLI tools
```

4. Install all the dependencies from your project, which are typically specified in a `poetry.lock` file.
4. Refer to the poetry docs for details on how to use the [add](https://python-poetry.org/docs/cli/#add), [update](https://python-poetry.org/docs/cli/#update) and [remove](https://python-poetry.org/docs/cli/#remove) commands.

```
poetry install
```
### Creating `requirements.txt`

5. Run any python scripts or CLI commands by prefixing with `poetry run`.
To export the list of dependents from the `poetry.lock` file into a `requirements.txt` file, use the following command:

```
poetry run python your_script.py
poetry run pytest
poetry export -f requirements.txt --output requirements.txt
```

## Release process

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.
Once the code has been merged into the `main` branch on this repo, there are a few steps that need to be completed to ensure a release is complete.

### Creating a release

* You should use the [releases](https://github.com/linkml/linkml-runtime/releases) section of the Github repo to draft a new release. Click on the *draft a new release* button. Annotate the release with a tag. Conventionally tags are prefixed with `v` so choose an appropriately versioned tag number. Ex., `v1.1.9` and such. Leave the default `main` branch as the target. Use the same tag number for the release title as well. After that, use Github's autogenerated CHANGELOG button to generate release notes. If it's possible to simplify the notes and make it more succinct, you should.
* Once a release is created, a [Github Action](.github/workflows/pypi-publish.yaml) will take care of publishing the package to PyPI for you. Verify that the latest release has been deployed to PyPI [here](https://pypi.org/project/linkml-runtime/).
* Use the [releases](https://github.com/linkml/linkml-runtime/releases) section of the Github interface to draft a new release.
* Conventionally tags are prefixed with `v` so choose an appropriately versioned tag number. Ex., `v1.1.9` and such.
* Leave the default `main` branch as the target. Use the same tag number for the release title as well. After that, use Github's autogenerated CHANGELOG button to generate release notes. If it's possible to simplify the notes and make it more succinct, you should.
* Once a release is created, a [Github Action](.github/workflows/pypi-publish.yaml) will take care of publishing the package to PyPI for you.

* Navigate to the [Actions](https://github.com/linkml/linkml-runtime/actions) tab, and verify that there is a ✅ next to the release tag that was just created. For ex., [v1.1.15](https://github.com/linkml/linkml-runtime/actions/runs/1656285916).
* Finally, check the package page on [PyPI](https://pypi.org/project/linkml-runtime/) to make sure the latest release was published.

## Testing

All code added to the linkml-runtime source must have tests. The repo uses pytest to run tests. The test code is located in the tests subdirectory.
All code added to the linkml-runtime source must have tests. The repo uses the native `unittest` module to run tests. The test code is located in the tests subdirectory.

You can run the test suite in the following way:


```
poetry run python -m unittest discover
```
Expand Down
155 changes: 0 additions & 155 deletions ChangeLog

This file was deleted.

11 changes: 11 additions & 0 deletions linkml_runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import rdflib_shim
shim = rdflib_shim.RDFLIB_SHIM

# use importlib.metadata to read the version provided
# by the package during installation. Do not hardcode
# the version in the code
try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata

LINKML = CurieNamespace('linkml', 'https://w3id.org/linkml/')
TCCM = CurieNamespace('tccm', 'https://ontologies.r.us/tccm/')
OWL = CurieNamespace('owl', OWL)
Expand All @@ -12,6 +20,9 @@
SKOS = CurieNamespace('skos', SKOS)
XSD = CurieNamespace('xsd', XSD)

__version__ = importlib_metadata.version(__name__)


class MappingError(ValueError):
"""
An error when mapping elements of a LinkML model to runtime objects
Expand Down
4 changes: 2 additions & 2 deletions linkml_runtime/loaders/json_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
from typing import Union, TextIO, Optional, Dict, Type

from hbreader import FileInfo
Expand All @@ -15,8 +16,7 @@ def loader(data: Union[str, dict], _: FileInfo) -> Optional[Dict]:
data_as_dict = json.loads(data) if isinstance(data, str) else data
typ = data_as_dict.pop('@type', None)
if typ and typ != target_class.__name__:
# TODO: connect this up with the logging facility or warning?
print(f"Warning: input type mismatch. Expected: {target_class.__name__}, Actual: {typ}")
logging.warning(f"Warning: input type mismatch. Expected: {target_class.__name__}, Actual: {typ}")
return self.json_clean(data_as_dict)

if not metadata:
Expand Down
23 changes: 18 additions & 5 deletions linkml_runtime/utils/schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,19 +1204,32 @@ def merge_schema(self, schema: SchemaDefinition) -> None:
dest = self.schema
for k, v in schema.prefixes.items():
if k not in dest.prefixes:
dest.prefixes[k] = copy(y)
dest.prefixes[k] = copy(v)
for k, v in schema.classes.items():
if k not in dest.classes:
dest.classes[k] = copy(y)
dest.classes[k] = copy(v)
for k, v in schema.slots.items():
if k not in dest.slots:
dest.slots[k] = copy(y)
dest.slots[k] = copy(v)
for k, v in schema.types.items():
if k not in dest.types:
dest.types[k] = copy(y)
dest.types[k] = copy(v)
for k, v in schema.enums.items():
if k not in dest.types:
dest.enums[k] = copy(y)
dest.enums[k] = copy(v)
self.set_modified()

def merge_imports(self):
"""
Merges the full imports closure
:return:
"""
schema = self.schema
to_merge = [s2 for s2 in self.all_schema(imports=True) if s2 != schema]
for s2 in to_merge:
self.merge_schema(s2)
schema.imports = []
self.set_modified()

def copy_schema(self, new_name: str = None) -> SchemaDefinition:
Expand Down
Loading

0 comments on commit d8c21e5

Please sign in to comment.