Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=too-many-lines,line-too-long,useless-suppression
# pylint: disable=too-many-lines,line-too-long,useless-suppression,unidiomatic-typecheck
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=line-too-long,useless-suppression,too-many-lines
# pylint: disable=line-too-long,useless-suppression,too-many-lines,unidiomatic-typecheck
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@


import asyncio
import os
import uuid
from azure.core.polling import AsyncLROPoller
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
Expand All @@ -31,8 +33,6 @@
TargetStorageLocation,
)
from azure.identity.aio import DefaultAzureCredential
import os
import uuid


async def deidentify_documents_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@


import asyncio
import os
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationContent,
DeidentificationOperationType,
DeidentificationResult,
)
from azure.identity.aio import DefaultAzureCredential
import os


async def deidentify_text_redact_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@


import asyncio
import os
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationContent,
DeidentificationOperationType,
DeidentificationResult,
)
from azure.identity.aio import DefaultAzureCredential
import os


async def deidentify_text_surrogate_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import asyncio
import os
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationContent,
Expand All @@ -31,7 +32,6 @@
TextEncodingType,
)
from azure.identity.aio import DefaultAzureCredential
import os


async def deidentify_text_surrogate_only_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@


import asyncio
import os
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationContent,
DeidentificationOperationType,
DeidentificationResult,
)
from azure.identity.aio import DefaultAzureCredential
import os


async def deidentify_text_tag_async():
Expand All @@ -43,7 +43,7 @@ async def deidentify_text_tag_async():
print(f'\nOriginal Text: "{body.input_text}"')

if result.tagger_result and result.tagger_result.entities:
print(f"Tagged Entities:")
print("Tagged Entities:")
for entity in result.tagger_result.entities:
print(
f'\tEntity Text: "{entity.text}", Entity Category: "{entity.category}", Offset: "{entity.offset.code_point}", Length: "{entity.length.code_point}"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@


import asyncio
import os
import uuid
from azure.core.polling import AsyncLROPoller
from azure.health.deidentification.aio import DeidentificationClient
from azure.health.deidentification.models import (
Expand All @@ -30,8 +32,6 @@
TargetStorageLocation,
)
from azure.identity.aio import DefaultAzureCredential
import os
import uuid


async def list_job_documents_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@


import asyncio
import os
from azure.health.deidentification.aio import DeidentificationClient
from azure.identity.aio import DefaultAzureCredential
import os


async def list_jobs_async():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def deidentify_text_tag():
print(f'\nOriginal Text: "{body.input_text}"')

if result.tagger_result and result.tagger_result.entities:
print(f"Tagged Entities:")
print("Tagged Entities:")
for entity in result.tagger_result.entities:
print(
f'\tEntity Text: "{entity.text}", Entity Category: "{entity.category}", Offset: "{entity.offset.code_point}", Length: "{entity.length.code_point}"'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# [START create_client]
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
import os
from azure.core.exceptions import AzureError
from azure.health.deidentification import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationContent,
)
from azure.identity import DefaultAzureCredential
import os


# [START create_client]
endpoint = os.environ["HEALTHDATAAISERVICES_DEID_SERVICE_ENDPOINT"]
credential = DefaultAzureCredential()
client = DeidentificationClient(endpoint, credential)
# [END create_client]

# [START handle_error]
from azure.core.exceptions import AzureError
from azure.health.deidentification.models import (
DeidentificationContent,
)


error_client = DeidentificationClient("https://contoso.deid.azure.com", credential)
body = DeidentificationContent(input_text="Hello, I'm Dr. John Smith.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"""


import os
import uuid
from azure.health.deidentification import DeidentificationClient
from azure.health.deidentification.models import (
DeidentificationJob,
SourceStorageLocation,
TargetStorageLocation,
)
from azure.identity import DefaultAzureCredential
import os
import uuid


def list_job_documents():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"""


import os
from azure.health.deidentification import DeidentificationClient
from azure.identity import DefaultAzureCredential
import os


def list_jobs():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import functools
import inspect
import os
import random
import datetime
import uuid
from azure.health.deidentification import DeidentificationClient
from azure.health.deidentification.aio import (
DeidentificationClient as DeidentificationClientAsync,
)


from devtools_testutils import (
AzureRecordedTestCase,
EnvironmentVariableLoader,
)
from azure.health.deidentification import DeidentificationClient
from azure.health.deidentification.aio import (
DeidentificationClient as DeidentificationClientAsync,
)

RealtimeEnv = functools.partial(
EnvironmentVariableLoader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from datetime import time
from azure.core.exceptions import ResourceNotFoundError

import pytest
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils import (
recorded_by_proxy,
)

from azure.health.deidentification.models import *
from azure.core.exceptions import ResourceNotFoundError
from azure.health.deidentification.models import (
DeidentificationJob,
DeidentificationOperationType,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateCancelDelete(DeidBaseTestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from datetime import time
from azure.core.exceptions import ResourceNotFoundError

import pytest
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils.aio import (
recorded_by_proxy_async,
)

from azure.health.deidentification.models import *
from azure.core.exceptions import ResourceNotFoundError
from azure.health.deidentification.models import (
DeidentificationJob,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateCancelDelete(DeidBaseTestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from deid_base_test_case import *
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils import (
recorded_by_proxy,
)

from azure.health.deidentification.models import *
from azure.core.polling import LROPoller
from azure.health.deidentification.models import (
DeidentificationJob,
DeidentificationJobCustomizationOptions,
DeidentificationOperationType,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateAndListJob(DeidBaseTestCase):
Expand Down Expand Up @@ -39,12 +45,12 @@ def test_create_list(self, **kwargs):
if j.job_name == jobname:
job = j
break
elif jobsToLookThrough <= 0:
raise Exception("Job not found in list_jobs")
if jobsToLookThrough <= 0:
raise RuntimeError("Job not found in list_jobs")

assert job is not None
assert job.job_name == jobname
assert job.status == OperationStatus.NOT_STARTED or job.status == OperationStatus.RUNNING
assert job.status in (OperationStatus.NOT_STARTED, OperationStatus.RUNNING)
assert job.operation_type == DeidentificationOperationType.REDACT
assert job.error is None
assert job.created_at is not None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from deid_base_test_case import *
import pytest
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils.aio import (
recorded_by_proxy_async,
)

from azure.health.deidentification.models import *
import pytest
from azure.health.deidentification.models import (
DeidentificationJob,
DeidentificationJobCustomizationOptions,
DeidentificationOperationType,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateAndListJob(DeidBaseTestCase):
Expand Down Expand Up @@ -40,12 +47,12 @@ async def test_create_list_async(self, **kwargs):
if j.job_name == jobname:
job = j
break
elif jobsToLookThrough <= 0:
raise Exception("Job not found in list_jobs")
if jobsToLookThrough <= 0:
raise RuntimeError("Job not found in list_jobs")

assert job is not None
assert job.job_name == jobname
assert job.status == OperationStatus.NOT_STARTED or job.status == OperationStatus.RUNNING
assert job.status in (OperationStatus.NOT_STARTED, OperationStatus.RUNNING)
assert job.operation_type == DeidentificationOperationType.REDACT
assert job.error is None
assert job.created_at is not None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from deid_base_test_case import *
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils import (
recorded_by_proxy,
)

from azure.health.deidentification.models import *
from azure.core.polling import LROPoller
from azure.health.deidentification.models import (
DeidentificationJob,
DeidentificationOperationType,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateJobWaitUntil(DeidBaseTestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from deid_base_test_case import *
import pytest
from deid_base_test_case import DeidBaseTestCase, BatchEnv
from devtools_testutils.aio import (
recorded_by_proxy_async,
)

from azure.health.deidentification.models import *
from azure.core.polling import AsyncLROPoller
import pytest
from azure.health.deidentification.models import (
DeidentificationJob,
DeidentificationOperationType,
OperationStatus,
SourceStorageLocation,
TargetStorageLocation,
)


class TestHealthDeidentificationCreateJobWaitUntil(DeidBaseTestCase):
Expand Down
Loading
Loading