From 19116e2d5d70a16a1f63bc24611dff0e8416186c Mon Sep 17 00:00:00 2001 From: ayushanand18 Date: Tue, 22 Nov 2022 18:07:20 +0530 Subject: [PATCH 1/3] Update. updated all docs --- docs/checklist.rst | 19 ++++------ docs/dataset.rst | 21 +++++------ docs/index.rst | 69 ++++++++++++++++++---------------- docs/nodes.rst | 20 +++++----- docs/occurrences.rst | 37 +++++++++--------- docs/taxa.rst | 26 +++++++------ pyobis/checklist/__init__.py | 3 +- pyobis/dataset/__init__.py | 4 +- pyobis/nodes/__init__.py | 4 +- pyobis/occurrences/__init__.py | 2 + pyobis/taxa/__init__.py | 4 +- 11 files changed, 109 insertions(+), 100 deletions(-) diff --git a/docs/checklist.rst b/docs/checklist.rst index c4f49015..5db00b70 100644 --- a/docs/checklist.rst +++ b/docs/checklist.rst @@ -5,25 +5,22 @@ checklist module .. py:module:: pyobis.checklist -.. autoclass:: ChecklistQuery - -A ChecklistQuery object for fetching checklist records. +.. autoclass:: ChecklistResponse Usage ##### .. code-block:: python - from pyobis.checklist import ChecklistQuery + from pyobis import checklist - query = ChecklistQuery() - data = query.search(args, **kwargs) - api_url = query.get_search_url() + query = checklist.list(taxonid = 127405, **kwargs) + query.api_url # Returns the API URL + query.to_pandas() # Returns a pandas DataFrame object Methods: ######## -.. automethod:: ChecklistQuery.list -.. automethod:: ChecklistQuery.redlist -.. automethod:: ChecklistQuery.newest -.. automethod:: ChecklistQuery.get_search_url +.. autofunction:: list +.. autofunction:: redlist +.. autofunction:: newest diff --git a/docs/dataset.rst b/docs/dataset.rst index b7047777..4884fc99 100644 --- a/docs/dataset.rst +++ b/docs/dataset.rst @@ -5,25 +5,24 @@ dataset module .. py:module:: pyobis.dataset -.. autoclass:: DatasetQuery - -A DatasetQuery object for fetching dataset records. +.. autoclass:: DatasetResponse Usage ##### .. code-block:: python - from pyobis.dataset import DatasetQuery + from pyobis import dataset + + query = dataset.search(args, **kwargs) # Build the Query + query.execute() # Execute the Query + query.data # Returns the data - query = DatasetQuery() - data = query.search(args, **kwargs) - api_url = query.get_search_url() + # or build and execute at the same time + data = dataset.search(args, **kwargs).execute() Methods: ######## -.. automethod:: DatasetQuery.get -.. automethod:: DatasetQuery.search -.. automethod:: DatasetQuery.get_search_url -.. automethod:: DatasetQuery.get_mapper_url +.. autofunction:: get +.. autofunction:: search diff --git a/docs/index.rst b/docs/index.rst index 6cf8e890..a158db6a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -46,67 +46,75 @@ Taxa module .. code-block:: python - from pyobis.taxa import TaxaQuery - - query = TaxaQuery() - - query.search(scientificname="Mola mola") - query.search(scientificname="Mola mola", offset=10) - query.search(geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))") - query.taxon(10332) - query.taxon(127405) - query.get_search_url() + from pyobis import taxa + + query = taxa.search(scientificname="Mola mola") + query.execute() + query.data # Returns the data + query.api_url # Returns the API URL + + data = taxa.search(scientificname="Mola mola").execute() + taxa.search(geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))") + taxa.taxon(10332) + taxa.taxon(127405) + Occurrence module ################# .. code-block:: python - from pyobis.occurrences import OccQuery + from pyobis import occurrences - query = OccQuery() + query = occurrences.search(scientificname="Mola mola") + query.execute() + query.data # Returns the data + query.api_url # Returns the OBIS API URL + query.mapper_url # Returns the OBIS Mapper URL - query.search(scientificname="Mola mola") - query.search(scientificname="Mola mola", offset=0, size=10) - query.search( + data = occurrences.search(scientificname="Mola mola", size=10).execute() + occurrences.search( geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))", size=20 ) - query.get_mapper_url() + Dataset module ############## .. code-block:: python - from pyobis.dataset import DatasetQuery + from pyobis import dataset - query = DatasetQuery() + query = dataset.search(scientificname=["Mola", "Abra", "Lanice", "Pectinaria"]) + query.execute() + query.data # Returns the data + query.api_url # Returns the API URL - query.search(scientificname=["Mola", "Abra", "Lanice", "Pectinaria"]) - query.get(id="ec9df3b9-3b2b-4d83-881b-27bcbcd57b95") + data = dataset.get(id="ec9df3b9-3b2b-4d83-881b-27bcbcd57b95").execute() Nodes module ############ .. code-block:: python - from pyobis.nodes import NodesQuery + from pyobis import nodes - query = NodesQuery() - - query.search(scientificname=["Mola", "Abra"]) - query.get_search_url() + query = nodes.search(scientificname=["Mola", "Abra"]) + query.execute() + query.data # Returns the data + query.api_url # Returns the API URL Checklist module ################ .. code-block:: python - from pyobis.checklist import ChecklistQuery - - query = ChecklistQuery() + from pyobis import checklist - query.list(scientificname="Cetacea") + query = checklist.list(scientificname="Cetacea") + query.execute() + query.data # Returns the data + query.api_url # Returns the OBIS API URL Meta ==== @@ -122,9 +130,6 @@ Meta - - - Contents ======== diff --git a/docs/nodes.rst b/docs/nodes.rst index 63e64efb..d14e7f25 100644 --- a/docs/nodes.rst +++ b/docs/nodes.rst @@ -5,25 +5,23 @@ nodes module .. py:module:: pyobis.nodes -.. autoclass:: NodesQuery - -A NodesQuery object for fetching nodes records. +.. autoclass:: NodesResponse Usage ##### .. code-block:: python - from pyobis.nodes import NodesQuery + from pyobis import nodes - query = NodesQuery() - data = query.search(args, **kwargs) - api_url = query.get_search_url() + query = nodes.search(scientificname=["Mola", "Abra"], **kwargs) + query.execute() + query.data # Returns the data + query.api_url # Returns the API URL Methods: ######## -.. automethod:: NodesQuery.search -.. automethod:: NodesQuery.activities -.. automethod:: NodesQuery.get_search_url -.. automethod:: NodesQuery.get_mapper_url +.. autofunction:: search +.. autofunction:: activities + diff --git a/docs/occurrences.rst b/docs/occurrences.rst index 595ce6c0..62c285b5 100644 --- a/docs/occurrences.rst +++ b/docs/occurrences.rst @@ -5,31 +5,34 @@ occurrences module .. py:module:: pyobis.occurrences -.. autoclass:: OccQuery - -An OccQuery object for fetching occurrence records. +.. autoclass:: OccResponse Usage ##### .. code-block:: python - from pyobis.occurrences import OccQuery + from pyobis import occurrences + + query = occurrences.search(scientificname="Mola mola") + query.execute() + query.data # Returns the data + query.api_url # Returns the OBIS API URL + query.mapper_url # Returns the OBIS Mapper URL - query = OccQuery() - data = query.search(args, **kwargs) - api_url = query.get_search_url() + data = occurrences.search(scientificname="Mola mola", size=10).execute() + occurrences.search( + geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))", size=20 + ) Methods: ######## -.. automethod:: OccQuery.search -.. automethod:: OccQuery.get -.. automethod:: OccQuery.grid -.. automethod:: OccQuery.getpoints -.. automethod:: OccQuery.point -.. automethod:: OccQuery.tile -.. automethod:: OccQuery.centroid -.. automethod:: OccQuery.get_search_url -.. automethod:: OccQuery.get_mapper_url -.. automethod:: OccQuery.lookup_taxon +.. autofunction:: search +.. autofunction:: get +.. autofunction:: grid +.. autofunction:: getpoints +.. autofunction:: point +.. autofunction:: tile +.. autofunction:: centroid +.. autofunction:: lookup_taxon diff --git a/docs/taxa.rst b/docs/taxa.rst index ac166494..5bdfa9db 100644 --- a/docs/taxa.rst +++ b/docs/taxa.rst @@ -5,25 +5,29 @@ taxa module .. py:module:: pyobis.taxa -.. autoclass:: TaxaQuery - -A TaxaQuery object for fetching taxa records. +.. autoclass:: TaxaResponse Usage ##### .. code-block:: python - from pyobis.taxa import TaxaQuery + from pyobis import taxa + + query = taxa.search(scientificname="Mola mola") + query.execute() + query.data # Returns the data + query.api_url # Returns the API URL + query.to_pandas() # Returns a pandas DataFrame - query = TaxaQuery() - data = query.search(args, **kwargs) - api_url = query.get_search_url() + data = taxa.search(scientificname="Mola mola").execute() + taxa.search(geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))") + taxa.taxon(10332) + taxa.taxon(127405) Methods: ######## -.. automethod:: TaxaQuery.search -.. automethod:: TaxaQuery.taxon -.. automethod:: TaxaQuery.annotations -.. automethod:: TaxaQuery.get_search_url +.. autofunction:: search +.. autofunction:: taxon +.. autofunction:: annotations diff --git a/pyobis/checklist/__init__.py b/pyobis/checklist/__init__.py index 079bcb78..b092085d 100644 --- a/pyobis/checklist/__init__.py +++ b/pyobis/checklist/__init__.py @@ -1,7 +1,8 @@ -from .checklist import list, newest, redlist +from .checklist import list, newest, redlist, ChecklistResponse __all__ = [ "list", "redlist", "newest", + "ChecklistResponse", ] diff --git a/pyobis/dataset/__init__.py b/pyobis/dataset/__init__.py index 9f43da74..1d545c10 100644 --- a/pyobis/dataset/__init__.py +++ b/pyobis/dataset/__init__.py @@ -1,3 +1,3 @@ -from .dataset import get, search +from .dataset import get, search, DatasetResponse -__all__ = ["search", "get"] +__all__ = ["search", "get", "DatasetResponse"] diff --git a/pyobis/nodes/__init__.py b/pyobis/nodes/__init__.py index c83a8431..9eac2221 100644 --- a/pyobis/nodes/__init__.py +++ b/pyobis/nodes/__init__.py @@ -1,3 +1,3 @@ -from .nodes import activities, search +from .nodes import activities, search, NodesResponse -__all__ = ["search", "activities"] +__all__ = ["search", "activities", "NodesResponse"] diff --git a/pyobis/occurrences/__init__.py b/pyobis/occurrences/__init__.py index f92a89db..77fcc2ae 100644 --- a/pyobis/occurrences/__init__.py +++ b/pyobis/occurrences/__init__.py @@ -7,6 +7,7 @@ point, search, tile, + OccResponse, ) __all__ = [ @@ -18,4 +19,5 @@ "lookup_taxon", "point", "centroid", + "OccResponse", ] diff --git a/pyobis/taxa/__init__.py b/pyobis/taxa/__init__.py index f1f41d6d..045289b3 100644 --- a/pyobis/taxa/__init__.py +++ b/pyobis/taxa/__init__.py @@ -1,3 +1,3 @@ -from .taxa import annotations, search, taxon +from .taxa import annotations, search, taxon, TaxaResponse -__all__ = ["search", "taxon", "annotations"] +__all__ = ["search", "taxon", "annotations", "TaxaResponse"] From bbafb654682c4b073529ef1f713bfc739d05af11 Mon Sep 17 00:00:00 2001 From: ayushanand18 Date: Tue, 22 Nov 2022 18:18:02 +0530 Subject: [PATCH 2/3] update. updated changelog --- Changelog.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Changelog.rst b/Changelog.rst index e1d85247..7d1163ce 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -1,5 +1,17 @@ Changelog ========= + +1.3.6 (2022-11-22) +----------------------- +- MAJOR: + - none +- MINOR: + - making UI simpler and more intuitive by a refactored OOP approach. + - data is now returned as a response object with its own parameters and methods. + - one-click method to every response object to convert it into a pandas DataFrame. +- PATCH: + - various README improvements including better description of modules and their suggested use. + iobis/pyobis dev ----------------------- - MAJOR: From ec018bbbcdb8f050485c8c731841dab110001b34 Mon Sep 17 00:00:00 2001 From: ayushanand18 Date: Tue, 22 Nov 2022 18:23:40 +0530 Subject: [PATCH 3/3] fix. fixed pre-commit failings --- docs/checklist.rst | 6 +++--- docs/dataset.rst | 6 +++--- docs/index.rst | 30 +++++++++++++++--------------- docs/nodes.rst | 5 ++--- docs/occurrences.rst | 8 ++++---- docs/taxa.rst | 10 +++++----- pyobis/checklist/__init__.py | 2 +- pyobis/dataset/__init__.py | 2 +- pyobis/nodes/__init__.py | 2 +- pyobis/occurrences/__init__.py | 2 +- pyobis/taxa/__init__.py | 2 +- 11 files changed, 37 insertions(+), 38 deletions(-) diff --git a/docs/checklist.rst b/docs/checklist.rst index 5db00b70..d0bb91ec 100644 --- a/docs/checklist.rst +++ b/docs/checklist.rst @@ -14,9 +14,9 @@ Usage from pyobis import checklist - query = checklist.list(taxonid = 127405, **kwargs) - query.api_url # Returns the API URL - query.to_pandas() # Returns a pandas DataFrame object + query = checklist.list(taxonid=127405, **kwargs) + query.api_url # Returns the API URL + query.to_pandas() # Returns a pandas DataFrame object Methods: ######## diff --git a/docs/dataset.rst b/docs/dataset.rst index 4884fc99..7a09b090 100644 --- a/docs/dataset.rst +++ b/docs/dataset.rst @@ -14,9 +14,9 @@ Usage from pyobis import dataset - query = dataset.search(args, **kwargs) # Build the Query - query.execute() # Execute the Query - query.data # Returns the data + query = dataset.search(args, **kwargs) # Build the Query + query.execute() # Execute the Query + query.data # Returns the data # or build and execute at the same time data = dataset.search(args, **kwargs).execute() diff --git a/docs/index.rst b/docs/index.rst index a158db6a..0e5dc0a8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -47,17 +47,17 @@ Taxa module .. code-block:: python from pyobis import taxa - - query = taxa.search(scientificname="Mola mola") + + query = taxa.search(scientificname="Mola mola") query.execute() - query.data # Returns the data - query.api_url # Returns the API URL + query.data # Returns the data + query.api_url # Returns the API URL data = taxa.search(scientificname="Mola mola").execute() taxa.search(geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))") taxa.taxon(10332) taxa.taxon(127405) - + Occurrence module ################# @@ -68,15 +68,15 @@ Occurrence module query = occurrences.search(scientificname="Mola mola") query.execute() - query.data # Returns the data - query.api_url # Returns the OBIS API URL - query.mapper_url # Returns the OBIS Mapper URL + query.data # Returns the data + query.api_url # Returns the OBIS API URL + query.mapper_url # Returns the OBIS Mapper URL data = occurrences.search(scientificname="Mola mola", size=10).execute() occurrences.search( geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))", size=20 ) - + Dataset module ############## @@ -87,8 +87,8 @@ Dataset module query = dataset.search(scientificname=["Mola", "Abra", "Lanice", "Pectinaria"]) query.execute() - query.data # Returns the data - query.api_url # Returns the API URL + query.data # Returns the data + query.api_url # Returns the API URL data = dataset.get(id="ec9df3b9-3b2b-4d83-881b-27bcbcd57b95").execute() @@ -101,8 +101,8 @@ Nodes module query = nodes.search(scientificname=["Mola", "Abra"]) query.execute() - query.data # Returns the data - query.api_url # Returns the API URL + query.data # Returns the data + query.api_url # Returns the API URL Checklist module ################ @@ -113,8 +113,8 @@ Checklist module query = checklist.list(scientificname="Cetacea") query.execute() - query.data # Returns the data - query.api_url # Returns the OBIS API URL + query.data # Returns the data + query.api_url # Returns the OBIS API URL Meta ==== diff --git a/docs/nodes.rst b/docs/nodes.rst index d14e7f25..f24d09ee 100644 --- a/docs/nodes.rst +++ b/docs/nodes.rst @@ -16,12 +16,11 @@ Usage query = nodes.search(scientificname=["Mola", "Abra"], **kwargs) query.execute() - query.data # Returns the data - query.api_url # Returns the API URL + query.data # Returns the data + query.api_url # Returns the API URL Methods: ######## .. autofunction:: search .. autofunction:: activities - diff --git a/docs/occurrences.rst b/docs/occurrences.rst index 62c285b5..55a9bf22 100644 --- a/docs/occurrences.rst +++ b/docs/occurrences.rst @@ -12,13 +12,13 @@ Usage .. code-block:: python - from pyobis import occurrences + from pyobis import occurrences query = occurrences.search(scientificname="Mola mola") query.execute() - query.data # Returns the data - query.api_url # Returns the OBIS API URL - query.mapper_url # Returns the OBIS Mapper URL + query.data # Returns the data + query.api_url # Returns the OBIS API URL + query.mapper_url # Returns the OBIS Mapper URL data = occurrences.search(scientificname="Mola mola", size=10).execute() occurrences.search( diff --git a/docs/taxa.rst b/docs/taxa.rst index 5bdfa9db..3fe49d83 100644 --- a/docs/taxa.rst +++ b/docs/taxa.rst @@ -12,13 +12,13 @@ Usage .. code-block:: python - from pyobis import taxa + from pyobis import taxa - query = taxa.search(scientificname="Mola mola") + query = taxa.search(scientificname="Mola mola") query.execute() - query.data # Returns the data - query.api_url # Returns the API URL - query.to_pandas() # Returns a pandas DataFrame + query.data # Returns the data + query.api_url # Returns the API URL + query.to_pandas() # Returns a pandas DataFrame data = taxa.search(scientificname="Mola mola").execute() taxa.search(geometry="POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))") diff --git a/pyobis/checklist/__init__.py b/pyobis/checklist/__init__.py index b092085d..f67d9781 100644 --- a/pyobis/checklist/__init__.py +++ b/pyobis/checklist/__init__.py @@ -1,4 +1,4 @@ -from .checklist import list, newest, redlist, ChecklistResponse +from .checklist import ChecklistResponse, list, newest, redlist __all__ = [ "list", diff --git a/pyobis/dataset/__init__.py b/pyobis/dataset/__init__.py index 1d545c10..71df47c0 100644 --- a/pyobis/dataset/__init__.py +++ b/pyobis/dataset/__init__.py @@ -1,3 +1,3 @@ -from .dataset import get, search, DatasetResponse +from .dataset import DatasetResponse, get, search __all__ = ["search", "get", "DatasetResponse"] diff --git a/pyobis/nodes/__init__.py b/pyobis/nodes/__init__.py index 9eac2221..3795ae16 100644 --- a/pyobis/nodes/__init__.py +++ b/pyobis/nodes/__init__.py @@ -1,3 +1,3 @@ -from .nodes import activities, search, NodesResponse +from .nodes import NodesResponse, activities, search __all__ = ["search", "activities", "NodesResponse"] diff --git a/pyobis/occurrences/__init__.py b/pyobis/occurrences/__init__.py index 77fcc2ae..0a58322f 100644 --- a/pyobis/occurrences/__init__.py +++ b/pyobis/occurrences/__init__.py @@ -1,4 +1,5 @@ from .occurrences import ( + OccResponse, centroid, get, getpoints, @@ -7,7 +8,6 @@ point, search, tile, - OccResponse, ) __all__ = [ diff --git a/pyobis/taxa/__init__.py b/pyobis/taxa/__init__.py index 045289b3..e039288b 100644 --- a/pyobis/taxa/__init__.py +++ b/pyobis/taxa/__init__.py @@ -1,3 +1,3 @@ -from .taxa import annotations, search, taxon, TaxaResponse +from .taxa import TaxaResponse, annotations, search, taxon __all__ = ["search", "taxon", "annotations", "TaxaResponse"]