Skip to content

Commit f72ba62

Browse files
authored
New classifiers with scicrunch RRIDs (⚠️ devops) (#2045)
* Create submodule with logic to communicate with scicrunch.org * Added pg tables for scicrunch resources * split submodule for scicrunch * Extends groups api in webserver * Added handlers in groups (w/o implementation) and added scicrunch setup * Adds tests fixture * Improves OAS descriptions * Deduces links from settings and cleanup * Defined classifiers tree with Odei * Adds migration script for scircunrch resources * Adds column in group_classifiers to use scicrunch alternative * updates config * Adds tests for actual scicrunch service. Intended for manual exploratory testing of the actual service API * pytest-simcore: adds fixture to mock .env-devel * Implements and cleanup group/*/classifiers handlers * Fixes conflicting migration steps after master rebase * Fixes environ key name * Renamed column to uses_scicrunch * Fixes while manual testing * Moved scicrunch into a folder * reviews get_group_classifiers * renames scicrunch_api -> scicrunch.service_client * Removed testing in this PR (next!)
1 parent cb2a0e9 commit f72ba62

File tree

32 files changed

+2287
-588
lines changed

32 files changed

+2287
-588
lines changed

.env-devel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ S3_ENDPOINT=172.17.0.1:9001
3737
S3_SECRET_KEY=12345678
3838
S3_SECURE=0
3939

40+
SCICRUNCH_API_BASE_URL=https://scicrunch.org/api/1
41+
SCICRUNCH_API_KEY=REPLACE_ME_with_valid_api_key
42+
4043
SMTP_HOST=mail.speag.com
4144
SMTP_PORT=25
4245

api/specs/webserver/openapi-groups.yaml

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,81 @@ paths:
211211
$ref: "#/components/responses/DefaultErrorResponse"
212212

213213
/groups/{gid}/classifiers:
214+
get:
215+
parameters:
216+
- name: gid
217+
in: path
218+
required: true
219+
schema:
220+
type: string
221+
- name: tree_view
222+
in: query
223+
description: "Some classifiers (e.g. sparc's) offer different tree views"
224+
schema:
225+
type: string
226+
enum: [std, sort]
227+
default: std
228+
tags:
229+
- group
230+
summary: Gets classifiers bundle for this group
231+
operationId: get_group_classifiers
232+
responses:
233+
"200":
234+
description: got a bundle with all information about classifiers
235+
default:
236+
$ref: "#/components/responses/DefaultErrorResponse"
237+
238+
/groups/sparc/classifiers/scicrunch-resources/{rrid}:
214239
parameters:
215-
- name: gid
240+
- name: rrid
216241
in: path
217242
required: true
218243
schema:
219244
type: string
220245
get:
221246
tags:
222247
- group
223-
summary: Gets classifiers bundle for this group
224-
operationId: get_group_classifiers
248+
summary: "Returns information on a valid RRID (https://www.force11.org/group/resource-identification-initiative)"
249+
operationId: get_scicrunch_resource
225250
responses:
226251
"200":
227-
description: got a bundle with all information about classifiers
252+
description: Got information of a valid RRID
253+
"404":
254+
description: Cannot find a valid research resource for the provided RRID
255+
"503":
256+
description: Underline validation service is not reachable
257+
default:
258+
$ref: "#/components/responses/DefaultErrorResponse"
259+
post:
260+
tags:
261+
- group
262+
summary: "Adds new RRID to classifiers"
263+
operationId: add_scicrunch_resource
264+
responses:
265+
"200":
266+
description: Got information of a valid RRID
267+
"422":
268+
description: Invalid RRID
228269
default:
229270
$ref: "#/components/responses/DefaultErrorResponse"
230271

272+
/groups/sparc/classifiers/scicrunch-resources:search:
273+
get:
274+
parameters:
275+
- name: guess_name
276+
in: query
277+
required: true
278+
schema:
279+
type: string
280+
tags:
281+
- group
282+
summary: "Returns a list of related resource provided a search name"
283+
operationId: search_scicrunch_resources
284+
responses:
285+
"200":
286+
description: Got information of a valid RRID
287+
default:
288+
$ref: "#/components/responses/DefaultErrorResponse"
231289
components:
232290
responses:
233291
DefaultErrorResponse:

api/specs/webserver/openapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ paths:
119119
/groups/{gid}/classifiers:
120120
$ref: "./openapi-groups.yaml#/paths/~1groups~1{gid}~1classifiers"
121121

122+
/groups/sparc/classifiers/scicrunch-resources/{rrid}:
123+
$ref: "./openapi-groups.yaml#/paths/~1groups~1sparc~1classifiers~1scicrunch-resources~1{rrid}"
124+
125+
/groups/sparc/classifiers/scicrunch-resources:search:
126+
$ref: "./openapi-groups.yaml#/paths/~1groups~1sparc~1classifiers~1scicrunch-resources:search"
127+
128+
122129
# DATA STORAGE SERVICES ----------------------------------------------------------
123130

124131
/storage/locations:

packages/postgres-database/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requirements: ## compiles pip requirements (.in -> .txt)
1111

1212

1313
.PHONY: install-dev install-prod install-ci
14-
install-dev install-prod install-ci: requirements _check_venv_active ## install app in development/production or CI mode
14+
install-dev install-prod install-ci: _check_venv_active ## install app in development/production or CI mode
1515
# installing in $(subst install-,,$@) mode
1616
pip-sync requirements/$(subst install-,,$@).txt
1717

@@ -67,6 +67,7 @@ setup-prod: guard-POSTGRES_DATA_VOLUME install-dev up-prod ## sets up a database
6767

6868
.PHONY: setup-commit
6969
setup-commit: install-dev up-pg ## sets up a database to create a new commit into migration history
70+
sleep 2
7071
# discovering
7172
sc-pg --help
7273
sc-pg discover -u test -p test -d test

packages/postgres-database/doc/img/postgres-database-models.svg

Lines changed: 515 additions & 488 deletions
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Adds table for scicrunch rrids
2+
3+
Revision ID: 39fa67f45cc0
4+
Revises: 3452ca7b13e9
5+
Create Date: 2020-12-15 18:16:03.581479+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "39fa67f45cc0"
13+
down_revision = "3452ca7b13e9"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.create_table(
21+
"scicrunch_resources",
22+
sa.Column("rrid", sa.String(), nullable=False),
23+
sa.Column("name", sa.String(), nullable=False),
24+
sa.Column("description", sa.String(), nullable=True),
25+
sa.Column(
26+
"creation_date",
27+
sa.DateTime(),
28+
server_default=sa.text("now()"),
29+
nullable=False,
30+
),
31+
sa.Column(
32+
"last_change_date",
33+
sa.DateTime(),
34+
server_default=sa.text("now()"),
35+
nullable=False,
36+
),
37+
sa.PrimaryKeyConstraint("rrid"),
38+
)
39+
# ### end Alembic commands ###
40+
41+
42+
def downgrade():
43+
# ### commands auto generated by Alembic - please adjust! ###
44+
op.drop_table("scicrunch_resources")
45+
# ### end Alembic commands ###
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Adds column to use scicrunch alternative
2+
3+
Revision ID: b60363fe438f
4+
Revises: 39fa67f45cc0
5+
Create Date: 2020-12-15 18:26:25.552123+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "b60363fe438f"
13+
down_revision = "39fa67f45cc0"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.add_column(
21+
"group_classifiers",
22+
sa.Column("uses_scicrunch", sa.Boolean(), nullable=False, default=False),
23+
)
24+
# ### end Alembic commands ###
25+
26+
# Applies the default to all
27+
query = 'UPDATE "group_classifiers" SET uses_scicrunch=false;'
28+
op.execute(query)
29+
# makes non nullable
30+
query = 'ALTER TABLE "group_classifiers" ALTER "uses_scicrunch" SET NOT NULL;'
31+
op.execute(query)
32+
33+
34+
def downgrade():
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
op.drop_column("group_classifiers", "uses_scicrunch")
37+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/classifiers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"group_classifiers",
1818
metadata,
1919
sa.Column("id", sa.BigInteger, nullable=False),
20-
# TODO: add jsonschema validtion
2120
sa.Column("bundle", JSONB, nullable=False),
2221
sa.Column("created", sa.DateTime(), nullable=False, server_default=func.now()),
2322
sa.Column(
@@ -38,5 +37,7 @@
3837
),
3938
unique=True, # Every Group can ONLY have one set of classifiers
4039
),
40+
# uses scicrunch service to acccess curated classifiers instead of static bundle
41+
sa.Column("uses_scicrunch", sa.Boolean, nullable=False, default=False),
4142
sa.PrimaryKeyConstraint("id", name="group_classifiers_pkey"),
4243
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
""" Stores SOME of the information associated to Research Resource Identifiers (RRIDs) as defined in https://scicrunch.org/resources
2+
"""
3+
4+
import sqlalchemy as sa
5+
from sqlalchemy.sql import func
6+
7+
from .base import metadata
8+
9+
scicrunch_resources = sa.Table(
10+
"scicrunch_resources",
11+
metadata,
12+
sa.Column("rrid", sa.String, nullable=False, primary_key=True),
13+
sa.Column("name", sa.String, nullable=False),
14+
sa.Column("description", sa.String, nullable=True),
15+
sa.Column(
16+
"creation_date", sa.DateTime(), nullable=False, server_default=func.now()
17+
),
18+
sa.Column(
19+
"last_change_date",
20+
sa.DateTime(),
21+
nullable=False,
22+
server_default=func.now(),
23+
onupdate=func.now(), # this will auto-update on modification
24+
),
25+
)

packages/postgres-database/src/simcore_postgres_database/webserver_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"""
77
from .models.api_keys import api_keys
88
from .models.classifiers import group_classifiers
9-
from .models.comp_pipeline import comp_pipeline, StateType
10-
from .models.comp_tasks import DB_CHANNEL_NAME, comp_tasks, NodeClass
9+
from .models.comp_pipeline import StateType, comp_pipeline
10+
from .models.comp_tasks import DB_CHANNEL_NAME, NodeClass, comp_tasks
1111
from .models.confirmations import ConfirmationAction, confirmations
1212
from .models.groups import GroupType, groups, user_to_groups
1313
from .models.products import products
1414
from .models.projects import ProjectType, projects
15+
from .models.scicrunch_resources import scicrunch_resources
1516
from .models.tags import study_tags, tags
1617
from .models.tokens import tokens
1718
from .models.users import UserRole, UserStatus, users
@@ -25,6 +26,7 @@
2526
"UserStatus",
2627
"projects",
2728
"ProjectType",
29+
"scicrunch_resources",
2830
"confirmations",
2931
"ConfirmationAction",
3032
"tokens",

0 commit comments

Comments
 (0)