You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/12/15 17:51:12 UTC
[atlas] branch branch-2.0 updated (38755da -> 1b8958f)
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git.
from 38755da ATLAS-4077: updated Python client to support Python 2.7
new 5213998 ATLAS-4077: updated Python client to fix errors found while running sample - #2
new 1b8958f ATLAS-4080: updated Python client with addition of API to retrieve metrics
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/python/request_json/typedef_create.json | 27 ++++++++++++++++------
.../sample-app/src/main/python/sample_client.py | 4 ++--
intg/src/main/python/README.md | 2 +-
.../{model/metrics.py => client/admin.py} | 14 +++++++----
.../main/python/apache_atlas/client/base_client.py | 4 ++--
.../apache_atlas/model/{metrics.py => admin.py} | 14 +++++++----
intg/src/main/python/apache_atlas/model/typedef.py | 20 ++++++++++++++--
intg/src/main/python/setup.py | 2 +-
8 files changed, 64 insertions(+), 23 deletions(-)
copy intg/src/main/python/apache_atlas/{model/metrics.py => client/admin.py} (70%)
rename intg/src/main/python/apache_atlas/model/{metrics.py => admin.py} (69%)
[atlas] 01/02: ATLAS-4077: updated Python client to fix errors
found while running sample - #2
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 5213998ccfd3e0d8859d413fd294c2875c02d669
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Mon Dec 14 21:47:01 2020 -0800
ATLAS-4077: updated Python client to fix errors found while running sample - #2
(cherry picked from commit 4fb6c7b4b1df3bdcd5c40cf65241bf2e42a07d22)
---
.../main/python/request_json/typedef_create.json | 27 ++++++++++++++++------
.../sample-app/src/main/python/sample_client.py | 4 ++--
intg/src/main/python/apache_atlas/model/typedef.py | 20 ++++++++++++++--
3 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/atlas-examples/sample-app/src/main/python/request_json/typedef_create.json b/atlas-examples/sample-app/src/main/python/request_json/typedef_create.json
index 5ebfc83..70018ad 100644
--- a/atlas-examples/sample-app/src/main/python/request_json/typedef_create.json
+++ b/atlas-examples/sample-app/src/main/python/request_json/typedef_create.json
@@ -3,6 +3,7 @@
{
"name": "sample_tableType",
"description": "sample_tableType",
+ "category": "ENUM",
"typeVersion": "1.0",
"elementDefs": [
{ "value": "MANAGED", "ordinal": 1 },
@@ -13,6 +14,7 @@
"structDefs": [
{
"name": "sample_serdeType",
+ "category": "STRUCT",
"typeVersion": "1.0",
"attributeDefs": [
{ "name": "name", "typeName": "string", "cardinality": "SINGLE", "isOptional": false, "isUnique": false, "isIndexable": true },
@@ -22,15 +24,18 @@
],
"classificationDefs": [
{
- "name": "sample_pii",
+ "name": "sample_pii",
+ "category": "CLASSIFICATION",
"typeVersion": "1.0"
},
{
- "name": "sample_finance",
+ "name": "sample_finance",
+ "category": "CLASSIFICATION",
"typeVersion": "1.0"
},
{
- "name": "sample_metric",
+ "name": "sample_metric",
+ "category": "CLASSIFICATION",
"typeVersion": "1.0"
}
],
@@ -38,6 +43,7 @@
{
"name": "sample_db",
"superTypes": [ "DataSet" ],
+ "category": "ENTITY",
"typeVersion": "1.0",
"attributeDefs": [
{ "name": "locationUri", "typeName": "string", "cardinality": "SINGLE", "isOptional": false, "isUnique": false, "isIndexable": true },
@@ -46,8 +52,9 @@
},
{
"name": "sample_table",
- "typeVersion": "1.0",
"superTypes": [ "DataSet" ],
+ "category": "ENTITY",
+ "typeVersion": "1.0",
"attributeDefs": [
{ "name": "createTime", "typeName": "date", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true },
{ "name": "tableType", "typeName": "sample_tableType", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true },
@@ -58,8 +65,9 @@
},
{
"name": "sample_column",
- "typeVersion": "1.0",
"superTypes": [ "DataSet" ],
+ "category": "ENTITY",
+ "typeVersion": "1.0",
"attributeDefs": [
{ "name": "dataType", "typeName": "string", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true },
{ "name": "comment", "typeName": "string", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true }
@@ -67,8 +75,9 @@
},
{
"name": "sample_process",
- "typeVersion": "1.0",
"superTypes": [ "Process" ],
+ "category": "ENTITY",
+ "typeVersion": "1.0",
"attributeDefs": [
{ "name": "userName", "typeName": "string", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true },
{ "name": "startTime", "typeName": "long", "cardinality": "SINGLE", "isOptional": true, "isUnique": false, "isIndexable": true },
@@ -82,6 +91,7 @@
{
"name": "sample_db_tables",
"description": "Tables of a db",
+ "category": "RELATIONSHIP",
"typeVersion": "1.0",
"relationshipCategory": "AGGREGATION",
"propagateTags": "NONE",
@@ -91,6 +101,7 @@
{
"name": "sample_table_columns",
"description": "Columns of a table",
+ "category": "RELATIONSHIP",
"typeVersion": "1.0",
"relationshipCategory": "COMPOSITION",
"propagateTags": "NONE",
@@ -102,10 +113,11 @@
{
"name": "sample_bm",
"description": "Sample business metadata",
+ "category": "BUSINESS_METADATA",
"typeVersion": "1.0",
"attributeDefs": [
{
- "name": "attr1",
+ "name": "attr1",
"typeName": "boolean",
"description": "Boolean attribute",
"cardinality": "SINGLE",
@@ -147,6 +159,7 @@
{
"name": "sample_bm_mv",
"description": "Sample business metadata with multi-value attributes",
+ "category": "BUSINESS_METADATA",
"typeVersion": "1.0",
"attributeDefs": [
{
diff --git a/atlas-examples/sample-app/src/main/python/sample_client.py b/atlas-examples/sample-app/src/main/python/sample_client.py
index 732b280..33c430f 100644
--- a/atlas-examples/sample-app/src/main/python/sample_client.py
+++ b/atlas-examples/sample-app/src/main/python/sample_client.py
@@ -48,10 +48,10 @@ class SampleApp:
client = AtlasClient(url, (username, password))
- self.__entity_example(client)
-
self.__typedef_example(client)
+ self.__entity_example(client)
+
self.__lineage_example(client)
self.__discovery_example(client)
diff --git a/intg/src/main/python/apache_atlas/model/typedef.py b/intg/src/main/python/apache_atlas/model/typedef.py
index 30e2750..f6fdf1a 100644
--- a/intg/src/main/python/apache_atlas/model/typedef.py
+++ b/intg/src/main/python/apache_atlas/model/typedef.py
@@ -102,7 +102,18 @@ class AtlasRelationshipDef(AtlasStructDef):
def __init__(self, attrs={}):
AtlasStructDef.__init__(self, attrs)
- self.category = TypeCategory.RELATIONSHIP.name
+ self.category = TypeCategory.RELATIONSHIP.name
+ self.relationshipCategory = attrs.get('relationshipCategory');
+ self.relationshipLabel = attrs.get('relationshipLabel');
+ self.propagateTags = attrs.get('propagateTags');
+ self.endDef1 = attrs.get('endDef1');
+ self.endDef2 = attrs.get('endDef2');
+
+ def type_coerce_attrs(self):
+ super(AtlasRelationshipDef, self).type_coerce_attrs()
+
+ self.endDef1 = type_coerce(self.endDef1, AtlasRelationshipEndDef)
+ self.endDef2 = type_coerce(self.endDef2, AtlasRelationshipEndDef)
class AtlasBusinessMetadataDef(AtlasStructDef):
@@ -168,7 +179,12 @@ class AtlasRelationshipEndDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.cardinality = non_null(self.cardinality, Cardinality.SINGLE.name)
+ self.type = attrs.get('type')
+ self.name = attrs.get('name')
+ self.isContainer = attrs.get('isContainer')
+ self.cardinality = attrs.get('cardinality')
+ self.isLegacyAttribute = attrs.get('isLegacyAttribute')
+ self.description = attrs.get('description')
class AtlasTypesDef(AtlasBase):
[atlas] 02/02: ATLAS-4080: updated Python client with addition of
API to retrieve metrics
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 1b8958fa29ec1cd6ace28ea03b6263ae8ba7fd54
Author: Verdan Mahmood <ve...@gmail.com>
AuthorDate: Tue Dec 15 09:35:38 2020 -0800
ATLAS-4080: updated Python client with addition of API to retrieve metrics
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
(cherry picked from commit af55c7f8799a95a1f26a38d51309bd9c5246bc77)
---
intg/src/main/python/README.md | 2 +-
.../apache_atlas/{model/metrics.py => client/admin.py} | 14 ++++++++++----
intg/src/main/python/apache_atlas/client/base_client.py | 4 ++--
.../python/apache_atlas/model/{metrics.py => admin.py} | 14 ++++++++++----
intg/src/main/python/setup.py | 2 +-
5 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/intg/src/main/python/README.md b/intg/src/main/python/README.md
index 9d80a68..a973717 100644
--- a/intg/src/main/python/README.md
+++ b/intg/src/main/python/README.md
@@ -16,7 +16,7 @@ Verify if apache-atlas client is installed:
Package Version
------------ ---------
-apache-atlas 0.0.2
+apache-atlas 0.0.3
```
## Usage
diff --git a/intg/src/main/python/apache_atlas/model/metrics.py b/intg/src/main/python/apache_atlas/client/admin.py
similarity index 70%
copy from intg/src/main/python/apache_atlas/model/metrics.py
copy to intg/src/main/python/apache_atlas/client/admin.py
index 636a3ea..171bcf8 100644
--- a/intg/src/main/python/apache_atlas/model/metrics.py
+++ b/intg/src/main/python/apache_atlas/client/admin.py
@@ -17,11 +17,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from apache_atlas.model.admin import *
from apache_atlas.utils import *
-class AtlasMetrics(AtlasBase):
- def __init__(self, attrs={}):
- AtlasBase.__init__(self, attrs)
+class AdminClient:
+ BASE_ADMIN_URL = BASE_URI + "admin/"
- self.data = attrs.get('data')
+ GET_METRICS_API = API(BASE_ADMIN_URL + "metrics", HttpMethod.GET, HTTPStatus.OK)
+
+ def __init__(self, client):
+ self.client = client
+
+ def get_metrics(self):
+ return self.client.call_api(AdminClient.GET_METRICS_API, AtlasAdminMetrics)
diff --git a/intg/src/main/python/apache_atlas/client/base_client.py b/intg/src/main/python/apache_atlas/client/base_client.py
index 3e6002d..fe0ddf4 100644
--- a/intg/src/main/python/apache_atlas/client/base_client.py
+++ b/intg/src/main/python/apache_atlas/client/base_client.py
@@ -28,11 +28,11 @@ from apache_atlas.client.entity import EntityClient
from apache_atlas.client.glossary import GlossaryClient
from apache_atlas.client.lineage import LineageClient
from apache_atlas.client.relationship import RelationshipClient
+from apache_atlas.client.admin import AdminClient
from apache_atlas.client.typedef import TypeDefClient
from apache_atlas.exceptions import AtlasServiceException
from apache_atlas.utils import HttpMethod, HTTPStatus, type_coerce
-
LOG = logging.getLogger('apache_atlas')
@@ -50,10 +50,10 @@ class AtlasClient:
self.discovery = DiscoveryClient(self)
self.glossary = GlossaryClient(self)
self.relationship = RelationshipClient(self)
+ self.admin = AdminClient(self)
logging.getLogger("requests").setLevel(logging.WARNING)
-
def call_api(self, api, response_type=None, query_params=None, request_obj=None):
params = copy.deepcopy(self.request_params)
path = os.path.join(self.host, api.path)
diff --git a/intg/src/main/python/apache_atlas/model/metrics.py b/intg/src/main/python/apache_atlas/model/admin.py
similarity index 69%
rename from intg/src/main/python/apache_atlas/model/metrics.py
rename to intg/src/main/python/apache_atlas/model/admin.py
index 636a3ea..3be8a94 100644
--- a/intg/src/main/python/apache_atlas/model/metrics.py
+++ b/intg/src/main/python/apache_atlas/model/admin.py
@@ -17,11 +17,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasBase
-class AtlasMetrics(AtlasBase):
- def __init__(self, attrs={}):
+class AtlasAdminMetrics(AtlasBase):
+ def __init__(self, attrs=None):
AtlasBase.__init__(self, attrs)
- self.data = attrs.get('data')
+ attrs = attrs or {}
+ _data = attrs.get('data', {})
+
+ self.general = _data.get('general', {})
+ self.tag = _data.get('tag', {})
+ self.entity = _data.get('entity', {})
+ self.system = _data.get('system', {})
diff --git a/intg/src/main/python/setup.py b/intg/src/main/python/setup.py
index ed33ebe..f11fa55 100644
--- a/intg/src/main/python/setup.py
+++ b/intg/src/main/python/setup.py
@@ -28,7 +28,7 @@ with open("README.md", "r") as fh:
setup(
name='apache-atlas',
- version='0.0.2',
+ version='0.0.3',
author="Apache Atlas",
author_email='dev@atlas.apache.org',
description="Apache Atlas Python Client",