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

feat: portal redesign #3485

Merged
merged 227 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
227 commits
Select commit Hold shift + click to select a range
ef0a3f1
prep
ebezzi Oct 19, 2022
09a2a49
more stuff
ebezzi Oct 19, 2022
dbe5e43
missing line
ebezzi Oct 19, 2022
563bba5
changes
ebezzi Oct 20, 2022
ae444d6
bunch of changes
ebezzi Oct 21, 2022
c11da6d
interface and tests
ebezzi Oct 24, 2022
47eddb9
Update backend/layers/common/entities.py
ebezzi Oct 24, 2022
5c30a76
temp stuff
ebezzi Oct 24, 2022
8821570
refactor, add documentation
ebezzi Oct 24, 2022
abef4eb
more refactor
ebezzi Oct 24, 2022
c3147c3
Merge branch 'ebezzi/redesign-persistence-layer' into ebezzi/business…
ebezzi Oct 24, 2022
55961ef
temp
ebezzi Oct 24, 2022
03095fd
typo
ebezzi Oct 24, 2022
08280ba
Merge branch 'ebezzi/redesign-persistence-layer' into ebezzi/business…
ebezzi Oct 24, 2022
8efccdc
Update backend/layers/persistence/persistence.py
ebezzi Oct 24, 2022
e880f72
more tests
ebezzi Oct 25, 2022
47b28f9
Update backend/layers/persistence/persistence.py
ebezzi Oct 25, 2022
5efda7c
Update backend/layers/persistence/persistence.py
ebezzi Oct 25, 2022
54a7de9
more tests
ebezzi Oct 25, 2022
bf81761
refactor
ebezzi Oct 25, 2022
1a79432
Update backend/layers/persistence/persistence.py
ebezzi Oct 25, 2022
88d7459
more tests
ebezzi Oct 25, 2022
5c63d70
even more stuff
ebezzi Oct 27, 2022
f796135
Changes
ebezzi Oct 27, 2022
1c7e9b6
PR comments
ebezzi Oct 27, 2022
731f2ce
PR suggestions, as code changes
atolopko-czi Oct 28, 2022
54f7d06
changes
ebezzi Oct 28, 2022
91a2325
conflicts
ebezzi Oct 28, 2022
7b30180
Merge pull request #3505 from chanzuckerberg/ebezzi/business-layer-un…
ebezzi Oct 28, 2022
8dc837b
Comments
ebezzi Oct 28, 2022
d2ac93c
conflicts
ebezzi Oct 28, 2022
70797fe
Remove owner from collection metadata
ebezzi Oct 28, 2022
9449356
rename
ebezzi Oct 28, 2022
8415bfa
more work
ebezzi Oct 31, 2022
cecc990
Remove all authorization from the business logic layer
ebezzi Oct 31, 2022
645ee71
Assertions for metadata validation errorS
ebezzi Oct 31, 2022
47bc9cc
More and more stuff
ebezzi Nov 1, 2022
370b491
convert everything to id classes
ebezzi Nov 1, 2022
d632c62
First pass
ebezzi Nov 1, 2022
98415eb
more files
ebezzi Nov 1, 2022
57e1ef6
more stuff
ebezzi Nov 1, 2022
7299627
TestCreateCollection ✅
ebezzi Nov 1, 2022
d781aa2
TestGetCollectionVersion ✅
ebezzi Nov 1, 2022
ac05425
TestGetAllCollections ✅
ebezzi Nov 2, 2022
d82ece3
Add one more test
ebezzi Nov 2, 2022
b057adc
chore: business layer tests for update collection (#3524)
ebezzi Nov 2, 2022
3ba51e0
signature
ebezzi Nov 2, 2022
e4d95e3
conflict resolution
ebezzi Nov 2, 2022
aa01554
Overhaul dataset processing status
ebezzi Nov 2, 2022
242c169
missing files
ebezzi Nov 2, 2022
1ae9861
fix enum mixin
ebezzi Nov 2, 2022
a47af3c
comments
ebezzi Nov 2, 2022
d15263b
few fixes
ebezzi Nov 2, 2022
f4897b3
TestUpdateCollectionDatasets ✅
ebezzi Nov 2, 2022
2ceae6a
TestGetDataset ✅
ebezzi Nov 3, 2022
375ce8c
TestUpdateDataset ✅
ebezzi Nov 3, 2022
41ba64d
TestCollectionOperations ✅
ebezzi Nov 3, 2022
7cfd73e
Merge branch 'main' into ebezzi/business-layer-unit-tests
ebezzi Nov 3, 2022
182f9cd
Link validation
ebezzi Nov 3, 2022
a06e8a2
Move business interface to another file
ebezzi Nov 3, 2022
9ea51f0
initial dump
ebezzi Nov 4, 2022
d140005
missing files
ebezzi Nov 4, 2022
dac2871
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 4, 2022
56be5e4
more tests
ebezzi Nov 7, 2022
7c6bb31
stuff
ebezzi Nov 8, 2022
21073a2
missing files
ebezzi Nov 8, 2022
b75dcc2
more stuff
ebezzi Nov 8, 2022
4cd6e1c
chore: add DatasetMetadata missing fields (#3572)
ebezzi Nov 8, 2022
270c7a8
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 8, 2022
72bc1a4
changes
ebezzi Nov 8, 2022
ba56193
Add name, x_approximate_distribution
ebezzi Nov 8, 2022
a2debca
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 8, 2022
c8d7803
baby steps
ebezzi Nov 8, 2022
1877df4
test__get_collection__ok ✅
ebezzi Nov 8, 2022
2ca7c46
many more tests ✅
ebezzi Nov 8, 2022
f4f22d1
small assertion
ebezzi Nov 8, 2022
178ff09
Link names can be optional
ebezzi Nov 8, 2022
27d593c
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 8, 2022
96ab9d1
stuff
ebezzi Nov 9, 2022
adbf9bc
fix bug + enforce immutability in several places
ebezzi Nov 9, 2022
0d1141d
conflict resolution
ebezzi Nov 9, 2022
c7c3326
many more tests ✅
ebezzi Nov 9, 2022
4c01fb5
moving to datasets
ebezzi Nov 9, 2022
975d8b2
chore: deepcopy in persistence_mock (#3578)
ebezzi Nov 9, 2022
52a20a4
Add DatasetArtifactId
ebezzi Nov 9, 2022
df5d9c3
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 9, 2022
081326d
more tests
ebezzi Nov 9, 2022
ec6bdb9
start
ebezzi Nov 9, 2022
9795c21
functions
ebezzi Nov 9, 2022
02f6513
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 9, 2022
1f9797a
baby steps
ebezzi Nov 9, 2022
724aaa7
ingest_dataset now also returns canonical dataset_id
ebezzi Nov 9, 2022
ac80f59
Merge branch 'ebezzi/business-layer-impl' into ebezzi/api-layer-inter…
ebezzi Nov 9, 2022
9bb1d90
test__get_all_datasets_for_index_with_ontology_expansion ✅
ebezzi Nov 9, 2022
b76e010
missing files
ebezzi Nov 9, 2022
2b5d3bd
test__get_dataset_assets ✅
ebezzi Nov 9, 2022
9a75632
rework base class
ebezzi Nov 10, 2022
322754b
revision tests - first pass
ebezzi Nov 10, 2022
a5c9836
stuff
ebezzi Nov 10, 2022
69f93d7
TestRevision ✅
ebezzi Nov 10, 2022
03d3c2a
TestDeleteRevision ✅
ebezzi Nov 10, 2022
96bdd47
Fix a bunch of pending tests
ebezzi Nov 10, 2022
6eeb297
chore: add dataset_version -> collection_id link
ebezzi Nov 10, 2022
2ace524
Merge branch 'ebezzi/business-layer-impl-dataset-collection-link' int…
ebezzi Nov 10, 2022
62998f0
temp
ebezzi Nov 10, 2022
3ad30cc
chore: add methods to get versions from a canonical collection_id
ebezzi Nov 10, 2022
b705372
stuff
ebezzi Nov 11, 2022
0548da7
one more test
ebezzi Nov 11, 2022
837a2ec
upload tests
ebezzi Nov 13, 2022
369102d
more tests ✅
ebezzi Nov 14, 2022
1ba1706
upload link tests ✅
ebezzi Nov 14, 2022
36bfa21
Publish collection ✅
ebezzi Nov 14, 2022
ee506b5
chore: add dataset_version -> collection_id link (#3585)
ebezzi Nov 14, 2022
f367d77
chore: collection versions can only be created one at a time (#3582)
ebezzi Nov 14, 2022
89d4940
chore: add methods to get versions from a canonical collection_id (#3…
ebezzi Nov 14, 2022
a7676e2
Merge from business layer branch
ebezzi Nov 14, 2022
a52774a
Merge from forked branch
ebezzi Nov 14, 2022
898a710
last minute changes
ebezzi Nov 14, 2022
c2658fa
initial stuff
ebezzi Nov 15, 2022
7b603bc
more stuff
ebezzi Nov 15, 2022
191dffa
several advancements
ebezzi Nov 15, 2022
366b014
stuff
ebezzi Nov 15, 2022
2670abe
more stuff
ebezzi Nov 15, 2022
9034dfd
fix: Migration task fails to start (#3588)
alexlokshin-czi Nov 15, 2022
d014f84
Merge pull request #3533 from chanzuckerberg/ebezzi/business-layer-impl
ebezzi Nov 16, 2022
02166d4
Merge branch 'main' into ebezzi/business-layer-unit-tests
ebezzi Nov 16, 2022
44575a1
Fix commits
ebezzi Nov 16, 2022
4442758
Merge
ebezzi Nov 16, 2022
f2c35fd
stuff
ebezzi Nov 16, 2022
51b9212
stuff
ebezzi Nov 16, 2022
da8c949
temp change
ebezzi Nov 16, 2022
82dbf44
unit tests attempt
ebezzi Nov 17, 2022
bdf4abe
more unit tests
ebezzi Nov 17, 2022
5d07526
more unit tests
ebezzi Nov 17, 2022
f171f68
happy path
ebezzi Nov 17, 2022
8fc192c
s3 provider
ebezzi Nov 17, 2022
bd8997a
more implementations
ebezzi Nov 17, 2022
a18caa0
stuff
ebezzi Nov 18, 2022
6812c6f
Changes
ebezzi Nov 18, 2022
4ca6975
add mock
ebezzi Nov 18, 2022
4ecc989
stuff
ebezzi Nov 18, 2022
5ad9821
fix test
ebezzi Nov 18, 2022
b078993
Merge pull request #3577 from chanzuckerberg/ebezzi/api-layer-interface
ebezzi Nov 21, 2022
cc8f67c
typo
ebezzi Nov 21, 2022
246a4fc
typo
ebezzi Nov 21, 2022
50203bd
meta endpoint
ebezzi Nov 21, 2022
16c78fe
conflict
ebezzi Nov 21, 2022
e470d1d
weird merge
ebezzi Nov 21, 2022
dfd1bdf
remove outdated stuff
ebezzi Nov 21, 2022
9c75a11
Remove old test
ebezzi Nov 21, 2022
dd49a1a
one more test
ebezzi Nov 21, 2022
c91f1d6
fixes
ebezzi Nov 22, 2022
4ca7937
stuff
ebezzi Nov 22, 2022
b372b53
tmp remove curator_name
ebezzi Nov 22, 2022
2bfc69c
merge
ebezzi Nov 22, 2022
bc9b7df
Add field
ebezzi Nov 22, 2022
d85d043
one fix
ebezzi Nov 22, 2022
f7aac2d
more stuff
ebezzi Nov 22, 2022
fc19054
overhaul
ebezzi Nov 22, 2022
e4d6afa
Rename class
ebezzi Nov 22, 2022
f71f85f
rename published_at -> originally_published_at
ebezzi Nov 22, 2022
8fd48f5
feat: explicit canonical collection (#3622)
ebezzi Nov 22, 2022
acf1821
Merge branch 'ebezzi/business-layer-unit-tests' of github.com:chanzuc…
ebezzi Nov 22, 2022
fa0f817
timestamps
ebezzi Nov 22, 2022
22b8384
timestamps 2
ebezzi Nov 22, 2022
5bffc30
feat: persistence layer
nayib-jose-gloria Nov 23, 2022
2a15999
feat: add persistence implementation (first draft)
nayib-jose-gloria Nov 23, 2022
9c0a1e6
feat: add finalization of canonical dataset on collection version pub…
nayib-jose-gloria Nov 28, 2022
8c4ea50
feat: redesign canonical dataset (#3627)
ebezzi Nov 28, 2022
a0b04ca
merge from feature branch
ebezzi Nov 28, 2022
fef5d22
partial changes
ebezzi Nov 28, 2022
7f835c1
add set-up to create schema from persistence orm
nayib-jose-gloria Nov 28, 2022
51b2e39
Merge branch 'nayib/persistence-layer' of https://github.com/chanzuck…
nayib-jose-gloria Nov 28, 2022
630aa64
fixes to the ORM
ebezzi Nov 28, 2022
00c4b40
Merge branch 'nayib/persistence-layer' of github.com:chanzuckerberg/c…
ebezzi Nov 28, 2022
5a73f65
fix method call
nayib-jose-gloria Nov 28, 2022
a3ff048
fix: use DatabaseProvider for test_business and update persistence la…
nayib-jose-gloria Nov 28, 2022
3b9bfb0
stuff
ebezzi Nov 29, 2022
f7d3e0d
stuff
ebezzi Nov 30, 2022
e46aebc
fix TestCollectionOperations tests
nayib-jose-gloria Dec 1, 2022
597fb51
persistence layer changes (#3650)
ebezzi Dec 1, 2022
0e93738
Merge from feature branch
ebezzi Dec 1, 2022
a8473d9
Merge branch 'nayib/persistence-layer' into ebezzi/processing-layer
ebezzi Dec 1, 2022
6aa0ffa
changes
ebezzi Dec 1, 2022
ef94dd0
pr feedback
nayib-jose-gloria Dec 1, 2022
a985b44
Merge branch 'nayib/persistence-layer' of https://github.com/chanzuck…
nayib-jose-gloria Dec 1, 2022
97ea264
Various bugs&fixes
ebezzi Dec 2, 2022
b997403
fixes
nayib-jose-gloria Dec 2, 2022
2e59b6a
Merge branch 'ebezzi/processing-layer' of https://github.com/chanzuck…
nayib-jose-gloria Dec 2, 2022
7ca3661
Merge branch 'main' into ebezzi/business-layer-unit-tests
Bento007 Dec 3, 2022
8602a32
fix tests and pr feedback
nayib-jose-gloria Dec 5, 2022
7bd523a
Merge pull request #3631 from chanzuckerberg/nayib/persistence-layer
nayib-jose-gloria Dec 5, 2022
637c224
feat: processing layer (#3603)
ebezzi Dec 5, 2022
33bc4e4
Merge branch 'main' into ebezzi/business-layer-unit-tests
Bento007 Dec 5, 2022
dbb66dd
feat: migration script + some fixes (#3681)
ebezzi Dec 7, 2022
9d8b9e2
black and flake8
Bento007 Dec 7, 2022
61021bc
black and flake8
Bento007 Dec 7, 2022
8c5a05b
fix: publisher metadata correct type (#3699)
ebezzi Dec 8, 2022
b3135e0
fix: allows business tests to be run by both persistence mock and as …
nayib-jose-gloria Dec 8, 2022
379e292
lint
nayib-jose-gloria Dec 8, 2022
a4a0910
merge feature branch
nayib-jose-gloria Dec 8, 2022
c9efaab
Merge pull request #3700 from chanzuckerberg/nayib/fix-business-tests
nayib-jose-gloria Dec 8, 2022
850be81
feat: revise at for curation api (#3675)
Bento007 Dec 8, 2022
9832e57
Merge branch 'main' into ebezzi/business-layer-unit-tests
Bento007 Dec 8, 2022
b06d19f
fix merge conflict
Bento007 Dec 8, 2022
f106477
fix: get portal API tests working with persistence mock
nayib-jose-gloria Dec 8, 2022
049e409
fix: get portal API tests working with database provider implementation
nayib-jose-gloria Dec 8, 2022
ed194a8
refactor: simplify session management + include option to run tests a…
nayib-jose-gloria Dec 9, 2022
210d6a3
pr feedback
nayib-jose-gloria Dec 9, 2022
764a4cc
Merge pull request #3704 from chanzuckerberg/nayib/fix-portal-api-tests
nayib-jose-gloria Dec 9, 2022
794c305
fix: processing tests (#3715)
ebezzi Dec 12, 2022
c1429ac
fix: strip -> removesuffix (#3716)
ebezzi Dec 12, 2022
b3deaca
chore: redesign run tests in GHA (#3694)
ebezzi Dec 12, 2022
7a8be4e
feat: add canonical collection tombstoning to portal redesign (#3740)
nayib-jose-gloria Dec 13, 2022
24fafb2
feat: set validation message (#3735)
ebezzi Dec 14, 2022
34f386d
chore: redesign miscellaneous fixes (#3739)
ebezzi Dec 14, 2022
7d2f98e
chore: restore processing tests (#3736)
ebezzi Dec 14, 2022
48cf1a9
chore: restore cloudfront invalidation (#3761)
ebezzi Dec 15, 2022
69b29e3
chore: curator name (#3780)
ebezzi Dec 16, 2022
0dd0319
feat: translate curation api for redesign (#3690)
Bento007 Dec 16, 2022
fb7904c
chore: curator API fix tests (#3782)
ebezzi Dec 19, 2022
0eb3314
chore: add curator_name to migration script (#3791)
ebezzi Dec 19, 2022
ee9b967
chore: redesign last minute fixes (#3792)
ebezzi Dec 19, 2022
511eaf1
feat: add integration test mode as a gha test step + makefile command…
nayib-jose-gloria Dec 19, 2022
30b6b2c
chore: last minute fixes #2 (#3794)
ebezzi Dec 19, 2022
1314000
Merge branch 'main' into ebezzi/business-layer-unit-tests
ebezzi Dec 19, 2022
2e2fdf8
update ontology test
ebezzi Dec 19, 2022
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
186 changes: 186 additions & 0 deletions backend/layers/business/business.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
from dataclasses import dataclass
from typing import Iterable, Optional

from backend.layers.common.entities import CollectionMetadata, CollectionVersion, DatasetArtifact, DatasetStatus, DatasetVersion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will everything be nested under layers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now it's good to keep it there for separation. Eventually we could just remove that folder and free up one level.

from backend.layers.persistence.persistence import DatabaseProviderInterface
from backend.layers.thirdparty.crossref_provider import CrossrefProviderInterface
from backend.layers.thirdparty.step_function_provider import StepFunctionProviderInterface


@dataclass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asume these datatypes will need to be reference by adjacent layers, should they be in a common location?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can either put them all in the common folder or keep them closer to the layer which is most logically connected to them. I'm ok with both solutions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserInfo seems like an entity to me, so I'd suggest moving to common.entities.User. Even it's not persisted.

Does owner == UserInfo.user_id?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, UserInfo is mostly a stub, I still need to figure out how do we want to shape it (hence my skipping the authorization tests)

class CollectionQueryFilter:
visibility: Optional[str] # Use an enum
owner: Optional[str]
# TODO: add list of fields to be returned (if needed)

@dataclass
class UserInfo:
user_id: str
token: str


class BusinessLogicInterface:

# Get_collections
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a docstring under get_collections

def get_collections():
    """ 
        Replaces get_collections_list and get_collections_index
        Accepts a CollectionFilter class (or kwargs) with:
        Date bounds
        Visibility
        Ownership
        List of fields to be returned
        Accepts an UserInfo object
        Returns a list of dictionaries that only includes the selected fields for each collection
        It should NOT add any information that is required by the current API for compatibility reasons (e.g. access_write). These will be delegated the upper layer
        It should NOT do any operation that is required by Curation API assumptions (e.g. remove None values)
"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading these comments and how mentions the soon to be deprecaited functions, it reads more like notes for future implementation not actual documentation. Is that how I should be interpretting it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is a copy-paste from the tech spec. Eventually, I'll rewrite it into proper docs.

# Replaces get_collections_list and get_collections_index
# Accepts a CollectionFilter class (or kwargs) with:
# Date bounds
# Visibility
# Ownership
# List of fields to be returned
# Accepts an UserInfo object
# Returns a list of dictionaries that only includes the selected fields for each collection
# It should NOT add any information that is required by the current API for compatibility reasons (e.g. access_write). These will be delegated to the upper layer
# It should NOT do any operation that is required by Curation API assumptions (e.g. remove None values)

def get_collections(self, filter: CollectionQueryFilter, user_info: UserInfo) -> Iterable[CollectionVersion]:
pass


# Get_collection
# Replaces get_collection_details
# Returns a single collection, with no filtering options
# Accepts:
# Collection_id
# UserInfo for validation
# Should reuse most of of the code from the method above

def get_collection(self, collection_id: str, user_info: UserInfo) -> CollectionVersion:
pass

def get_collection_version(self, version_id: str, user_info: UserInfo) -> CollectionVersion
pass

# Create_collection
# Replaces the current create_collection
# Accepts:
# A dictionary (or Class) with the body of the collection to be created
# UserInfo
# Should validate the body accepted as param (see existing verify_collection_body)
# Should call CrossrefProvider to retrieve publisher metadata information
# This method currently collects errors in a list, which will be piped upstream to the API response. This is a good idea but it should be refactor into a generalized pattern (otherwise we’ll “pollute” the business layer with logic specific to the API layer).

def create_collection(self, collection_metadata: CollectionMetadata, user_info: UserInfo) -> CollectionVersion:
pass

# Delete_collection
# Replaces the current delete_collection
# Accepts:
# Collection_id
# UserInfo
# Performs authorization on user/collection

def delete_collection(self, collection_id: str, user_info: UserInfo) -> None:
pass

# Update_collection
# Replaces the current update_collection
# Accepts:
# Collection_id
# UserInfo
# A dataclass with the body to be updated
# Should validate the body
# Should handle DOI updates (re-use the existing logic with minimal refactors)
# Can either return nothing or the metadata of the updated collection

# TODO: body should be a dataclass?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't it be CollectionMetadata? If not using that because it also includes links then maybe links should be treated as publisher_metadata, i.e. moved up a level into CollectionVersion and updated via a separate method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no, owner cannot be changed via an update.

def update_collection_version(self, version_id: str, body: dict, user_info: UserInfo) -> None:
pass

# Create_collection_version
# Replaces the current post_collection_revision
# Accepts:
# Collection_id
# UserInfo
# Performs authorization on the collection
# Since revision logic is database specific, it delegates to the underlying layer
# Returns a handle to the revised collection (either id or the full collection metadata)

def create_collection_version(self, collection_id: str, user_info: UserInfo) -> CollectionVersion:
pass

def delete_collection_version(self, version_id: str, user_info: UserInfo) -> None:
pass


# Publish_collection
# Replaces post (in publish.py)
# Accepts:
# Collection_id
# UserInfo
# Performs validation to make sure that the collection can be published
# [Currently] accepts data_submission_policy_version: what is this for?
# [Currently] triggers Cloudfront invalidation for the index endpoints. This should arguably NOT be done here but by the API layer
# Since revision logic is database specific, it delegates to the underlying layer

def publish_collection_version(self, version_id: str, user_info: UserInfo) -> None:
pass

# Ingest_dataset
# Replaces the existing Upload_from_link
# Potentially, also replaces relink (I am not sure why they are 2 separate functions)
# Accepts:
# Collection_id
# UserInfo
# URL of the uploadable dataset
# [Optional] a dataset_id to be replaced
# This is one of the most complex functions. Other than the database provider, It will need two additional providers:
# StepFunctionProvider (to call the SFN that triggers the upload)
# DropboxProvider to interface with Dropbox (could be more generic: RemoteFileProvider?)
# Should handle exceptions from all providers:
# Should only raise custom exceptions

def ingest_dataset(self, collection_version_id: str, url: str, existing_dataset_version_id: Optional[str], user_info: UserInfo) -> str:
pass

# Get_all_datasets
# Replaces get_dataset_index

def get_all_datasets(self) -> Iterable[DatasetVersion]:
pass

# Delete_dataset
# Replaces delete_dataset

def delete_dataset(self, dataset_version_id: str) -> None:
pass


# get_dataset_assets
# Replaces get_dataset_assets

def get_dataset_artifacts(self, dataset_id: str) -> Iterable[DatasetArtifact]:
pass


# Download_dataset_asset
# Replaces post_dataset_asset


def download_dataset_asset(self, dataset_id: str) -> str:
pass

# Get_dataset_status
# Replaces get_status

def get_dataset_status(self, dataset_id: str) -> DatasetStatus:
pass


# TODO: move it to a separate file
class BusinessLogic(BusinessLogicInterface):

database_provider: DatabaseProviderInterface
crossref_provider: CrossrefProviderInterface
step_function_provider: StepFunctionProviderInterface

def __init__(
self,
database_provider: DatabaseProviderInterface,
crossref_provider: CrossrefProviderInterface,
step_function_provider: StepFunctionProviderInterface,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there anything to initialize in BusinessLogicInterface, else remove super().__init__()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will get rid of it, thanks. I think @atolopko-czi suggested to use ABC which would make interfaces look neater.

) -> None:
self.crossref_provider = crossref_provider
self.database_provider = database_provider
self.step_function_provider = step_function_provider
super().__init__()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these class variables?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think they should be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These

database_provider: DatabaseProviderInterface
crossref_provider: CrossrefProviderInterface
step_function_provider: StepFunctionProviderInterface

Should be variables set in the __init__

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're set in __init__. Those are just a type declaration but they're not defined as class variables.

67 changes: 67 additions & 0 deletions backend/layers/common/entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from dataclasses import dataclass
from datetime import datetime
from typing import List, Optional
from enum import Enum

class DatasetStatus(Enum):
NA = "N/A"
WAITING = "Waiting"
UPLOADING = "Uploading"
UPLOADED = "Uploaded"
FAILED = "Failed"
CANCEL_PENDING = "Cancel pending"
CANCELED = "Canceled"

@dataclass
class DatasetArtifact:
type: str
uri: str


@dataclass
class DatasetMetadata:
organism: str
tissue: str
assay: str
disease: str
sex: str
self_reported_ethnicity: str
development_stage: str
cell_type: str
cell_count: int


@dataclass
class DatasetVersion:
dataset_id: str
version_id: str
processing_status: DatasetStatus
metadata: DatasetMetadata
artifacts: List[DatasetArtifact]


@dataclass
class Link:
name: str
type: str
uri: str

@dataclass
class CollectionMetadata:
name: str
description: str
owner: str
contact_name: str
contact_email: str
links: List[Link] # TODO: use a dataclass


@dataclass
class CollectionVersion:
collection_id: str
version_id: str
owner: str
metadata: CollectionMetadata
publisher_metadata: Optional[dict] # TODO: use a dataclass
datasets: List[DatasetVersion]
published_at: Optional[datetime]
Loading