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

Ensuring that links point to index meta-dbs #34

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
68a2e86
Ensuring that links point to index meta-dbs
giovannipizzi Jun 11, 2020
16650d9
Running tests also on PRs
giovannipizzi Jun 11, 2020
bb551ab
Providing correctly the redirects with Netlify
giovannipizzi Jun 11, 2020
3a130a4
Fixing the tests after renaming folders
giovannipizzi Jun 11, 2020
f27908a
Replacing the docs on index meta-db with a generic template example
giovannipizzi Jun 11, 2020
e9bffa5
Adding `providers` link for cod and tcod
giovannipizzi Jun 11, 2020
cf5987c
Adding `providers` link for template example
giovannipizzi Jun 11, 2020
450a577
Remove trailing slashes from URLs
giovannipizzi Jun 11, 2020
e4f9d66
Using different prefix to allow coloring in output of GitHub actions
giovannipizzi Jun 11, 2020
8d48b68
Adapting link types and link_type attributes
giovannipizzi Jun 11, 2020
137603e
Merge branch 'fix_index_metadbs' of github.com:giovannipizzi/provider…
giovannipizzi Jun 11, 2020
a44dd09
Re-fixed the tests that had some issues
giovannipizzi Jun 11, 2020
7aa03f7
Apply suggestions from code review by Casper
giovannipizzi Jun 11, 2020
d433b0a
Fixing `link` -> `links`
giovannipizzi Jun 11, 2020
08b9fc1
Reinstating the link to the specific section of the Index MetaDB
giovannipizzi Jun 11, 2020
29d76d1
Some minor changes to the GitHub action
giovannipizzi Jun 11, 2020
0f04f8b
Fixing README.md that had outdated info
giovannipizzi Jun 11, 2020
f7d1a8d
Merge remote-tracking branch 'upstream/master' into fix_index_metadbs
giovannipizzi Jun 11, 2020
1c5910c
Apply suggestions from code review by Casper
giovannipizzi Jun 12, 2020
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
3 changes: 1 addition & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Scheduled validator

on:
push:
on: [push, pull_request]
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

jobs:
validate:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ __pycache__/
*.py[cod]
*$py.class

*~
.DS_Store

# C extensions
*.so

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ The repository is organized this way:

giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
Presently, only the `v1` version of the formats exist.
Hence, to update the list of providers, file a pull-request against the repository to edit `/src/links/v1/providers.json`.

## Requirements to be listed in this providers list

It is a policy of this providers list ([providers.optimade.org](http://providers.optimade.org)) that links inside `providers.json` must be links to an [OPTIMADE Index Meta-Database](https://github.com/Materials-Consortia/OPTIMADE/blob/develop/optimade.rst#32index-meta-database).

If you only have one or few databases in your implementation, and you do not want to host an Index Meta-Database yourself, you can host the Index Meta-Database directly in this repository. You can find instructions [here](./src/index-metadbs).
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# The exclamation mark at the end of the HTTP code is to make sure
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
# the redirect is always followed even if there is a file at that page.
# See https://docs.netlify.com/routing/redirects/rewrites-proxies/#shadowing

# Returning 200 just returns the content without doing a HTTP redirect, i.e.
# without changing the URL, that is what we want to achieve here
# https://docs.netlify.com/routing/redirects/redirect-options/#http-status-codes
/providers.json /src/links/v1/providers.json 200!
/v1/links /src/links/v1/providers.json 200!
/v1/info /src/info/v1/info.json 200!

# Provide redirects for index meta-databases (removing the JSON at the end)
/index-metadbs/:providerid/:version/links /src/index-metadbs/:providerid/:version/links.json 200!
/index-metadbs/:providerid/:version/info /src/index-metadbs/:providerid/:version/info.json 200!
1 change: 0 additions & 1 deletion providers.json

This file was deleted.

41 changes: 41 additions & 0 deletions src/index-metadbs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Static Index Meta-Databases

## Goal

This folder hosts static versions of Index Meta-Databases for those providers that only have one main sub-database (or very few sub-databases) and do not wish to maintain an Index Meta-Database themselves (Index Meta-Databases are described in the [OPTIMADE specifications](https://github.com/Materials-Consortia/OPTIMADE/blob/develop/optimade.rst)).
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

Note: while providing an (empty) Index Meta-Database is not required by the OPTIMADE API specifications, it is instead required in order to be listed in this List of Providers ([providers.optimade.org](http://providers.optimade.org)).
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

## When should I use a static index meta-database hosted in this repository
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

If you add a new provider and do not wish to host an Index Meta-Database yourself, feel free to add an Index Meta-Database here.

However, if your Index Meta-Database is rapidly changing (e.g. because the list of sub-databases changes often), please host it yourself to avoid multiple commits and pull requests to this repository at every change.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
Rare changes are instead of course welcome, e.g., if you have to change your DNS name or the description, or if you need just to add one static new sub-database, like a test database.

Note that "changes" here refer solely to changes to the *list of sub-databases*; the content of each sub-database can change at any time without the need to modify the Index Meta-Database.

## Instructions on how to add a new static Index Meta-Database
1. Go in the folder `src/index-metadbs`, copy the existing template folder (`exmpl`) to a new folder, where the folder name should be the identifier of your provider (we will use `exmpl2` here and in the following as the name of the new provider).
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
In particular, this will contain a `v1` subfolder, with two files inside it: `info.json` and `links.json`.

2. Adapt the content of the `links.json` file. In particular, provide a new `link` dictionary entry for each sub-database that you want to refer to.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
In the special case in which you have a single "main" sub-database, just change the existing values as follows:

- change the `id` to your provider identifier: `"exmpl" -> "exmpl2"`
- change the attributes `name`, `description` and `homepage` to contain the correct content. Please reuse the *same* content as the one you specified in the main `providers.json` file.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
- point the `base_url` to the base URL of your OPTIMADE implementation.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

3. Adapt the content of the `info.json` file. In particular, you should change two fields:
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

- change the URL of the `available_api_versions` by replacing `exmpl` with your identifier: `http://providers.optimade.org/index-metadbs/exmpl2/v1/`
- change the `id` inside `data->relationships->default->data->id` from `exmpl` to the correct ID from the list of links in the `links.json` file.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
As explained in the OPTIMADE specifications, this should be the ID of the database that should be considered as the "default" sub-database by clients.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

If you only have one sub-database and you followed the instructions above, you should use here your provider identifier.
If you do not wish to have a default database, remove completely the `relationships` attribute.
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved

4. In the top-level `providers.json` file, point the `base_url` of your provider to `http://providers.optimade.org/index-metadbs/exmpl/`.

5. Create a pull request, and check that all automated continuous-integration tests pass.
Also, you can check that the new Index Meta-Database properly works at the expected link using the Netlify preview (just click on the `netlify/optimade-providers/deploy-preview` entry of the GitHub checks that will appear in the GitHub PR Conversation page after a few seconds).
34 changes: 34 additions & 0 deletions src/index-metadbs/cod/v1/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"data" : {
"attributes" : {
"available_api_versions" : [
{
"version" : "1.0",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"url" : "http://providers.optimade.org/index-metadbs/cod/v1/"
}
],
"is_index" : true,
"formats" : [
"json"
],
"entry_types_by_format" : {
"json" : []
},
"available_endpoints" : [
"info",
"links"
],
"api_version" : "v1"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
},
"type" : "info",
"relationships" : {
"default" : {
"data" : {
"id" : "cod",
"type" : "link"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"id" : "/"
}
}
26 changes: 26 additions & 0 deletions src/index-metadbs/cod/v1/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data" : [
{
"id" : "cod",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "Crystallography Open Database",
"description": "Open-access collection of crystal structures of organic, inorganic, metal-organics compounds and minerals, excluding biopolymers",
"base_url": "https://www.crystallography.net/cod/optimade",
"homepage": "https://www.crystallography.net/cod",
"link_type": "child"
}
},
{
"id" : "optimade-providers",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "OPTIMADE Providers Index Meta-Database",
"description": "The list of OPTIMADE providers maintained by Materials-Consortia",
"base_url": "https://providers.optimade.org/",
"homepage": "https://www.optimade.org/",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"link_type": "providers"
}
}
]
}
34 changes: 34 additions & 0 deletions src/index-metadbs/exmpl/v1/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"data" : {
"attributes" : {
"available_api_versions" : [
{
"version" : "1.0",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"url" : "http://providers.optimade.org/index-metadbs/exmpl/v1/"
}
],
"is_index" : true,
"formats" : [
"json"
],
"entry_types_by_format" : {
"json" : []
},
"available_endpoints" : [
"info",
"links"
],
"api_version" : "v1"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
},
"type" : "info",
"relationships" : {
"default" : {
"data" : {
"id" : "exmpl",
"type" : "link"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"id" : "/"
}
}
26 changes: 26 additions & 0 deletions src/index-metadbs/exmpl/v1/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data" : [
{
"id" : "exmpl",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "Example provider",
"description": "Provider used for examples, not to be assigned to a real database",
"base_url": null,
"homepage": "https://example.com",
"link_type": "child"
}
},
{
"id" : "optimade-providers",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "OPTIMADE Providers Index Meta-Database",
"description": "The list of OPTIMADE providers maintained by Materials-Consortia",
"base_url": "https://providers.optimade.org/",
"homepage": "https://www.optimade.org/",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"link_type": "providers"
}
}
]
}
34 changes: 34 additions & 0 deletions src/index-metadbs/tcod/v1/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"data" : {
"attributes" : {
"available_api_versions" : [
{
"version" : "1.0",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"url" : "http://providers.optimade.org/index-metadbs/tcod/v1/"
}
],
"is_index" : true,
"formats" : [
"json"
],
"entry_types_by_format" : {
"json" : []
},
"available_endpoints" : [
"info",
"links"
],
"api_version" : "v1"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
},
"type" : "info",
"relationships" : {
"default" : {
"data" : {
"id" : "cod",
"type" : "link"
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"id" : "/"
}
}
26 changes: 26 additions & 0 deletions src/index-metadbs/tcod/v1/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data" : [
{
"id" : "cod",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "Theoretical Crystallography Open Database",
"description": "Open-access collection of theoretically calculated or refined crystal structures of organic, inorganic, metal-organic compounds and minerals, excluding biopolymers",
"base_url": "https://www.crystallography.net/tcod/optimade",
"homepage": "https://www.crystallography.net/tcod",
"link_type": "child"
}
},
{
"id" : "optimade-providers",
"type" : "link",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"attributes" : {
"name": "OPTIMADE Providers Index Meta-Database",
"description": "The list of OPTIMADE providers maintained by Materials-Consortia",
"base_url": "https://providers.optimade.org/",
"homepage": "https://www.optimade.org/",
giovannipizzi marked this conversation as resolved.
Show resolved Hide resolved
"link_type": "providers"
}
}
]
}
6 changes: 3 additions & 3 deletions src/links/v1/providers.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"attributes": {
"name": "Crystallography Open Database",
"description": "Open-access collection of crystal structures of organic, inorganic, metal-organics compounds and minerals, excluding biopolymers",
"base_url": "https://www.crystallography.net/cod/optimade",
"base_url": "http://providers.optimade.org/index-metadbs/cod",
"homepage": "https://www.crystallography.net/cod"
}
},
Expand All @@ -36,7 +36,7 @@
"attributes": {
"name": "Example provider",
"description": "Provider used for examples, not to be assigned to a real database",
"base_url": "https://example.com/optimade",
"base_url": "http://providers.optimade.org/index-metadbs/exmpl",
"homepage": "https://example.com"
}
},
Expand Down Expand Up @@ -156,7 +156,7 @@
"attributes": {
"name": "Theoretical Crystallography Open Database",
"description": "Open-access collection of theoretically calculated or refined crystal structures of organic, inorganic, metal-organic compounds and minerals, excluding biopolymers",
"base_url": "https://www.crystallography.net/tcod/optimade",
"base_url": "http://providers.optimade.org/index-metadbs/tcod",
"homepage": "https://www.crystallography.net/tcod"
}
}
Expand Down
Loading