Skip to content

Commit

Permalink
Fix bug where SqlIndex models are not recognised correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Dec 13, 2020
1 parent 5da2304 commit 05456b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/machinable/index/sql_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def __init__(self, url, database, filesystem_model=None):
if isinstance(database, str):
database = dataset.connect(database)
self._db = database
if filesystem_model is None:
filesystem_model = SubmissionComponentModel.get()
self._filesystem_model = filesystem_model
if isinstance(url, Submission):
self.url = url.model.url
Expand All @@ -38,16 +40,15 @@ def __init__(self, url, database, filesystem_model=None):
self._data = url
url = url["url"]
self.url = url
self.submission_id = self.filesystem_model.submission_id
self.component_id = self.filesystem_model.component_id
parsed = parse_storage_url(self.url)
self.submission_id = parsed["submission_id"]
self.component_id = parsed["component_id"]

def submission_model(self, url):
return SqlSubmissionModel(url, self._db)

def submission_component_model(self, url):
return SqlSubmissionComponentModel(
url, self._db, filesystem_model=SubmissionComponentModel.get()
)
return SqlSubmissionComponentModel(url, self._db)


class SqlSubmissionModel(SqlBaseModel, FileSystemSubmissionModel):
Expand Down Expand Up @@ -95,7 +96,7 @@ def as_submission(self):
return Submission(self)


class SqlSubmissionComponentModel(SqlBaseModel, FileSystemSubmissionModel):
class SqlSubmissionComponentModel(SqlBaseModel, FileSystemSubmissionComponentModel):
@property
def filesystem_model(self):
if self._filesystem_model is None:
Expand Down
6 changes: 4 additions & 2 deletions tests/index/sql_index_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def test_sql_index(helpers):
latest = index.find_latest()
assert len(latest) > 0
since = latest.first().started_at
experiments = index.find_latest(since=since)
assert len(experiments) == 0
submissions = index.find_latest(since=since)
assert len(submissions) == 0
assert len(index.find_all()) > 0
submission = index.find("tttttt")
assert len(submission.components) == 4

0 comments on commit 05456b4

Please sign in to comment.