forked from move-coop/parsons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New connector for working with the Catalist Match API (move-coop#912)
* Enable api_connector to return error message in `text` attribute Some API error responses contain the error message in the `text` attribute, so this update makes it possible to fetch that message if it exists. * New connector to work with the Catalist Match API * Add pytest-mock to requirements to support mocking in pytests * Tests on the catalist match connector * More open ended pytest-mock version for compatibility * Expand docstring documetation based on feedback in PR * More verbose error on match failure * Parameterize template_id variable * Expand docstrings on initial setup * Include Catalist documentation rst file
- Loading branch information
1 parent
2c616bb
commit 97bc5c3
Showing
9 changed files
with
700 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Catalist | ||
======= | ||
|
||
******** | ||
Overview | ||
******** | ||
|
||
The CatalistMatch class allows you to interact with the Catalist M Tool (match) API. Users of this Parsons integration can use the Parsons table format to send input files to the M Tool and receive back a matched version of that table. | ||
|
||
.. note:: | ||
Authentication | ||
In order to use this class you must be provided with an OAuth Client ID and Client Secret from catalist, as well as SFTP credentials. You will also need to have Catalist whitelist the IP address you are using to access the M Tool. | ||
|
||
========== | ||
Quickstart | ||
========== | ||
|
||
To instantiate the CatalistMatch class, you must provide your ``client_id``, ``client_secret``, ``sftp_username`` and ``sftp_password`` values as arguments: | ||
|
||
.. code-block:: sh | ||
# In bash, set your environment variables like so: | ||
$ export CATALIST_CLIENT_ID='MY_UUID' | ||
$ export CATALIST_CLIENT_SECRET='MY_SECRET' | ||
$ export CATALIST_SFTP_USERNAME='MY_USERNAME' | ||
$ export CATALIST_SFTP_PASSWORD='MY_PASSWORD' | ||
.. code-block:: python | ||
import os | ||
from parsons import CatalistMatch | ||
match = CatalistMatch( | ||
client_id=os.environ['CATALIST_CLIENT_ID'], | ||
client_secret=os.environ['CATALIST_CLIENT_SECRET'], | ||
sftp_username=os.environ['CATALIST_SFTP_USERNAME'], | ||
sftp_password=os.environ['CATALIST_SFTP_PASSWORD'] | ||
) | ||
You can then load a CSV as a Parsons table and submit it for matching, then save the resulting matched Parsons table as a CSV. | ||
|
||
.. code-block:: python | ||
source_table = Table.from_csv(source_filepath) | ||
result_table = match.match(source_table) | ||
result_table.to_csv(result_filepath) | ||
*** | ||
API | ||
*** | ||
|
||
.. autoclass :: parsons.CatalistMatch | ||
:inherited-members: |
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,3 @@ | ||
from parsons.catalist.catalist import CatalistMatch | ||
|
||
__all__ = ["CatalistMatch"] |
Oops, something went wrong.