Latest updates from internal dev branch.

This commit is contained in:
Laura Glendenning
2021-06-02 17:01:23 -04:00
parent 2a6dd42b92
commit 7638a04b66
228 changed files with 10989 additions and 5773 deletions

View File

@@ -149,6 +149,7 @@ To import testing data, run the dev stack and then run:
```bash
./setup_dev_test_data.sh
```
You will need python3 and pipenv installed to run this script.
*WARNING*: This script will remove any pre-existing data. If you need to clear your database
for other reasons, stop your dev stack and then `rm -rf local_data/dev/eve/db`.
@@ -253,6 +254,13 @@ Or use the convenience script:
```bash
./run_docker_compose.sh --build
```
If your network has an SSL certificate in its configuration, you may be able to do this:
```bash
./run_docker_compose.sh --build-with-cert <crt file>
```
This has only been tested in internal environments and may not cover all scenarios. For example:
the docker container has to be able to install the ca-certificates package before it can be
installed.
To run containers as daemons for DEFAULT configuration (remove -d flag to see logs):
```bash
@@ -294,6 +302,7 @@ Once the system is up and running:
```bash
./setup_docker_test_data.sh
```
You will need python3 and pipenv installed to run this script.
Once the test data has been imported, you no longer need to use the docker-compose.test.yml file.

View File

@@ -0,0 +1,179 @@
# (C) 2019 The Johns Hopkins University Applied Physics Laboratory LLC.
parameters:
appReleaseName: ""
appTlsSecretName: $(appTlsSecretName)
appUrl: ""
azureContainerRegistry: $(azureContainerRegistry)
azureSubscriptionEndpointForSecrets: $(azureSubscriptionEndpointForSecrets)
backendStorageMountPath: "/mnt/azure"
backendStorageClaimName: ""
deployEnvironment: $(deployEnvironment)
deploymentName: "CONTAINER_DEPLOY"
dockerAuthSecretName: $(dockerAuthSecretName)
helmRepoName: $(Pipeline.Workspace) # Default to chart published as artifact and automatically downloaded into workspace
helmChart: "pine-chart"
imageTag: $(Build.BuildId)
ingressClass: "nginx"
kubeServiceConnection: $(kubeServiceConnection)
namespace: $(namespace)
secrets: []
redisImageName: $(redisImageName)
eveImageName: $(eveImageName)
backendImageName: $(backendImageName)
frontendImageName: $(frontendImageName)
pipelineImageName: $(pipelineImageName)
jobs:
# track deployments on the environment
- deployment: "${{ parameters.deploymentName }}"
pool: Default
# creates an environment if it doesnt exist
environment: ${{ parameters.deployEnvironment }}
strategy:
# default deployment strategy
runOnce:
deploy:
steps:
- task: Bash@3
displayName: Display settings
inputs:
targetType: 'inline'
script: |
echo "appReleaseName: ${{ parameters.appReleaseName }}"
echo "appUrl: ${{ parameters.appUrl }}"
echo "deployEnvironment: ${{ parameters.deployEnvironment }}"
echo "kubeServiceConnection: ${{ parameters.kubeServiceConnection }}"
echo "namespace: ${{ parameters.namespace }}"
echo "ingressClass: ${{ parameters.ingressClass }}"
echo "imageTag: ${{ parameters.imageTag }}"
- bash: |
if [ -z "$APP_RELEASE_NAME" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"appReleaseName\""
echo "##vso[task.complete result=Failed;]"
fi
if [ -z "$APP_URL" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"appUrl\""
echo "##vso[task.complete result=Failed;]"
fi
if [ -z "$AZURE_SUBSCRIPTION" ]; then
echo "##vso[task.logissue type=error;]Missing variable \"azureSubscriptionEndpointForSecrets\""
echo "##vso[task.complete result=Failed;]"
fi
env:
APP_RELEASE_NAME: ${{ parameters.appReleaseName }}
APP_URL: ${{ parameters.appUrl }}
AZURE_SUBSCRIPTION: ${{ parameters.azureSubscriptionEndpointForSecrets }}
displayName: Check for required parameters
- task: HelmInstaller@1
displayName: 'Install Helm 3.5.3'
inputs:
helmVersionToInstall: 3.5.3
- task: KubectlInstaller@0
inputs:
kubectlVersion: 'latest'
- task: Kubernetes@1
displayName: 'kubectl set imagePullSecrets'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: '${{ parameters.kubeServiceConnection }}'
namespace: '${{ parameters.namespace }}'
command: 'get'
arguments: 'service'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
azureSubscriptionEndpointForSecrets: ${{ parameters.azureSubscriptionEndpointForSecrets }}
azureContainerRegistry: ${{ parameters.azureContainerRegistry }}
secretName: '${{ parameters.dockerAuthSecretName }}'
versionSpec: '1.13.10'
- task: Bash@3
displayName: "set default overrides"
inputs:
targetType: 'inline'
script: |
#!/bin/bash
echo "Creating pipelineHelmOverrideValues.yaml file"
cat > pipelineHelmOverrideValues.yaml <<- EOM
fullnameOverride: ${{ parameters.appReleaseName }}
name: ${{ parameters.appReleaseName }}
eve:
image:
repository: ${{ parameters.azureContainerRegistry }}/${{ parameters.eveImageName }}
tag: ${{ parameters.imageTag }}
redis:
image:
repository: ${{ parameters.azureContainerRegistry }}/${{ parameters.redisImageName }}
tag: ${{ parameters.imageTag }}
backend:
image:
repository: ${{ parameters.azureContainerRegistry }}/${{ parameters.backendImageName }}
tag: ${{ parameters.imageTag }}
persistence:
enabled: true
mountPath: ${{ parameters.backendStorageMountPath }}
nlpAnnotation:
image:
repository: ${{ parameters.azureContainerRegistry }}/${{ parameters.pipelineImageName }}
tag: ${{ parameters.imageTag }}
frontend:
serverName: ${{ parameters.appUrl }}
image:
repository: ${{ parameters.azureContainerRegistry }}/${{ parameters.frontendImageName }}
tag: ${{ parameters.imageTag }}
namespace: ${{ parameters.namespace }}
ingress:
annotations:
kubernetes.io/ingress.class: ${{ parameters.ingressClass }}
hosts:
- ${{ parameters.appUrl }}
tls:
- hosts:
- ${{ parameters.appUrl }}
secretName: ${{ parameters.appTlsSecretName }}
imagePullSecrets:
- ${{ parameters.dockerAuthSecretName }}
EOM
echo "File created"
cat pipelineHelmOverrideValues.yaml
- ${{ if ne(parameters.secrets, '') }}:
- task: Bash@3
displayName: "Add secrets section to overrides"
inputs:
targetType: 'inline'
script: |
#!/bin/bash
cat >> pipelineHelmOverrideValues.yaml <<- EOM
secrets:
EOM
echo "File updated"
- ${{ each secret in parameters.secrets }}:
- task: Bash@3
displayName: "Add secret to overrides"
inputs:
targetType: 'inline'
script: |
#!/bin/bash
cat >> pipelineHelmOverrideValues.yaml <<- EOM
${{ secret.key }}:
EOM
echo "File updated"
- ${{ each secretData in secret.value }}:
- task: Bash@3
displayName: "Add secret data to overrides"
inputs:
targetType: 'inline'
script: |
#!/bin/bash
cat >> pipelineHelmOverrideValues.yaml <<- EOM
${{ secretData.key }}: ${{ secretData.value }}
EOM
- task: HelmDeploy@0
displayName: Helm upgrade
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: '${{ parameters.kubeServiceConnection }}'
namespace: '${{ parameters.namespace }}'
command: 'upgrade'
chartType: 'Name'
chartName: '${{ parameters.helmRepoName }}/${{ parameters.helmChart }}'
releaseName: ${{ parameters.appReleaseName }}
valueFile: 'pipelineHelmOverrideValues.yaml'

View File

@@ -6,7 +6,6 @@ parameters:
azureContainerRegistry: $(azureContainerRegistry)
azureSubscriptionEndpointForSecrets: $(azureSubscriptionEndpointForSecrets)
backendStorageMountPath: "/mnt/azure"
backendStorageShareName: ""
deployEnvironment: $(deployEnvironment)
deploymentName: "CONTAINER_DEPLOY"
dockerAuthSecretName: $(dockerAuthSecretName)
@@ -113,7 +112,6 @@ jobs:
tag: ${{ parameters.imageTag }}
persistence:
enabled: true
shareName: ${{ parameters.backendStorageShareName }}
mountPath: ${{ parameters.backendStorageMountPath }}
nlpAnnotation:
image:

View File

@@ -8,7 +8,6 @@ trigger:
branches:
include:
- master
#- release/*
- develop
## Reference to repository containing common templates and variables
@@ -88,7 +87,7 @@ stages:
inputs:
command: buildAndPush
repository: $(pipelineImageName)
dockerfile: pipelines/docker/Dockerfile
dockerfile: pipelines/Dockerfile
buildContext: pipelines/
containerRegistry: $(containerRegistry)
tags: |
@@ -104,12 +103,12 @@ stages:
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/develop'))
dependsOn: build_test
jobs:
- template: azure-pipeline-templates/deploy.yml # Template reference
- template: azure-pipeline-templates/deploy-v2.yml # Template reference
parameters:
appReleaseName: $(appReleaseName)
appUrl: "dev-nlpannotator.pm.jh.edu"
deployEnvironment: $(devEnvironment)
kubeServiceConnection: $(devEnvironment)
deployEnvironment: $(devEnvironmentV2)
kubeServiceConnection: $(devEnvironmentV2)
namespace: $(devNamespace)
imageTag: $(Build.BuildId)
redisImageName: $(redisImageName)
@@ -117,7 +116,6 @@ stages:
backendImageName: $(backendImageName)
frontendImageName: $(frontendImageName)
pipelineImageName: $(pipelineImageName)
backendStorageShareName: "pine-files-dev"
secrets:
backend:
VEGAS_CLIENT_SECRET: $(vegas-client-secret-dev)
@@ -144,7 +142,6 @@ stages:
backendImageName: $(backendImageName)
frontendImageName: $(frontendImageName)
pipelineImageName: $(pipelineImageName)
backendStorageShareName: "pine-files-prod"
secrets:
backend:
VEGAS_CLIENT_SECRET: $(vegas-client-secret-prod)

View File

@@ -6,13 +6,20 @@ ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
# Install basic dependencies
RUN apt-get clean && \
apt-get -y update && \
apt-get -y install software-properties-common
apt-get -y install software-properties-common ca-certificates
# Copy any certs
COPY docker/*.crt /usr/local/share/ca-certificates/
RUN rm /usr/local/share/ca-certificates/empty.crt && update-ca-certificates
# Install pipenv
RUN apt-get -y update && \
apt-get -y install git build-essential python3.6 python3-pip gettext-base && \
pip3 install --upgrade pip gunicorn pipenv
apt-get -y install git build-essential python3.6 python3-pip gettext-base
RUN pip3 install --default-timeout=30 --upgrade pip gunicorn pipenv
ARG ROOT_DIR=/nlp-web-app/backend
ARG REDIS_PORT=6379
@@ -29,7 +36,7 @@ ADD Pipfile $ROOT_DIR
ADD Pipfile.lock $ROOT_DIR
WORKDIR $ROOT_DIR
RUN pipenv install --system --deploy
RUN REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt pipenv install --system --deploy
ADD pine/ $ROOT_DIR/pine/
ADD scripts/ $ROOT_DIR/scripts/

0
backend/docker/empty.crt Normal file
View File

View File

@@ -295,22 +295,22 @@ def download_collection(collection_id):
else:
return jsonify(data)
def get_doc_and_overlap_ids(collection_id):
"""
Return lists of ids for overlapping and non-overlapping documents for the collection matching the provided
collection id.
:param collection_id: str
:return: tuple
"""
params = service.params({
"where": {"collection_id": collection_id, "overlap": 0},
"projection": {"_id": 1}
})
doc_ids = [doc["_id"] for doc in service.get_all_items("documents", params)]
# doc_ids = get_all_ids("documents?where={\"collection_id\":\"%s\",\"overlap\":0}"%(collection_id))
random.shuffle(doc_ids)
overlap_ids = get_overlap_ids(collection_id)
return (doc_ids, overlap_ids)
# def get_doc_and_overlap_ids(collection_id):
# """
# Return lists of ids for overlapping and non-overlapping documents for the collection matching the provided
# collection id.
# :param collection_id: str
# :return: tuple
# """
# params = service.params({
# "where": {"collection_id": collection_id, "overlap": 0},
# "projection": {"_id": 1}
# })
# doc_ids = [doc["_id"] for doc in service.get_all_items("documents", params)]
# # doc_ids = get_all_ids("documents?where={\"collection_id\":\"%s\",\"overlap\":0}"%(collection_id))
# random.shuffle(doc_ids)
# overlap_ids = get_overlap_ids(collection_id)
# return (doc_ids, overlap_ids)
@bp.route("/add_annotator/<collection_id>", methods=["POST"])
@@ -401,8 +401,10 @@ def get_overlap_ids(collection_id):
:param collection_id: str
:return: tuple
"""
where = {"collection_id": collection_id, "overlap": 1}
params = service.where_params(where)
params = service.params({
"where": {"collection_id": collection_id, "overlap": 1},
"projection": {"_id": 1}
})
return [doc["_id"] for doc in service.get_all_items("documents", params)]
@@ -545,6 +547,8 @@ def create_collection():
#create documents if CSV file was sent in
doc_ids = []
doc_ids_overlap_0 = []
doc_ids_overlap_1 = []
if posted_file != None:
docs = []
csvreader = csv.reader(posted_file)
@@ -579,18 +583,25 @@ def create_collection():
doc["overlap"] = 0
docs.append(doc)
if len(docs) >= DOCUMENTS_PER_TRANSACTION:
doc_ids += _upload_documents(collection, docs)
transaction_doc_ids = _upload_documents(collection, docs)
doc_ids += transaction_doc_ids
for (i, doc_id) in enumerate(transaction_doc_ids):
if docs[i]["overlap"] == 0:
doc_ids_overlap_0.append(doc_id)
else:
doc_ids_overlap_1.append(doc_id)
docs = []
if len(docs) > 0:
doc_ids += _upload_documents(collection, docs)
docs = []
# create next ids
(doc_ids, overlap_ids) = get_doc_and_overlap_ids(collection_id)
random.shuffle(doc_ids_overlap_0)
#(doc_ids, overlap_ids) = get_doc_and_overlap_ids(collection_id)
overlap_obj = {
"classifier_id": classifier_id,
"document_ids": doc_ids,
"overlap_document_ids": { ann_id: overlap_ids for ann_id in collection["annotators"] }
"document_ids": doc_ids_overlap_0,
"overlap_document_ids": { ann_id: doc_ids_overlap_1 for ann_id in collection["annotators"] }
}
#for ann_id in collection["annotators"]:
# overlap_obj["overlap_document_ids"][ann_id] = overlap_ids
@@ -599,7 +610,7 @@ def create_collection():
if not instances_response.ok:
abort(instances_response.status_code, instances_response.content)
#post_items("next_instances", overlap_obj)
doc_ids.extend(overlap_ids)
#doc_ids.extend(overlap_ids)
# upload any image files
for image_file in image_files:

View File

@@ -40,13 +40,16 @@ class BaseClient(object):
__metaclass__ = abc.ABCMeta
def __init__(self, base_uri: str, name: str = None):
def __init__(self, base_uri: str, name: str = None, verify_ssl: bool = True):
"""Constructor.
:param base_uri: the base URI for the server, e.g. ``"http://localhost:5000"``
:type base_uri: str
:param name: optional human-readable name for the server, defaults to None
:type name: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
"""
self.base_uri: str = base_uri.strip("/")
"""The server's base URI.
@@ -59,6 +62,12 @@ class BaseClient(object):
:type: requests.Session
"""
self.name: str = name
self.verify_ssl: bool = verify_ssl
"""Whether to verify SSL/HTTPS calls. If you turn this off you should be fully aware of the
security consequences of such.
:type: bool
"""
self.logger: logging.Logger = logging.getLogger(self.__class__.__name__)
@abc.abstractmethod
@@ -102,6 +111,8 @@ class BaseClient(object):
"""
uri = self.uri(path, *additional_paths)
self.logger.debug("{} {}".format(method.upper(), uri))
if not self.verify_ssl:
kwargs["verify"] = False
if self.session:
resp = self.session.request(method, uri, **kwargs)
else:
@@ -192,7 +203,8 @@ class EveClient(BaseClient):
:type: str
"""
def __init__(self, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = DEFAULT_DBNAME):
def __init__(self, eve_base_uri: str, mongo_base_uri: str = None,
mongo_dbname: str = DEFAULT_DBNAME, verify_ssl: bool = True):
"""Constructor.
:param eve_base_uri: the base URI for the eve server, e.g. ``"http://localhost:5001"``
@@ -201,8 +213,11 @@ class EveClient(BaseClient):
:type mongo_base_uri: str, optional
:param mongo_dbname: the DB name that PINE uses, defaults to ``"pmap_nlp"``
:type mongo_dbname: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
"""
super().__init__(eve_base_uri, name="eve")
super().__init__(eve_base_uri, name="eve", verify_ssl=verify_ssl)
self.mongo_base_uri: str = mongo_base_uri
"""The base URI for the MongoDB server.
@@ -379,13 +394,16 @@ class PineClient(BaseClient):
"""A client to access PINE (more specifically: the backend).
"""
def __init__(self, backend_base_uri: str):
def __init__(self, backend_base_uri: str, verify_ssl: bool = True):
"""Constructor.
:param backend_base_uri: the base URI for the backend server, e.g. ``"http://localhost:5000"``
:type backend_base_uri: str
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
"""
super().__init__(backend_base_uri)
super().__init__(backend_base_uri, verify_ssl=verify_ssl)
@overrides
def is_valid(self) -> bool:
@@ -781,10 +799,11 @@ class PineClient(BaseClient):
class LocalPineClient(PineClient):
"""A client for a local PINE instance, including an :py:class<.EveClient>.
"""A client for a local PINE instance, including an :py:class:`EveClient`.
"""
def __init__(self, backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = EveClient.DEFAULT_DBNAME):
def __init__(self, backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None,
mongo_dbname: str = EveClient.DEFAULT_DBNAME, verify_ssl: bool = True):
"""Constructor.
:param backend_base_uri: the base URI for the backend server, e.g. ``"http://localhost:5000"``
@@ -795,10 +814,13 @@ class LocalPineClient(PineClient):
:type mongo_base_uri: str, optional
:param mongo_dbname: the DB name that PINE uses, defaults to ``"pmap_nlp"``
:type mongo_dbname: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
"""
super().__init__(backend_base_uri)
self.eve: EveClient = EveClient(eve_base_uri, mongo_base_uri, mongo_dbname=mongo_dbname)
super().__init__(backend_base_uri, verify_ssl=verify_ssl)
self.eve: EveClient = EveClient(eve_base_uri, mongo_base_uri, mongo_dbname=mongo_dbname, verify_ssl=verify_ssl)
"""The local :py:class:`EveClient` instance.
:type: EveClient

View File

@@ -79,7 +79,6 @@ services:
image: al_pipeline
build:
context: ./pipelines/
dockerfile: docker/Dockerfile
environment:
AL_PIPELINE: opennlp
AL_REDIS_HOST: redis

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: cf05c036b9504a2049358d358c8a7799
config: 28db3ee17933f0afc4bbd3a81209a862
tags: 645f666f9bcd5a90fca523b33c5a78b7

View File

@@ -13,8 +13,9 @@ Functions
.. autoapisummary::
pine.backend.annotations.bp.check_document_by_id
pine.backend.annotations.bp.check_document
pine.backend.annotations.bp.check_document_view_by_id
pine.backend.annotations.bp.check_document_view
pine.backend.annotations.bp.check_document_annotate
pine.backend.annotations.bp.get_my_annotations_for_document
pine.backend.annotations.bp.get_others_annotations_for_document
pine.backend.annotations.bp.get_annotations_for_document
@@ -43,7 +44,7 @@ Functions
.. function:: check_document_by_id(doc_id: str)
.. function:: check_document_view_by_id(doc_id: str)
Verify that a document with the given doc_id exists and that the logged in user has permissions to access the
document
@@ -51,7 +52,10 @@ Functions
:return: dict
.. function:: check_document(doc: dict)
.. function:: check_document_view(doc: dict)
.. function:: check_document_annotate(doc: dict)
.. function:: get_my_annotations_for_document(doc_id)

View File

@@ -65,63 +65,56 @@ Functions
.. function:: flask_get_module()
.. function:: flask_get_flat() -> Response
.. function:: flask_get_flat() -> flask.Response
.. function:: flask_get_can_manage_users() -> Response
.. function:: flask_get_can_manage_users() -> flask.Response
.. function:: flask_get_logged_in_user() -> Response
.. function:: flask_get_logged_in_user() -> flask.Response
.. function:: flask_get_logged_in_user_details() -> Response
.. function:: flask_get_logged_in_user_details() -> flask.Response
.. function:: flask_get_login_form() -> Response
.. function:: flask_get_login_form() -> flask.Response
.. function:: flask_post_logout() -> Response
.. function:: flask_post_logout() -> flask.Response
.. py:class:: AuthModule(app, bp)
.. class:: AuthModule(app, bp)
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: __metaclass__
.. method:: is_flat(self)
.. method:: is_flat(self) -> bool
:abstractmethod:
.. method:: can_manage_users(self)
.. method:: can_manage_users(self) -> bool
:abstractmethod:
.. method:: get_login_form(self)
.. method:: get_login_form(self) -> pine.backend.models.LoginForm
:abstractmethod:
.. method:: get_logged_in_user(self)
.. method:: get_logged_in_user_details(self)
.. method:: get_logged_in_user_details(self) -> pine.backend.models.UserDetails
.. method:: logout(self)
.. function:: init_app(app)

View File

@@ -17,71 +17,58 @@ Classes
.. py:class:: EveUser(data)
.. class:: EveUser(data)
Bases: :class:`pine.backend.models.AuthUser`
Initialize self. See help(type(self)) for accurate signature.
.. method:: id(self)
:property:
.. method:: username(self)
:property:
.. method:: display_name(self)
:property:
.. method:: is_admin(self)
:property:
.. method:: get_details(self)
.. method:: get_details(self) -> pine.backend.models.UserDetails
.. class:: EveModule(app, bp)
.. py:class:: EveModule(app, bp)
Bases: :class:`pine.backend.auth.bp.AuthModule`
.. method:: is_flat(self)
.. method:: is_flat(self) -> bool
.. method:: can_manage_users(self)
.. method:: can_manage_users(self) -> bool
.. method:: get_logged_in_user_details(self)
.. method:: update_user_details(self)
.. method:: update_user_password(self)
.. method:: get_login_form(self)
.. method:: get_login_form(self) -> pine.backend.models.LoginForm
.. method:: login(self)
.. method:: login(self) -> flask.Response
.. method:: get_all_users(self)

View File

@@ -17,34 +17,30 @@ Classes
.. py:class:: OAuthUser(data)
.. class:: OAuthUser(data)
Bases: :class:`pine.backend.models.AuthUser`
Initialize self. See help(type(self)) for accurate signature.
.. method:: id(self)
:property:
.. method:: username(self)
:property:
.. method:: display_name(self)
:property:
.. method:: is_admin(self)
:property:
.. class:: OAuthModule(app, bp)
.. py:class:: OAuthModule(app, bp)
Bases: :class:`pine.backend.auth.bp.AuthModule`
@@ -52,30 +48,23 @@ Classes
:abstractmethod:
.. method:: get_login_form_button_text(self)
:abstractmethod:
.. method:: is_flat(self)
.. method:: is_flat(self) -> bool
.. method:: can_manage_users(self)
.. method:: can_manage_users(self) -> bool
.. method:: get_login_form(self)
.. method:: get_login_form(self) -> pine.backend.models.LoginForm
.. method:: login(self)
.. method:: login(self) -> flask.Response
.. method:: authorize(self)

View File

@@ -16,16 +16,15 @@ Classes
.. py:class:: VegasAuthModule(app, bp)
.. class:: VegasAuthModule(app, bp)
Bases: :class:`pine.backend.auth.oauth.OAuthModule`
.. method:: register_oauth(self, oauth, app)
.. method:: get_login_form_button_text(self)

View File

@@ -15,17 +15,10 @@ Functions
pine.backend.collections.bp.is_cached_last_collection
pine.backend.collections.bp.update_cached_last_collection
pine.backend.collections.bp._collection_user_can_projection
pine.backend.collections.bp._collection_user_can
pine.backend.collections.bp.user_can_annotate
pine.backend.collections.bp.user_can_view
pine.backend.collections.bp.user_can_add_documents_or_images
pine.backend.collections.bp.user_can_modify_document_metadata
pine.backend.collections.bp.user_can_annotate_by_id
pine.backend.collections.bp.user_can_annotate_by_ids
pine.backend.collections.bp.user_can_view_by_id
pine.backend.collections.bp.user_can_add_documents_or_images_by_id
pine.backend.collections.bp.user_can_modify_document_metadata_by_id
pine.backend.collections.bp.user_permissions_projection
pine.backend.collections.bp.get_user_permissions
pine.backend.collections.bp.get_user_permissions_by_id
pine.backend.collections.bp.get_user_permissions_by_ids
pine.backend.collections.bp.get_user_collections
pine.backend.collections.bp.get_unarchived_user_collections
pine.backend.collections.bp.get_archived_user_collections
@@ -48,7 +41,7 @@ Functions
pine.backend.collections.bp.get_collection_image_exists
pine.backend.collections.bp._path_split
pine.backend.collections.bp._safe_path
pine.backend.collections.bp.get_user_can_add_documents_or_images
pine.backend.collections.bp.endpoint_get_user_permissions
pine.backend.collections.bp._upload_collection_image_file
pine.backend.collections.bp.post_collection_image
pine.backend.collections.bp.init_app
@@ -80,37 +73,16 @@ Functions
.. function:: update_cached_last_collection(collection_id)
.. function:: _collection_user_can_projection()
.. function:: user_permissions_projection()
.. function:: _collection_user_can(collection, annotate)
.. function:: get_user_permissions(collection: dict) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_annotate(collection)
.. function:: get_user_permissions_by_id(collection_id: str) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_view(collection)
.. function:: user_can_add_documents_or_images(collection)
.. function:: user_can_modify_document_metadata(collection)
.. function:: user_can_annotate_by_id(collection_id)
.. function:: user_can_annotate_by_ids(collection_ids)
.. function:: user_can_view_by_id(collection_id)
.. function:: user_can_add_documents_or_images_by_id(collection_id)
.. function:: user_can_modify_document_metadata_by_id(collection_id)
.. function:: get_user_permissions_by_ids(collection_ids: Iterable[str]) -> List[models.CollectionUserPermissions]
.. function:: get_user_collections(archived, page)
@@ -240,7 +212,7 @@ Functions
.. function:: _safe_path(path)
.. function:: get_user_can_add_documents_or_images(collection_id)
.. function:: endpoint_get_user_permissions(collection_id)
.. function:: _upload_collection_image_file(collection_id, path, image_file)

View File

@@ -28,41 +28,21 @@ Functions
.. autoapisummary::
pine.backend.collections.user_can_annotate
pine.backend.collections.user_can_view
pine.backend.collections.user_can_add_documents_or_images
pine.backend.collections.user_can_modify_document_metadata
pine.backend.collections.user_can_annotate_by_id
pine.backend.collections.user_can_annotate_by_ids
pine.backend.collections.user_can_view_by_id
pine.backend.collections.user_can_add_documents_or_images_by_id
pine.backend.collections.user_can_modify_document_metadata_by_id
pine.backend.collections.user_permissions_projection
pine.backend.collections.get_user_permissions
pine.backend.collections.get_user_permissions_by_id
pine.backend.collections.get_user_permissions_by_ids
.. function:: user_can_annotate(collection)
.. function:: user_permissions_projection()
.. function:: user_can_view(collection)
.. function:: get_user_permissions(collection: dict) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_add_documents_or_images(collection)
.. function:: get_user_permissions_by_id(collection_id: str) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_modify_document_metadata(collection)
.. function:: user_can_annotate_by_id(collection_id)
.. function:: user_can_annotate_by_ids(collection_ids)
.. function:: user_can_view_by_id(collection_id)
.. function:: user_can_add_documents_or_images_by_id(collection_id)
.. function:: user_can_modify_document_metadata_by_id(collection_id)
.. function:: get_user_permissions_by_ids(collection_ids: Iterable[str]) -> List[models.CollectionUserPermissions]

View File

@@ -44,25 +44,21 @@ Functions
.. py:class:: PerformanceHistory
.. class:: PerformanceHistory
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. method:: pformat(self, **kwargs)
.. method:: pprint(self)
.. method:: add(self, rest_type, path, response)
.. data:: PERFORMANCE_HISTORY

View File

@@ -16,6 +16,7 @@ Functions
pine.backend.data.users.get_all_users
pine.backend.data.users.get_user
pine.backend.data.users.get_user_by_email
pine.backend.data.users.get_user_by_id_or_email
pine.backend.data.users.get_user_details
pine.backend.data.users.update_user
pine.backend.data.users.print_users_command
@@ -34,16 +35,19 @@ Functions
.. function:: get_user_by_email(email)
.. function:: get_user_by_id_or_email(username)
.. function:: get_user_details(user_id)
.. function:: update_user(user_id: str, details: models.UserDetails)
.. function:: update_user(user_id: str, details: pine.backend.models.UserDetails)
.. function:: print_users_command()
.. function:: add_admin_command(username, password)
.. function:: add_admin_command(user_id, username, password)
.. function:: set_user_password_by_id(user_id, password)

View File

@@ -15,21 +15,16 @@ Functions
pine.backend.documents.bp._document_user_can_projection
pine.backend.documents.bp.get_collection_ids_for
pine.backend.documents.bp.user_can_annotate
pine.backend.documents.bp.user_can_view
pine.backend.documents.bp.user_can_modify_metadata
pine.backend.documents.bp.user_can_annotate_by_id
pine.backend.documents.bp.user_can_annotate_by_ids
pine.backend.documents.bp.user_can_view_by_id
pine.backend.documents.bp.user_can_modify_metadata_by_id
pine.backend.documents.bp.get_user_permissions
pine.backend.documents.bp.get_user_permissions_by_id
pine.backend.documents.bp.get_user_permissions_by_ids
pine.backend.documents.bp.get_document
pine.backend.documents.bp.count_documents_in_collection
pine.backend.documents.bp.get_all_documents_in_collection
pine.backend.documents.bp.get_paginated_documents_in_collection
pine.backend.documents.bp._check_documents
pine.backend.documents.bp.add_document
pine.backend.documents.bp.can_annotate_document
pine.backend.documents.bp.can_modify_metadata
pine.backend.documents.bp.endpoint_get_user_permissions
pine.backend.documents.bp.update_metadata
pine.backend.documents.bp.init_app
@@ -45,25 +40,13 @@ Functions
.. function:: get_collection_ids_for(document_ids) -> set
.. function:: user_can_annotate(document)
.. function:: get_user_permissions(document: dict) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_view(document)
.. function:: get_user_permissions_by_id(document_id: str) -> pine.backend.models.CollectionUserPermissions
.. function:: user_can_modify_metadata(document)
.. function:: user_can_annotate_by_id(document_id)
.. function:: user_can_annotate_by_ids(document_ids)
.. function:: user_can_view_by_id(document_id)
.. function:: user_can_modify_metadata_by_id(document_id)
.. function:: get_user_permissions_by_ids(document_ids: Iterable[str]) -> List[models.CollectionUserPermissions]
.. function:: get_document(doc_id)
@@ -84,10 +67,7 @@ Functions
.. function:: add_document()
.. function:: can_annotate_document(doc_id)
.. function:: can_modify_metadata(doc_id)
.. function:: endpoint_get_user_permissions(doc_id)
.. function:: update_metadata(doc_id)

View File

@@ -13,3 +13,30 @@ Submodules
bp/index.rst
Package Contents
----------------
Functions
~~~~~~~~~
.. autoapisummary::
pine.backend.documents.get_collection_ids_for
pine.backend.documents.get_user_permissions
pine.backend.documents.get_user_permissions_by_id
pine.backend.documents.get_user_permissions_by_ids
.. function:: get_collection_ids_for(document_ids) -> set
.. function:: get_user_permissions(document: dict) -> pine.backend.models.CollectionUserPermissions
.. function:: get_user_permissions_by_id(document_id: str) -> pine.backend.models.CollectionUserPermissions
.. function:: get_user_permissions_by_ids(document_ids: Iterable[str]) -> List[models.CollectionUserPermissions]

View File

@@ -26,7 +26,8 @@ Classes
.. py:class:: ServiceManager(default_handler=None)
.. class:: ServiceManager(default_handler=None)
Bases: :class:`object`
@@ -140,7 +141,6 @@ Classes
.. method:: get_registered_channels(cls, include_ttl=False)
:classmethod:
Get list of registered channels, with registration time if requested.
:type include_ttl: bool
:rtype: list[str] | dict[str, datetime]
@@ -149,7 +149,6 @@ Classes
.. method:: get_registered_service_details(cls, service_name=None)
:classmethod:
Get registration details of a service.
:type service_name: str
:rtype: None | dict
@@ -158,7 +157,6 @@ Classes
.. method:: get_registered_services(cls, include_details=True)
:classmethod:
Get list of registered services and registration body if requested.
:type include_details: bool
:rtype: list[str] | list[dict]
@@ -167,7 +165,6 @@ Classes
.. method:: send_service_request(cls, service_name, data, job_id=None, encoder=None)
:classmethod:
Queue's a job for the requested service.
:type service_name: str
:type data: dict
@@ -178,54 +175,46 @@ Classes
.. method:: start_listeners(self)
Starts all the workers.
.. method:: stop_listeners(self)
Stops all the workers.
.. method:: _start_registration_listener(self)
Starts the registration worker.
:rtype: bool
.. method:: _start_processing_listeners(self)
Starts the processing workers.
:rtype: bool
.. method:: _start_channel_watchdog(self)
Starts the channel watchdog workers in an asyncio-only thread. It monitors the channel TTL's.
:rtype: bool
.. method:: _stop_channel_watchdog(self)
Stops the channel watchdog workers in an asyncio-only thread.
:rtype: bool
.. method:: _registration_listener(self)
Registration Listener Implementation.
.. method:: _channel_watchdog(self)
:async:
Channel Watchdog Implementation.
In asyncio, it monitors the channel-ttl keys and the channels SET to expire registered services as needed.
The other functionality is to register new channels as they're added to the pubsub in the processing listener.
@@ -235,14 +224,11 @@ Classes
:staticmethod:
.. method:: _processing_listener_handler_wrapper(self, job_id, job_type, job_queue, job_data)
.. method:: _processing_listener(self)
Processing Listener Implementation.
Runs a handler when a processing message gets send over an already registered channel.

View File

@@ -50,7 +50,7 @@ Functions
.. py:class:: Action
.. class:: Action
Bases: :class:`enum.Enum`
@@ -58,9 +58,6 @@ Functions
Derive from this class to define new enumerations.
Create and return a new object. See help(type) for accurate signature.
.. attribute:: LOGIN
@@ -126,13 +123,13 @@ Functions
.. function:: access_flask_add_document(document: dict)
.. function:: access_flask_add_documents(documents: typing.List[dict])
.. function:: access_flask_add_documents(documents: List[dict])
.. function:: access_flask_annotate_document(annotation)
.. function:: access_flask_annotate_documents(annotations: typing.List[dict])
.. function:: access_flask_annotate_documents(annotations: List[dict])
.. function:: access(action, user, request_info, message, **extra_info)

View File

@@ -17,10 +17,11 @@ Classes
pine.backend.models.LoginForm
pine.backend.models.AuthUser
pine.backend.models.UserDetails
pine.backend.models.CollectionUserPermissions
.. py:class:: LoginFormFieldType
.. class:: LoginFormFieldType
Bases: :class:`enum.Enum`
@@ -28,9 +29,6 @@ Classes
Derive from this class to define new enumerations.
Create and return a new object. See help(type) for accurate signature.
.. attribute:: TEXT
:annotation: = text
@@ -42,67 +40,135 @@ Classes
.. py:class:: LoginFormField(name: str, display: str, field_type: LoginFormFieldType)
.. class:: LoginFormField(name: str, display: str, field_type: pine.backend.models.LoginFormFieldType)
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. method:: to_dict(self)
.. class:: LoginForm(fields: list, button_text: str)
.. py:class:: LoginForm(fields: list, button_text: str)
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. method:: to_dict(self)
.. class:: AuthUser
.. py:class:: AuthUser
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. method:: id(self)
:property:
.. method:: username(self)
:property:
.. method:: display_name(self)
:property:
.. method:: is_admin(self)
:property:
.. method:: to_dict(self)
.. class:: UserDetails(first_name, last_name, description)
.. py:class:: UserDetails(first_name, last_name, description)
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. method:: to_dict(self)
.. class:: CollectionUserPermissions(view=False, annotate=False, add_documents=False, add_images=False, modify_users=False, modify_labels=False, modify_document_metadata=False, download_data=False, archive=False)
Bases: :class:`object`
Collection permissions for a user as a dictionary of boolean flags.
.. attribute:: view
:annotation: :bool
Whether the user can view the collection and documents.
:type: bool
.. attribute:: annotate
:annotation: :bool
Whether the user can annotate collection documents.
:type: bool
.. attribute:: add_documents
:annotation: :bool
Whether the user can add documents to the collection.
:type: bool
.. attribute:: add_images
:annotation: :bool
Whether the user can add images to the collection.
:type: bool
.. attribute:: modify_users
:annotation: :bool
Whether the user can modify the list of viewers/annotators for the collection.
:type: bool
.. attribute:: modify_labels
:annotation: :bool
Whether the user can modify the list of labels for the collection.
:type: bool
.. attribute:: modify_document_metadata
:annotation: :bool
Whether the user can modify document metadata (such as changing the image).
:type: bool
.. attribute:: download_data
:annotation: :bool
Whether the user can download the collection data
:type: bool
.. attribute:: archive
:annotation: :bool
Whether the user can archive or unarchive the collection.
:type: bool
.. method:: to_dict(self) -> dict
Returns a dict version of this object for conversion to JSON.
:returns: a dict version of this object for conversion to JSON
:rtype: dict

View File

@@ -43,9 +43,8 @@ Functions
.. py:class:: Document(txt, doc_id)
.. class:: Document(txt, doc_id)
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: __slots__
:annotation: = ['ann_files', 'txt', 'doc_id']
@@ -59,71 +58,58 @@ Functions
.. function:: compute_f1(tp, fp, fn)
.. py:class:: F1Agreement(annotators, documents, labels, eval_func=exact_match_instance_evaluation, token_func=None)
.. class:: F1Agreement(annotators, documents, labels, eval_func=exact_match_instance_evaluation, token_func=None)
Initialize self. See help(type(self)) for accurate signature.
.. method:: annotators(self)
:property:
.. method:: documents(self)
:property:
.. method:: labels(self)
:property:
.. method:: _compute_tp_fp_fn(self, documents)
.. method:: _increment_counts(self, annotations, pair, doc, kind)
.. method:: mean_sd_per_label(self)
Mean and standard deviation of all annotator combinations' F1 scores by label.
.. method:: mean_sd_per_document(self)
Mean and standard deviation of all annotator combinations' F1 scores per document.
.. method:: mean_sd_total(self)
Mean and standard deviation of all annotator cominations' F1 scores.
.. method:: mean_sd_per_label_one_vs_rest(self, annotator)
Mean and standard deviation of all annotator combinations' F1 scores involving given annotator per label.
.. method:: mean_sd_total_one_vs_rest(self, annotator)
Mean and standard deviation of all annotator combinations' F1 scores involving given annotator.
.. method:: _pairs_involving(self, annotator)
.. method:: _mean_sd(f1_pairs)
:staticmethod:
Mean and standard deviation along first axis.
@@ -131,10 +117,8 @@ Functions
:staticmethod:
.. method:: compute_total_f1_matrix(self)
Returns (n x n) matrix, where n is the number of annotators, containing
pair-wise total F1 scores between all annotators.
@@ -143,7 +127,6 @@ Functions
.. method:: draw_heatmap(self, out_path)
Draws heatmap based on square matrix of F1 scores.

View File

@@ -54,71 +54,58 @@ Functions
.. py:class:: F1Agreement(annotators, documents, labels, eval_func=exact_match_instance_evaluation, token_func=None)
.. class:: F1Agreement(annotators, documents, labels, eval_func=exact_match_instance_evaluation, token_func=None)
Initialize self. See help(type(self)) for accurate signature.
.. method:: annotators(self)
:property:
.. method:: documents(self)
:property:
.. method:: labels(self)
:property:
.. method:: _compute_tp_fp_fn(self, documents)
.. method:: _increment_counts(self, annotations, pair, doc, kind)
.. method:: mean_sd_per_label(self)
Mean and standard deviation of all annotator combinations' F1 scores by label.
.. method:: mean_sd_per_document(self)
Mean and standard deviation of all annotator combinations' F1 scores per document.
.. method:: mean_sd_total(self)
Mean and standard deviation of all annotator cominations' F1 scores.
.. method:: mean_sd_per_label_one_vs_rest(self, annotator)
Mean and standard deviation of all annotator combinations' F1 scores involving given annotator per label.
.. method:: mean_sd_total_one_vs_rest(self, annotator)
Mean and standard deviation of all annotator combinations' F1 scores involving given annotator.
.. method:: _pairs_involving(self, annotator)
.. method:: _mean_sd(f1_pairs)
:staticmethod:
Mean and standard deviation along first axis.
@@ -126,10 +113,8 @@ Functions
:staticmethod:
.. method:: compute_total_f1_matrix(self)
Returns (n x n) matrix, where n is the number of annotators, containing
pair-wise total F1 scores between all annotators.
@@ -138,14 +123,12 @@ Functions
.. method:: draw_heatmap(self, out_path)
Draws heatmap based on square matrix of F1 scores.
.. py:class:: Document(txt, doc_id)
.. class:: Document(txt, doc_id)
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: __slots__
:annotation: = ['ann_files', 'txt', 'doc_id']

View File

@@ -41,20 +41,17 @@ Functions
.. function:: read(path, encoding=ENCODING, newline='\r\n', mode='r')
.. py:class:: TokenOverlap(text, tokens)
.. class:: TokenOverlap(text, tokens)
Data structure for quick lookup of tokens overlapping with given span.
Assumes that the provided list of tokens is sorted by indices!
Initialize self. See help(type(self)) for accurate signature.
.. method:: compute_mapping(text_length, tokens)
:staticmethod:
.. method:: overlapping_tokens(self, start, end)

View File

@@ -23,12 +23,11 @@ Classes
.. py:class:: BaseConfig(root_dir=None)
.. class:: BaseConfig(root_dir=None)
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: ROOT_DIR
@@ -178,33 +177,27 @@ Classes
:classmethod:
.. method:: _process_paths(cls, alt_path=None)
:classmethod:
.. method:: _process_file_cfg(cls)
:classmethod:
.. method:: _process_env_vars(cls)
:classmethod:
.. method:: as_dict(cls)
:classmethod:
:rtype: dict
.. method:: as_attr_dict(cls)
:classmethod:
:rtype: munch.Munch | dict
@@ -212,26 +205,22 @@ Classes
:staticmethod:
.. method:: _str2bool(_str, _default=None)
:staticmethod:
.. class:: TestConfig(root_dir=None)
.. py:class:: TestConfig(root_dir=None)
Bases: :class:`pine.backend.shared.config.BaseConfig`
Initialize self. See help(type(self)) for accurate signature.
.. class:: ConfigBuilder
.. py:class:: ConfigBuilder
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: __env_cfg_variable
:annotation: = BUILDER_CFG_PROFILE
@@ -260,28 +249,24 @@ Classes
.. method:: __get_configs()
:staticmethod:
:rtype list[Callable[..., BaseConfig]]
.. method:: get_config_names()
:staticmethod:
:rtype: list[str]
.. method:: get_arg_parser(cls)
:classmethod:
:rtype: ArgumentParser
.. method:: init_config(cls, config_name=None, config_base=None, enable_terminal=True, as_attr_dict=True)
:classmethod:
:type config_name: str | None
:type config_base: str | None
:type enable_terminal: bool
@@ -291,7 +276,6 @@ Classes
.. method:: get_config(cls, config_name=None, config_base=None, enable_terminal=True, as_attr_dict=True)
:classmethod:
:type config_name: str | None
:type config_base: str | None
:type enable_terminal: bool
@@ -302,7 +286,6 @@ Classes
.. method:: set_config(cls, config_name=None, config_base=None, enable_terminal=True, as_attr_dict=True)
:classmethod:
:type config_name: str | None
:type config_base: str | None
:type enable_terminal: bool
@@ -312,7 +295,6 @@ Classes
.. method:: __parse_terminal_config(cls)
:classmethod:
:rtype: argparse.Namespace

View File

@@ -32,7 +32,7 @@ Functions
pine.client.client._standardize_path
.. function:: _standardize_path(path: str, *additional_paths: typing.List[str]) -> typing.List[str]
.. function:: _standardize_path(path: str, *additional_paths: List[str]) -> List[str]
Standardize path(s) into a list of path components.
@@ -45,7 +45,8 @@ Functions
:rtype: list(str)
.. py:class:: BaseClient(base_uri: str, name: str = None)
.. class:: BaseClient(base_uri: str, name: str = None, verify_ssl: bool = True)
Bases: :class:`object`
@@ -58,6 +59,9 @@ Functions
:type base_uri: str
:param name: optional human-readable name for the server, defaults to None
:type name: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. attribute:: __metaclass__
@@ -80,9 +84,17 @@ Functions
:type: requests.Session
.. method:: is_valid(self)
:abstractmethod:
.. attribute:: verify_ssl
:annotation: :bool
Whether to verify SSL/HTTPS calls. If you turn this off you should be fully aware of the
security consequences of such.
:type: bool
.. method:: is_valid(self) -> bool
:abstractmethod:
Returns whether this client and its connection(s) are valid.
@@ -90,8 +102,7 @@ Functions
:rtype: bool
.. method:: uri(self, path: str, *additional_paths: typing.List[str])
.. method:: uri(self, path: str, *additional_paths: List[str]) -> str
Makes a complete URI from the given path(s).
@@ -104,8 +115,7 @@ Functions
:rtype: str
.. method:: _req(self, method: str, path: str, *additional_paths: typing.List[str], **kwargs)
.. method:: _req(self, method: str, path: str, *additional_paths: List[str], **kwargs) -> requests.Response
Makes a :py:mod:`requests` call, checks for errors, and returns the response.
@@ -124,8 +134,7 @@ Functions
:rtype: requests.Response
.. method:: get(self, path: str, *additional_paths: typing.List[str], **kwargs)
.. method:: get(self, path: str, *additional_paths: List[str], **kwargs) -> requests.Response
Makes a :py:mod:`requests` ``GET`` call, checks for errors, and returns the response.
@@ -142,8 +151,7 @@ Functions
:rtype: requests.Response
.. method:: put(self, path: str, *additional_paths: typing.List[str], **kwargs)
.. method:: put(self, path: str, *additional_paths: List[str], **kwargs) -> requests.Response
Makes a :py:mod:`requests` ``PUT`` call, checks for errors, and returns the response.
@@ -160,8 +168,7 @@ Functions
:rtype: requests.Response
.. method:: patch(self, path: str, *additional_paths: typing.List[str], **kwargs)
.. method:: patch(self, path: str, *additional_paths: List[str], **kwargs) -> requests.Response
Makes a :py:mod:`requests` ``PATCH`` call, checks for errors, and returns the response.
@@ -178,8 +185,7 @@ Functions
:rtype: requests.Response
.. method:: post(self, path: str, *additional_paths: typing.List[str], **kwargs)
.. method:: post(self, path: str, *additional_paths: List[str], **kwargs) -> requests.Response
Makes a :py:mod:`requests` ``POST`` call, checks for errors, and returns the response.
@@ -197,7 +203,8 @@ Functions
.. py:class:: EveClient(eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = DEFAULT_DBNAME)
.. class:: EveClient(eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = DEFAULT_DBNAME, verify_ssl: bool = True)
Bases: :class:`pine.client.client.BaseClient`
@@ -212,6 +219,9 @@ Functions
:type mongo_base_uri: str, optional
:param mongo_dbname: the DB name that PINE uses, defaults to ``"pmap_nlp"``
:type mongo_dbname: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. attribute:: DEFAULT_DBNAME
:annotation: :str = pmap_nlp
@@ -245,8 +255,7 @@ Functions
:type: pymongo.database.Database
.. method:: is_valid(self)
.. method:: is_valid(self) -> bool
Returns whether this client and its connection(s) are valid.
@@ -254,8 +263,7 @@ Functions
:rtype: bool
.. method:: ping(self)
.. method:: ping(self) -> Any
Pings the eve server and returns the result.
@@ -264,8 +272,7 @@ Functions
:returns: the JSON response from the server (probably ``"pong"``)
.. method:: about(self)
.. method:: about(self) -> dict
Returns the 'about' dict from the server.
@@ -275,8 +282,7 @@ Functions
:rtype: dict
.. method:: get_resource(self, resource: str, resource_id: str)
.. method:: get_resource(self, resource: str, resource_id: str) -> dict
Gets a resource from eve by its ID.
@@ -286,8 +292,7 @@ Functions
:rtype: dict
.. method:: _add_or_replace_resource(self, resource: str, obj: dict, valid_fn: typing.Callable[[dict, typing.Callable[[str], None]], bool] = None)
.. method:: _add_or_replace_resource(self, resource: str, obj: dict, valid_fn: Callable[([dict, typing.Callable[[str], None]], bool)] = None) -> str
Adds or replaces the given resource.
@@ -305,8 +310,7 @@ Functions
:rtype: str
.. method:: _add_resources(self, resource: str, objs: typing.List[dict], valid_fn: typing.Callable[[dict, typing.Callable[[str], None]], bool] = None, replace_if_exists: bool = False)
.. method:: _add_resources(self, resource: str, objs: List[dict], valid_fn: Callable[([dict, typing.Callable[[str], None]], bool)] = None, replace_if_exists: bool = False)
Tries to add all the resource objects at once, optionally falling back to individual replacement if that fails.
@@ -326,8 +330,7 @@ Functions
:rtype: list(str)
.. method:: add_users(self, users: typing.List[dict], replace_if_exists=False)
.. method:: add_users(self, users: List[dict], replace_if_exists=False) -> List[str]
Adds the given users.
@@ -345,7 +348,6 @@ Functions
.. method:: get_users(self)
Gets all users.
:raises exceptions.PineClientHttpException: if the HTTP request returns an error
@@ -354,8 +356,7 @@ Functions
:rtype: list(dict)
.. method:: add_pipelines(self, pipelines: typing.List[dict], replace_if_exists=False)
.. method:: add_pipelines(self, pipelines: List[dict], replace_if_exists=False) -> List[str]
Adds the given pipelines.
@@ -372,7 +373,8 @@ Functions
.. py:class:: PineClient(backend_base_uri: str)
.. class:: PineClient(backend_base_uri: str, verify_ssl: bool = True)
Bases: :class:`pine.client.client.BaseClient`
@@ -383,9 +385,11 @@ Functions
:param backend_base_uri: the base URI for the backend server, e.g. ``"http://localhost:5000"``
:type backend_base_uri: str
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. method:: is_valid(self)
.. method:: is_valid(self) -> bool
Returns whether this client and its connection(s) are valid.
@@ -393,8 +397,7 @@ Functions
:rtype: bool
.. method:: ping(self)
.. method:: ping(self) -> Any
Pings the backend server and returns the result.
@@ -403,8 +406,7 @@ Functions
:returns: the JSON response from the server (probably ``"pong"``)
.. method:: about(self)
.. method:: about(self) -> dict
Returns the 'about' dict from the server.
@@ -414,8 +416,7 @@ Functions
:rtype: dict
.. method:: get_logged_in_user(self)
.. method:: get_logged_in_user(self) -> dict
Returns the currently logged in user, or None if not logged in.
@@ -425,8 +426,7 @@ Functions
:rtype: dict
.. method:: get_my_user_id(self)
.. method:: get_my_user_id(self) -> str
Returns the ID of the logged in user, or None if not logged in.
@@ -436,8 +436,7 @@ Functions
:rtype: str
.. method:: is_logged_in(self)
.. method:: is_logged_in(self) -> bool
Returns whether the user is currently logged in or not.
@@ -449,15 +448,13 @@ Functions
.. method:: _check_login(self)
Checks whether user is logged in and raises an :py:class:`.exceptions.PineClientAuthException` if not.
:raises exceptions.PineClientAuthException: if not logged in
:raises exceptions.PineClientHttpException: if the HTTP request returns an error
.. method:: get_auth_module(self)
.. method:: get_auth_module(self) -> str
Returns the PINE authentication module, e.g. ``"eve"``.
@@ -467,8 +464,7 @@ Functions
:rtype: str
.. method:: login_eve(self, username: str, password: str)
.. method:: login_eve(self, username: str, password: str) -> bool
Logs in using eve credentials, and returns whether it was successful.
@@ -486,14 +482,12 @@ Functions
.. method:: logout(self)
Logs out the current user.
:raises exceptions.PineClientHttpException: if the HTTP request returns an error
.. method:: get_pipelines(self)
.. method:: get_pipelines(self) -> List[dict]
Returns all pipelines accessible to logged in user.
@@ -504,8 +498,7 @@ Functions
:rtype: list(dict)
.. method:: collection_builder(self, **kwargs: dict)
.. method:: collection_builder(self, **kwargs: dict) -> pine.client.models.CollectionBuilder
Makes and returns a new :py:class:`.models.CollectionBuilder` with the logged in user.
@@ -516,8 +509,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: create_collection(self, builder: models.CollectionBuilder)
.. method:: create_collection(self, builder: pine.client.models.CollectionBuilder) -> str
Creates a collection using the current value of the given builder and returns its ID.
@@ -532,8 +524,18 @@ Functions
:rtype: str
.. method:: get_collection_documents(self, collection_id: str, truncate: bool, truncate_length: int = 30)
.. method:: get_collection_permissions(self, collection_id: str) -> pine.client.models.CollectionUserPermissions
Returns collection permissions for the logged in user.
:param collection_id: the ID of the collection
:type collection_id: str
:returns: the collection permissions
:rtype: models.CollectionUserPermissions
.. method:: get_collection_documents(self, collection_id: str, truncate: bool, truncate_length: int = 30) -> List[dict]
Returns all the documents in the given collection.
@@ -548,8 +550,7 @@ Functions
:rtype: list(dict)
.. method:: add_document(self, document: dict = {}, creator_id: str = None, collection_id: str = None, overlap: int = None, text: str = None, metadata: dict = None)
.. method:: add_document(self, document: dict = {}, creator_id: str = None, collection_id: str = None, overlap: int = None, text: str = None, metadata: dict = None) -> str
Adds a new document to a collection and returns its ID.
@@ -578,8 +579,7 @@ Functions
:rtype: str
.. method:: add_documents(self, documents: typing.List[dict], creator_id: str = None, collection_id: str = None)
.. method:: add_documents(self, documents: List[dict], creator_id: str = None, collection_id: str = None) -> List[str]
Adds multiple documents at once and returns their IDs.
@@ -600,8 +600,7 @@ Functions
:rtype: list(str)
.. method:: annotate_document(self, document_id: str, doc_annotations: typing.List[str], ner_annotations: typing.List[typing.Union[dict, list, tuple]])
.. method:: annotate_document(self, document_id: str, doc_annotations: List[str], ner_annotations: List[Union[dict, list, tuple]]) -> str
Annotates the given document with the given values.
@@ -620,8 +619,7 @@ Functions
:rtype: str
.. method:: annotate_collection_documents(self, collection_id: str, document_annotations: dict, skip_document_updates=False)
.. method:: annotate_collection_documents(self, collection_id: str, document_annotations: dict, skip_document_updates=False) -> List[str]
Annotates documents in a collection.
@@ -642,8 +640,7 @@ Functions
:rtype: list(str)
.. method:: list_collections(self, include_archived: bool = False)
.. method:: list_collections(self, include_archived: bool = False) -> List[dict]
Returns a list of user's collections.
@@ -659,7 +656,6 @@ Functions
.. method:: download_collection_data(self, collection_id: str, include_collection_metadata: bool = True, include_document_metadata: bool = True, include_document_text: bool = True, include_annotations: bool = True, include_annotation_latest_version_only: bool = True)
Downloads collection data.
:param collection_id: the ID of the collection for which to download data
@@ -686,11 +682,12 @@ Functions
.. py:class:: LocalPineClient(backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = EveClient.DEFAULT_DBNAME)
.. class:: LocalPineClient(backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = EveClient.DEFAULT_DBNAME, verify_ssl: bool = True)
Bases: :class:`pine.client.client.PineClient`
A client for a local PINE instance, including an :py:class<.EveClient>.
A client for a local PINE instance, including an :py:class:`EveClient`.
Constructor.
@@ -703,6 +700,9 @@ Functions
:type mongo_base_uri: str, optional
:param mongo_dbname: the DB name that PINE uses, defaults to ``"pmap_nlp"``
:type mongo_dbname: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. attribute:: eve
:annotation: :EveClient
@@ -712,8 +712,7 @@ Functions
:type: EveClient
.. method:: is_valid(self)
.. method:: is_valid(self) -> bool
Returns whether this client and its connection(s) are valid.

View File

@@ -12,7 +12,8 @@
Module Contents
---------------
.. py:exception:: PineClientException(message: str, cause: Exception = None)
.. exception:: PineClientException(message: str, cause: Exception = None)
Bases: :class:`Exception`
@@ -35,7 +36,8 @@ Module Contents
.. py:exception:: PineClientHttpException(method: str, path: str, resp: requests.Response)
.. exception:: PineClientHttpException(method: str, path: str, resp: requests.Response)
Bases: :class:`pine.client.exceptions.PineClientException`
@@ -52,15 +54,20 @@ Module Contents
:type resp: requests.Response
.. attribute:: resp
:annotation: :requests.Response
The :py:class:`Response <requests.Response>` with the error info
:type: requests.Response
.. method:: status_code(self)
:property:
.. exception:: PineClientValueException(obj: dict, obj_type: str)
.. py:exception:: PineClientValueException(obj: dict, obj_type: str)
Bases: :class:`pine.client.exceptions.PineClientException`
@@ -75,7 +82,8 @@ Module Contents
:type obj_type: str
.. py:exception:: PineClientAuthException(message: str, cause: Exception = None)
.. exception:: PineClientAuthException(message: str, cause: Exception = None)
Bases: :class:`pine.client.exceptions.PineClientException`

View File

@@ -44,7 +44,8 @@ Functions
pine.client.setup_logging
.. py:class:: PineClient(backend_base_uri: str)
.. class:: PineClient(backend_base_uri: str, verify_ssl: bool = True)
Bases: :class:`pine.client.client.BaseClient`
@@ -55,9 +56,11 @@ Functions
:param backend_base_uri: the base URI for the backend server, e.g. ``"http://localhost:5000"``
:type backend_base_uri: str
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. method:: is_valid(self)
.. method:: is_valid(self) -> bool
Returns whether this client and its connection(s) are valid.
@@ -65,8 +68,7 @@ Functions
:rtype: bool
.. method:: ping(self)
.. method:: ping(self) -> Any
Pings the backend server and returns the result.
@@ -75,8 +77,7 @@ Functions
:returns: the JSON response from the server (probably ``"pong"``)
.. method:: about(self)
.. method:: about(self) -> dict
Returns the 'about' dict from the server.
@@ -86,8 +87,7 @@ Functions
:rtype: dict
.. method:: get_logged_in_user(self)
.. method:: get_logged_in_user(self) -> dict
Returns the currently logged in user, or None if not logged in.
@@ -97,8 +97,7 @@ Functions
:rtype: dict
.. method:: get_my_user_id(self)
.. method:: get_my_user_id(self) -> str
Returns the ID of the logged in user, or None if not logged in.
@@ -108,8 +107,7 @@ Functions
:rtype: str
.. method:: is_logged_in(self)
.. method:: is_logged_in(self) -> bool
Returns whether the user is currently logged in or not.
@@ -121,15 +119,13 @@ Functions
.. method:: _check_login(self)
Checks whether user is logged in and raises an :py:class:`.exceptions.PineClientAuthException` if not.
:raises exceptions.PineClientAuthException: if not logged in
:raises exceptions.PineClientHttpException: if the HTTP request returns an error
.. method:: get_auth_module(self)
.. method:: get_auth_module(self) -> str
Returns the PINE authentication module, e.g. ``"eve"``.
@@ -139,8 +135,7 @@ Functions
:rtype: str
.. method:: login_eve(self, username: str, password: str)
.. method:: login_eve(self, username: str, password: str) -> bool
Logs in using eve credentials, and returns whether it was successful.
@@ -158,14 +153,12 @@ Functions
.. method:: logout(self)
Logs out the current user.
:raises exceptions.PineClientHttpException: if the HTTP request returns an error
.. method:: get_pipelines(self)
.. method:: get_pipelines(self) -> List[dict]
Returns all pipelines accessible to logged in user.
@@ -176,8 +169,7 @@ Functions
:rtype: list(dict)
.. method:: collection_builder(self, **kwargs: dict)
.. method:: collection_builder(self, **kwargs: dict) -> pine.client.models.CollectionBuilder
Makes and returns a new :py:class:`.models.CollectionBuilder` with the logged in user.
@@ -188,8 +180,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: create_collection(self, builder: models.CollectionBuilder)
.. method:: create_collection(self, builder: pine.client.models.CollectionBuilder) -> str
Creates a collection using the current value of the given builder and returns its ID.
@@ -204,8 +195,18 @@ Functions
:rtype: str
.. method:: get_collection_documents(self, collection_id: str, truncate: bool, truncate_length: int = 30)
.. method:: get_collection_permissions(self, collection_id: str) -> pine.client.models.CollectionUserPermissions
Returns collection permissions for the logged in user.
:param collection_id: the ID of the collection
:type collection_id: str
:returns: the collection permissions
:rtype: models.CollectionUserPermissions
.. method:: get_collection_documents(self, collection_id: str, truncate: bool, truncate_length: int = 30) -> List[dict]
Returns all the documents in the given collection.
@@ -220,8 +221,7 @@ Functions
:rtype: list(dict)
.. method:: add_document(self, document: dict = {}, creator_id: str = None, collection_id: str = None, overlap: int = None, text: str = None, metadata: dict = None)
.. method:: add_document(self, document: dict = {}, creator_id: str = None, collection_id: str = None, overlap: int = None, text: str = None, metadata: dict = None) -> str
Adds a new document to a collection and returns its ID.
@@ -250,8 +250,7 @@ Functions
:rtype: str
.. method:: add_documents(self, documents: typing.List[dict], creator_id: str = None, collection_id: str = None)
.. method:: add_documents(self, documents: List[dict], creator_id: str = None, collection_id: str = None) -> List[str]
Adds multiple documents at once and returns their IDs.
@@ -272,8 +271,7 @@ Functions
:rtype: list(str)
.. method:: annotate_document(self, document_id: str, doc_annotations: typing.List[str], ner_annotations: typing.List[typing.Union[dict, list, tuple]])
.. method:: annotate_document(self, document_id: str, doc_annotations: List[str], ner_annotations: List[Union[dict, list, tuple]]) -> str
Annotates the given document with the given values.
@@ -292,8 +290,7 @@ Functions
:rtype: str
.. method:: annotate_collection_documents(self, collection_id: str, document_annotations: dict, skip_document_updates=False)
.. method:: annotate_collection_documents(self, collection_id: str, document_annotations: dict, skip_document_updates=False) -> List[str]
Annotates documents in a collection.
@@ -314,8 +311,7 @@ Functions
:rtype: list(str)
.. method:: list_collections(self, include_archived: bool = False)
.. method:: list_collections(self, include_archived: bool = False) -> List[dict]
Returns a list of user's collections.
@@ -331,7 +327,6 @@ Functions
.. method:: download_collection_data(self, collection_id: str, include_collection_metadata: bool = True, include_document_metadata: bool = True, include_document_text: bool = True, include_annotations: bool = True, include_annotation_latest_version_only: bool = True)
Downloads collection data.
:param collection_id: the ID of the collection for which to download data
@@ -358,11 +353,12 @@ Functions
.. py:class:: LocalPineClient(backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = EveClient.DEFAULT_DBNAME)
.. class:: LocalPineClient(backend_base_uri: str, eve_base_uri: str, mongo_base_uri: str = None, mongo_dbname: str = EveClient.DEFAULT_DBNAME, verify_ssl: bool = True)
Bases: :class:`pine.client.client.PineClient`
A client for a local PINE instance, including an :py:class<.EveClient>.
A client for a local PINE instance, including an :py:class:`EveClient`.
Constructor.
@@ -375,6 +371,9 @@ Functions
:type mongo_base_uri: str, optional
:param mongo_dbname: the DB name that PINE uses, defaults to ``"pmap_nlp"``
:type mongo_dbname: str, optional
:param verify_ssl: whether to verify SSL/HTTPs calls; do not turn this off unless you
are fully aware of the security consequences
:type verify_ssl: bool, optional
.. attribute:: eve
:annotation: :EveClient
@@ -384,8 +383,7 @@ Functions
:type: EveClient
.. method:: is_valid(self)
.. method:: is_valid(self) -> bool
Returns whether this client and its connection(s) are valid.
@@ -402,7 +400,8 @@ Functions
passed to :py:func:`logging.config.dictConfig`.
.. py:class:: CollectionBuilder(collection: dict = None, creator_id: str = None, viewers: typing.List[str] = None, annotators: typing.List[str] = None, labels: typing.List[str] = None, title: str = None, description: str = None, allow_overlapping_ner_annotations: bool = None, pipelineId: str = None, overlap: float = None, train_every: int = None, classifierParameters: dict = None, document_csv_file: str = None, document_csv_file_has_header: bool = None, document_csv_file_text_column: int = None, image_files: typing.List[str] = None)
.. class:: CollectionBuilder(collection: dict = None, creator_id: str = None, viewers: List[str] = None, annotators: List[str] = None, labels: List[str] = None, title: str = None, description: str = None, allow_overlapping_ner_annotations: bool = None, pipelineId: str = None, overlap: float = None, train_every: int = None, classifierParameters: dict = None, document_csv_file: str = None, document_csv_file_has_header: bool = None, document_csv_file_text_column: int = None, image_files: List[str] = None)
Bases: :class:`object`
@@ -471,28 +470,25 @@ Functions
:type: dict
.. method:: collection(self)
.. method:: collection(self) -> dict
:property:
Returns the collection information from the form.
:returns: collection information from the form
:rtype: dict
.. method:: form_json(self)
.. method:: form_json(self) -> dict
:property:
Returns the form where the values have been JSON-encoded.
:returns: the form where the values have been JSON-encoded
:rtype: dict
.. method:: creator_id(self, user_id: str)
.. method:: creator_id(self, user_id: str) -> pine.client.models.CollectionBuilder
Sets the creator_id to the given, and adds to viewers and annotators.
@@ -503,8 +499,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: viewer(self, user_id: str)
.. method:: viewer(self, user_id: str) -> pine.client.models.CollectionBuilder
Adds the given user to the list of viewers.
@@ -515,8 +510,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: annotator(self, user_id: str)
.. method:: annotator(self, user_id: str) -> pine.client.models.CollectionBuilder
Adds the given user to the list of annotators.
@@ -527,8 +521,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: label(self, label: str)
.. method:: label(self, label: str) -> pine.client.models.CollectionBuilder
Adds the given label to the collection.
@@ -539,8 +532,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: metadata(self, key: str, value: typing.Any)
.. method:: metadata(self, key: str, value: Any) -> pine.client.models.CollectionBuilder
Adds the given metadata key/value to the collection.
@@ -552,8 +544,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: title(self, title: str)
.. method:: title(self, title: str) -> pine.client.models.CollectionBuilder
Sets the metadata title to the given.
@@ -564,8 +555,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: description(self, description: str)
.. method:: description(self, description: str) -> pine.client.models.CollectionBuilder
Sets the metadata description to the given.
@@ -576,8 +566,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: configuration(self, key: str, value: typing.Any)
.. method:: configuration(self, key: str, value: Any) -> pine.client.models.CollectionBuilder
Adds the given configuration key/value to the collection.
@@ -591,7 +580,6 @@ Functions
.. method:: allow_overlapping_ner_annotations(self, allow_overlapping_ner_annotations: bool)
Sets the configuration value for allow_overlapping_ner_annotations to the given.
:param allow_overlapping_ner_annotations: whether to allow overlapping NER annotations
@@ -601,8 +589,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: classifier(self, pipelineId: str, overlap: float = 0, train_every: int = 100, classifierParameters: dict = {})
.. method:: classifier(self, pipelineId: str, overlap: float = 0, train_every: int = 100, classifierParameters: dict = {}) -> pine.client.models.CollectionBuilder
Sets classifier information for the created collection.
@@ -619,8 +606,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: document_csv_file(self, csv_filename: str, has_header: bool, text_column: int)
.. method:: document_csv_file(self, csv_filename: str, has_header: bool, text_column: int) -> pine.client.models.CollectionBuilder
Sets the CSV file used to create documents to the given.
@@ -638,8 +624,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: image_file(self, image_filename: str)
.. method:: image_file(self, image_filename: str) -> pine.client.models.CollectionBuilder
Adds the given image file to the collection.
@@ -652,8 +637,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: is_valid(self, error_callback: typing.Callable[[str], None] = None)
.. method:: is_valid(self, error_callback: Callable[([str], None)] = None)
Checks whether the currently set values are valid or not.

View File

@@ -13,6 +13,7 @@ Classes
.. autoapisummary::
pine.client.models.CollectionBuilder
pine.client.models.CollectionUserPermissions
@@ -222,7 +223,7 @@ Functions
:rtype: bool
.. function:: is_valid_eve_user(user: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_eve_user(user: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given user object is valid.
@@ -239,7 +240,7 @@ Functions
:rtype: bool
.. function:: is_valid_eve_pipeline(pipeline: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_eve_pipeline(pipeline: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given pipeline object is valid.
@@ -256,7 +257,7 @@ Functions
:rtype: bool
.. function:: is_valid_eve_collection(collection: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_eve_collection(collection: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given collection object is valid.
@@ -274,7 +275,7 @@ Functions
:rtype: bool
.. function:: is_valid_collection(form: dict, files: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_collection(form: dict, files: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given form and files parameters are valid for creating a collection.
@@ -302,7 +303,7 @@ Functions
:rtype: bool
.. function:: is_valid_eve_document(document: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_eve_document(document: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given document object is valid.
@@ -319,7 +320,7 @@ Functions
:rtype: bool
.. function:: is_valid_doc_annotation(ann: typing.Any, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_doc_annotation(ann: Any, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given annotation is a valid document label/annotation.
@@ -333,7 +334,7 @@ Functions
:rtype: bool
.. function:: is_valid_ner_annotation(ann: typing.Any, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_ner_annotation(ann: Any, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given annotation is a valid document NER annotation.
@@ -360,7 +361,7 @@ Functions
:rtype: bool
.. function:: is_valid_annotation(body: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_annotation(body: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given body is valid to create an annotation.
@@ -378,7 +379,7 @@ Functions
:rtype: bool
.. function:: is_valid_doc_annotations(doc_annotations: dict, error_callback: typing.Callable[[str], None] = None) -> bool
.. function:: is_valid_doc_annotations(doc_annotations: dict, error_callback: Callable[([str], None)] = None) -> bool
Checks whether the given document annotations are valid.
@@ -394,7 +395,8 @@ Functions
:rtype: bool
.. py:class:: CollectionBuilder(collection: dict = None, creator_id: str = None, viewers: typing.List[str] = None, annotators: typing.List[str] = None, labels: typing.List[str] = None, title: str = None, description: str = None, allow_overlapping_ner_annotations: bool = None, pipelineId: str = None, overlap: float = None, train_every: int = None, classifierParameters: dict = None, document_csv_file: str = None, document_csv_file_has_header: bool = None, document_csv_file_text_column: int = None, image_files: typing.List[str] = None)
.. class:: CollectionBuilder(collection: dict = None, creator_id: str = None, viewers: List[str] = None, annotators: List[str] = None, labels: List[str] = None, title: str = None, description: str = None, allow_overlapping_ner_annotations: bool = None, pipelineId: str = None, overlap: float = None, train_every: int = None, classifierParameters: dict = None, document_csv_file: str = None, document_csv_file_has_header: bool = None, document_csv_file_text_column: int = None, image_files: List[str] = None)
Bases: :class:`object`
@@ -463,28 +465,25 @@ Functions
:type: dict
.. method:: collection(self)
.. method:: collection(self) -> dict
:property:
Returns the collection information from the form.
:returns: collection information from the form
:rtype: dict
.. method:: form_json(self)
.. method:: form_json(self) -> dict
:property:
Returns the form where the values have been JSON-encoded.
:returns: the form where the values have been JSON-encoded
:rtype: dict
.. method:: creator_id(self, user_id: str)
.. method:: creator_id(self, user_id: str) -> pine.client.models.CollectionBuilder
Sets the creator_id to the given, and adds to viewers and annotators.
@@ -495,8 +494,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: viewer(self, user_id: str)
.. method:: viewer(self, user_id: str) -> pine.client.models.CollectionBuilder
Adds the given user to the list of viewers.
@@ -507,8 +505,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: annotator(self, user_id: str)
.. method:: annotator(self, user_id: str) -> pine.client.models.CollectionBuilder
Adds the given user to the list of annotators.
@@ -519,8 +516,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: label(self, label: str)
.. method:: label(self, label: str) -> pine.client.models.CollectionBuilder
Adds the given label to the collection.
@@ -531,8 +527,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: metadata(self, key: str, value: typing.Any)
.. method:: metadata(self, key: str, value: Any) -> pine.client.models.CollectionBuilder
Adds the given metadata key/value to the collection.
@@ -544,8 +539,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: title(self, title: str)
.. method:: title(self, title: str) -> pine.client.models.CollectionBuilder
Sets the metadata title to the given.
@@ -556,8 +550,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: description(self, description: str)
.. method:: description(self, description: str) -> pine.client.models.CollectionBuilder
Sets the metadata description to the given.
@@ -568,8 +561,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: configuration(self, key: str, value: typing.Any)
.. method:: configuration(self, key: str, value: Any) -> pine.client.models.CollectionBuilder
Adds the given configuration key/value to the collection.
@@ -583,7 +575,6 @@ Functions
.. method:: allow_overlapping_ner_annotations(self, allow_overlapping_ner_annotations: bool)
Sets the configuration value for allow_overlapping_ner_annotations to the given.
:param allow_overlapping_ner_annotations: whether to allow overlapping NER annotations
@@ -593,8 +584,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: classifier(self, pipelineId: str, overlap: float = 0, train_every: int = 100, classifierParameters: dict = {})
.. method:: classifier(self, pipelineId: str, overlap: float = 0, train_every: int = 100, classifierParameters: dict = {}) -> pine.client.models.CollectionBuilder
Sets classifier information for the created collection.
@@ -611,8 +601,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: document_csv_file(self, csv_filename: str, has_header: bool, text_column: int)
.. method:: document_csv_file(self, csv_filename: str, has_header: bool, text_column: int) -> pine.client.models.CollectionBuilder
Sets the CSV file used to create documents to the given.
@@ -630,8 +619,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: image_file(self, image_filename: str)
.. method:: image_file(self, image_filename: str) -> pine.client.models.CollectionBuilder
Adds the given image file to the collection.
@@ -644,8 +632,7 @@ Functions
:rtype: models.CollectionBuilder
.. method:: is_valid(self, error_callback: typing.Callable[[str], None] = None)
.. method:: is_valid(self, error_callback: Callable[([str], None)] = None)
Checks whether the currently set values are valid or not.
@@ -659,6 +646,86 @@ Functions
.. class:: CollectionUserPermissions(view=False, annotate=False, add_documents=False, add_images=False, modify_users=False, modify_labels=False, modify_document_metadata=False, download_data=False, archive=False)
Bases: :class:`object`
Collection permissions for a user as a dictionary of boolean flags.
.. attribute:: view
:annotation: :bool
Whether the user can view the collection and documents.
:type: bool
.. attribute:: annotate
:annotation: :bool
Whether the user can annotate collection documents.
:type: bool
.. attribute:: add_documents
:annotation: :bool
Whether the user can add documents to the collection.
:type: bool
.. attribute:: add_images
:annotation: :bool
Whether the user can add images to the collection.
:type: bool
.. attribute:: modify_users
:annotation: :bool
Whether the user can modify the list of viewers/annotators for the collection.
:type: bool
.. attribute:: modify_labels
:annotation: :bool
Whether the user can modify the list of labels for the collection.
:type: bool
.. attribute:: modify_document_metadata
:annotation: :bool
Whether the user can modify document metadata (such as changing the image).
:type: bool
.. attribute:: download_data
:annotation: :bool
Whether the user can download the collection data
:type: bool
.. attribute:: archive
:annotation: :bool
Whether the user can archive or unarchive the collection.
:type: bool
.. method:: to_dict(self) -> dict
Returns a dict version of this object for conversion to JSON.
:returns: a dict version of this object for conversion to JSON
:rtype: dict
.. function:: remove_eve_fields(obj: dict, remove_timestamps: bool = True, remove_versions: bool = True)
Removes fields inserted by eve from the given object.

View File

@@ -26,12 +26,11 @@ Classes
.. py:class:: EveClient(entry_point='{}:{}'.format(config.EVE_HOST, config.EVE_PORT))
.. class:: EveClient(entry_point='{}:{}'.format(config.EVE_HOST, config.EVE_PORT))
Bases: :class:`object`
Initialize self. See help(type(self)) for accurate signature.
.. attribute:: eve_headers
@@ -40,33 +39,25 @@ Classes
.. method:: add(self, resource, add_object)
.. method:: get_obj(self, resource, id)
.. method:: get_all_items(self, resource)
.. method:: get_all_ids(self, resource)
.. method:: get_items(self, resource)
.. method:: get_documents(self, collection_id)
.. method:: get_docs_with_annotations(self, collection_id, doc_map)
.. method:: update(self, resource, id, etag, update_obj)

Some files were not shown because too many files have changed in this diff Show More