-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from DiamondLightSource/objectmodel
More object model work
- Loading branch information
Showing
11 changed files
with
189 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import ispyb.model | ||
|
||
class GridInfo(ispyb.model.DBCache): | ||
'''An object representing a GridInfo database entry. The object | ||
lazily accesses the underlying database when necessary and exposes record | ||
data as python attributes. | ||
''' | ||
|
||
def __init__(self, dcgid, db_conn, preload=None): | ||
'''Create a GridInfo object for a defined DCGID. Requires | ||
a database connection object exposing further data access methods. | ||
:param dcgid: DataCollectionGroupID | ||
:param db_conn: ISPyB database connection object | ||
:return: A GridInfo object representing the database entry for | ||
the specified DataCollectionGroupID | ||
''' | ||
self._db = db_conn | ||
self._dcgid = int(dcgid) | ||
if preload: | ||
self._data = preload | ||
|
||
def reload(self): | ||
'''Load/update information from the database.''' | ||
raise NotImplementedError('TODO: Not implemented yet') | ||
|
||
@property | ||
def dcgid(self): | ||
'''Returns the DataCollectionGroupID.''' | ||
return self._dcgid | ||
|
||
def __repr__(self): | ||
'''Returns an object representation, including the DataCollectionGroupID, | ||
the database connection interface object, and the cache status.''' | ||
return '<GridInfo #%d (%s), %r>' % ( | ||
self._dcgid, | ||
'cached' if self.cached else 'uncached', | ||
self._db | ||
) | ||
|
||
def __str__(self): | ||
'''Returns a pretty-printed object representation.''' | ||
if not self.cached: | ||
return 'GridInfo #%d (not yet loaded from database)' % self._dcid | ||
return ('\n'.join(( | ||
'GridInfo #{0.dcgid}', | ||
))).format(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import ispyb.model.datacollection | ||
import ispyb.model.processingjob | ||
|
||
class ObjectModelMixIn(): | ||
'''Object model accessor functions for Connector classes.''' | ||
|
||
def get_data_collection(self, dcid): | ||
'''Return a DataCollection object representing the information | ||
about the selected data collection''' | ||
return ispyb.model.datacollection.DataCollection( | ||
dcid, | ||
self.mx_acquisition, | ||
) | ||
|
||
def get_data_collection_group(self, dcgid): | ||
'''Return a DataCollectionGroup object representing the information | ||
about the selected data collection group''' | ||
return ispyb.model.datacollection.DataCollectionGroup( | ||
dcgid, | ||
self, | ||
) | ||
|
||
def get_processing_job(self, jobid): | ||
'''Return a ProcessingJob object representing the information | ||
about the selected processing job.''' | ||
return ispyb.model.processingjob.ProcessingJob( | ||
jobid, | ||
self.mx_processing, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters