Skip to content

Commit 19f5f2f

Browse files
authored
Merge branch 'master' into py3k
2 parents d449d47 + 1010c1e commit 19f5f2f

File tree

7 files changed

+170
-30
lines changed

7 files changed

+170
-30
lines changed

docs/source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'sphinx.ext.autodoc',
3535
'sphinx.ext.viewcode',
3636
'sphinx.ext.napoleon',
37+
'sphinx.ext.autosummary'
3738
]
3839

3940
# Add any paths that contain templates here, relative to this directory.
@@ -176,3 +177,6 @@
176177
author, 'ODM2PythonAPI', 'One line description of project.',
177178
'Miscellaneous'),
178179
]
180+
181+
182+
autosummary_generate = True

docs/source/contribute.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Contribute to Documentation
2+
============================
3+
4+
This guide is a reference on how to contribute to ODM2 Documentation effort
5+
for the many `ODM2 Software Ecosystem <https://github.com/ODM2/odm2-software-ecosystem>`__.
6+
7+
Conventions
8+
-----------
9+
10+
There are a few conventions that should be followed
11+
when writing docstrings within the code:
12+
13+
- Docstrings should follow
14+
`Google Style Documentation
15+
<http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html>`__.
16+
17+
- Do not say "**defaults to ____**" for any arguments,
18+
unless the argument needs further explanation.
19+
The default value is already available in the method/function definition.
20+
21+
- If function needs to be instantiated, explicitly show in example.
22+
See
23+
`here <https://stackoverflow.com/questions/17134653/difference-between-class-and-instance-methods>`__
24+
for discussion of class vs instance methods.
25+
26+
- Provide link to `Controlled Vocabulary <http://vocabulary.odm2.org/>`__
27+
if an argument needs a CV as value.
28+
29+
Please add any additional conventions that you think should be in place
30+
within `the github issue #106 <https://github.com/ODM2/ODM2PythonAPI/issues/106>`__.
31+
32+
Pull requests
33+
-------------
34+
35+
Once changes has been in place within your forked copy of the repository
36+
you are working on, please create a pull request to add your contribution
37+
to the **master** branch of the repository.

docs/source/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ A Python-based application programmer's interface for the `Observations Data Mod
99

1010
installing
1111
modules
12-
models
12+
odm2models
1313
credits
14+
contribute
1415

1516
Indices and tables
1617
==================
1718

19+
.. toctree::
20+
:maxdepth: 2
21+
22+
models
23+
1824
* :ref:`genindex`
1925
* :ref:`modindex`
2026
* :ref:`search`

docs/source/models.rst

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
ODM2 Models
2-
===========
1+
ODM2 Models Index
2+
==================
33

4-
.. automodule:: odm2api.ODM2.models
5-
:members:
6-
:undoc-members:
7-
:show-inheritance:
4+
ODM2 is organized with a "core" schema and multiple "extension" schemas that
5+
extend the functionality of the core. The following sections cover some overarching concepts
6+
for ODM2 and then focus on specific entities within the ODM2 Core schema and ODM2's extension schemas.
7+
8+
ODM2Core Entities
9+
------------------
10+
11+
The following are entities in the `ODM2 Core Schema <http://odm2.github.io/ODM2/schemas/ODM2_Current/diagrams/ODM2Core.html>`__:
12+
13+
.. autosummary::
14+
15+
odm2api.ODM2.models.Actions
16+
odm2api.ODM2.models.DataSets
17+
odm2api.ODM2.models.FeatureActions
18+
odm2api.ODM2.models.Methods
19+
odm2api.ODM2.models.Organizations
20+
odm2api.ODM2.models.People
21+
odm2api.ODM2.models.ProcessingLevels
22+
odm2api.ODM2.models.RelatedActions
23+
odm2api.ODM2.models.Results
24+
odm2api.ODM2.models.SamplingFeatures
25+
odm2api.ODM2.models.TaxonomicClassifiers
26+
odm2api.ODM2.models.Units
27+
odm2api.ODM2.models.Variables

docs/source/odm2models.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ODM2 Models
2+
===========
3+
4+
.. automodule:: odm2api.ODM2.models
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

odm2api/ODM2/models.py

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,19 @@ class CVReferenceMaterialMedium(Base, CV):
155155
# Core
156156
# ################################################################################
157157
class People(Base):
158-
158+
"""
159+
Individuals that perform actions.
160+
"""
159161
PersonID = Column('personid', Integer, primary_key=True, nullable=False)
160162
PersonFirstName = Column('personfirstname', String(255), nullable=False)
161163
PersonMiddleName = Column('personmiddlename', String(255))
162164
PersonLastName = Column('personlastname', String(255), nullable=False)
163165

164166

165167
class Organizations(Base):
166-
168+
"""
169+
A group of people.
170+
"""
167171
OrganizationID = Column('organizationid', Integer, primary_key=True, nullable=False)
168172
OrganizationTypeCV = Column('organizationtypecv', ForeignKey(CVOrganizationType.Name), nullable=False,
169173
index=True)
@@ -194,7 +198,9 @@ class Affiliations(Base):
194198

195199

196200
class Methods(Base):
197-
201+
"""
202+
The procedure used to perform an action.
203+
"""
198204
MethodID = Column('methodid', Integer, primary_key=True, nullable=False)
199205
MethodTypeCV = Column('methodtypecv', ForeignKey(CVMethodType.Name), nullable=False, index=True)
200206
MethodCode = Column('methodcode', String(50), nullable=False)
@@ -207,7 +213,9 @@ class Methods(Base):
207213

208214

209215
class Actions(Base):
210-
216+
"""
217+
Actions are performed by people and may have a result.
218+
"""
211219
ActionID = Column('actionid', Integer, primary_key=True, nullable=False)
212220
ActionTypeCV = Column('actiontypecv', ForeignKey(CVActionType.Name), nullable=False, index=True)
213221
MethodID = Column('methodid', ForeignKey(Methods.MethodID), nullable=False)
@@ -234,19 +242,42 @@ class ActionBy(Base):
234242

235243

236244
class SamplingFeatures(Base):
237-
245+
"""
246+
Where or on what an action was performed.
247+
"""
238248
SamplingFeatureID = Column('samplingfeatureid', Integer, primary_key=True, nullable=False)
249+
"""int: Primary key identifier."""
239250
SamplingFeatureUUID = Column('samplingfeatureuuid', String(36), nullable=False)
251+
"""str: A universally unique identifier for the sampling feature."""
240252
SamplingFeatureTypeCV = Column('samplingfeaturetypecv', ForeignKey(CVSamplingFeatureType.Name),
241253
nullable=False, index=True)
254+
"""str: CV term describing the type of sampling feature."""
242255
SamplingFeatureCode = Column('samplingfeaturecode', String(50), nullable=False)
256+
"""str: A short but meaningful text identifier for the sampling feature."""
243257
SamplingFeatureName = Column('samplingfeaturename', String(255))
258+
"""str: Sampling Feature name (free text)."""
244259
SamplingFeatureDescription = Column('samplingfeaturedescription', String(500))
260+
"""str: Text describing the sampling feature."""
245261
SamplingFeatureGeotypeCV = Column('samplingfeaturegeotypecv', ForeignKey(CVSamplingFeatureGeoType.Name),
246262
index=True)
263+
"""str: Dimensionality of SamplingFeature; point2d, line2d, etc."""
247264
Elevation_m = Column('elevation_m', Float(53))
265+
"""float: The elevation of the sampling feature in meters, or in the case of Specimen,
266+
the elevation from where the SamplingFeature.Specimen was collected"""
248267
ElevationDatumCV = Column('elevationdatumcv', ForeignKey(CVElevationDatum.Name), index=True)
268+
"""str: The code for the vertical geodetic datum that specifies the zero point for
269+
the Sampling Feature Elevation"""
270+
# FeatureGeometry = Column('featuregeometry', String(50))
271+
"""object: The location geometry of the sampling feature on the Earth expressed using a
272+
geometry data type. Can be a Point, Curve (profile, trajectory, etc),
273+
Surface (flat polygons, etc) or Solid/Volume (although often limited to
274+
2D geometries). """
275+
249276
FeatureGeometryWKT = Column('featuregeometrywkt', String(50))
277+
"""str: The location geometry of the sampling feature on the Earth expressed as
278+
well known text (WKT). Can be a Point, Curve (profile, trajectory, etc.),
279+
Surface (flat polygons, etc.), or Solid/Volume (although often limited to
280+
2D geometries)."""
250281
__mapper_args__ = {
251282
'polymorphic_on': case(
252283
[
@@ -259,7 +290,10 @@ class SamplingFeatures(Base):
259290

260291

261292
class FeatureActions(Base):
262-
293+
"""
294+
Provides flexible linkage between Actions and the SamplingFeatures
295+
on which or at which they were performed.
296+
"""
263297
FeatureActionID = Column('featureactionid', Integer, primary_key=True, nullable=False)
264298
SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID),
265299
nullable=False)
@@ -270,7 +304,9 @@ class FeatureActions(Base):
270304

271305

272306
class DataSets(Base):
273-
307+
"""
308+
Enables grouping of results into a larger dataset.
309+
"""
274310
DataSetID = Column('datasetid', Integer, primary_key=True, nullable=False)
275311

276312
# This has been changed to String to support multiple database uuid types
@@ -282,15 +318,19 @@ class DataSets(Base):
282318

283319

284320
class ProcessingLevels(Base):
285-
321+
"""
322+
Levels to which data have been quality controlled.
323+
"""
286324
ProcessingLevelID = Column('processinglevelid', Integer, primary_key=True, nullable=False)
287325
ProcessingLevelCode = Column('processinglevelcode', String(50), nullable=False)
288326
Definition = Column('definition', String(500))
289327
Explanation = Column('explanation', String(500))
290328

291329

292330
class RelatedActions(Base):
293-
331+
"""
332+
Enables specifying relationships among Actions (e.g., workflows, etc.)
333+
"""
294334
RelationID = Column('relationid', Integer, primary_key=True, nullable=False)
295335
ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False)
296336
RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False,
@@ -302,7 +342,9 @@ class RelatedActions(Base):
302342

303343

304344
class TaxonomicClassifiers(Base):
305-
345+
"""
346+
Terms for classifying results.
347+
"""
306348
TaxonomicClassifierID = Column('taxonomicclassifierid', Integer, primary_key=True, nullable=False)
307349
TaxonomicClassifierTypeCV = Column(
308350
'taxonomicclassifiertypecv',
@@ -321,7 +363,9 @@ class TaxonomicClassifiers(Base):
321363

322364

323365
class Units(Base):
324-
366+
"""
367+
Units of measure.
368+
"""
325369
UnitsID = Column('unitsid', Integer, primary_key=True, nullable=False)
326370
UnitsTypeCV = Column('unitstypecv', ForeignKey(CVUnitsType.Name), nullable=False, index=True)
327371
UnitsAbbreviation = Column('unitsabbreviation', String(255), nullable=False)
@@ -330,7 +374,9 @@ class Units(Base):
330374

331375

332376
class Variables(Base):
333-
377+
"""
378+
What was observed.
379+
"""
334380
VariableID = Column('variableid', Integer, primary_key=True, nullable=False)
335381
VariableTypeCV = Column('variabletypecv', ForeignKey(CVVariableType.Name), nullable=False, index=True)
336382
VariableCode = Column('variablecode', String(50), nullable=False)
@@ -341,7 +387,9 @@ class Variables(Base):
341387

342388

343389
class Results(Base):
344-
390+
"""
391+
The result of an action.
392+
"""
345393
ResultID = Column('resultid', BigIntegerType, primary_key=True)
346394

347395
# This has been changed to String to support multiple database uuid types

odm2api/ODM2/services/readService.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,34 @@ def getProcessingLevels(self, ids=None, codes=None):
373373

374374
# Sampling Feature
375375
def getSamplingFeatures(self, ids=None, codes=None, uuids=None, type=None, wkt=None, results=False):
376-
"""
377-
* Pass nothing - returns a list of all sampling feature objects with
378-
each object of type specific to that sampling feature
379-
* Pass a list of SamplingFeatureID - returns a single sampling feature object for the given ids
380-
* Pass a list of SamplingFeatureCode - returns a single sampling feature object for the given code
381-
* Pass a list of SamplingFeatureUUID - returns a single sampling feature object for the given UUID's
382-
* Pass a SamplingFeatureType - returns a list of sampling feature objects of the type passed in
383-
* Pass a SamplingFeature Well Known Text - return a list of sampling feature objects
384-
* Pass whether or not you want to return only the sampling features
385-
that have results associated with them
376+
"""Retrieve a list of Sampling Feature objects.
377+
378+
If no arguments are passed to the function, or their values are None,
379+
all Sampling Feature objects in the database will be returned.
380+
381+
Args:
382+
ids (list, optional): List of SamplingFeatureIDs.
383+
codes (list, optional): List of SamplingFeature Codes.
384+
uuids (list, optional): List of UUIDs string.
385+
type (str, optional): Type of Sampling Feature from
386+
`controlled vocabulary name <http://vocabulary.odm2.org/samplingfeaturetype/>`_.
387+
wkt (str, optional): SamplingFeature Well Known Text.
388+
results (bool, optional): Whether or not you want to return only the
389+
sampling features that have results associated with them.
390+
391+
Returns:
392+
list: List of Sampling Feature objects
393+
394+
Examples:
395+
>>> READ = ReadODM2(SESSION_FACTORY)
396+
>>> READ.getSamplingFeatures(ids=[39, 40])
397+
>>> READ.getSamplingFeatures(codes=['HOME', 'FIELD'])
398+
>>> READ.getSamplingFeatures(uuids=['a6f114f1-5416-4606-ae10-23be32dbc202',
399+
... '5396fdf3-ceb3-46b6-aaf9-454a37278bb4'])
400+
>>> READ.getSamplingFeatures(type='Site')
401+
>>> READ.getSamplingFeatures(wkt='POINT (30 10)')
402+
>>> READ.getSamplingFeatures(results=True)
403+
>>> READ.getSamplingFeatures(type='Site', results=True)
386404
387405
"""
388406
if results:

0 commit comments

Comments
 (0)