kaggle 1.8.3__py3-none-any.whl → 1.8.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kaggle/__init__.py +1 -1
- kaggle/api/kaggle_api_extended.py +183 -74
- kaggle/cli.py +36 -28
- kaggle/models/upload_file.py +4 -4
- {kaggle-1.8.3.dist-info → kaggle-1.8.4.dist-info}/METADATA +65 -74
- kaggle-1.8.4.dist-info/RECORD +15 -0
- kaggle/models/api_blob_type.py +0 -4
- kaggle/models/dataset_column.py +0 -228
- kaggle/models/dataset_new_request.py +0 -443
- kaggle/models/dataset_new_version_request.py +0 -319
- kaggle/models/dataset_update_settings_request.py +0 -344
- kaggle/models/kernel_push_request.py +0 -608
- kaggle/models/model_instance_new_version_request.py +0 -145
- kaggle/models/model_instance_update_request.py +0 -451
- kaggle/models/model_new_instance_request.py +0 -552
- kaggle/models/model_new_request.py +0 -329
- kaggle/models/model_update_request.py +0 -300
- kaggle/models/start_blob_upload_request.py +0 -240
- kaggle/models/start_blob_upload_response.py +0 -142
- kaggle-1.8.3.dist-info/RECORD +0 -28
- {kaggle-1.8.3.dist-info → kaggle-1.8.4.dist-info}/WHEEL +0 -0
- {kaggle-1.8.3.dist-info → kaggle-1.8.4.dist-info}/entry_points.txt +0 -0
- {kaggle-1.8.3.dist-info → kaggle-1.8.4.dist-info}/licenses/LICENSE.txt +0 -0
kaggle/models/upload_file.py
CHANGED
|
@@ -21,7 +21,7 @@ import re # noqa: F401
|
|
|
21
21
|
|
|
22
22
|
import six
|
|
23
23
|
|
|
24
|
-
from
|
|
24
|
+
from kagglesdk.datasets.types.dataset_api_service import ApiDatasetColumn
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class UploadFile(object):
|
|
@@ -33,7 +33,7 @@ class UploadFile(object):
|
|
|
33
33
|
and the value is json key in definition.
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
|
-
column_types = {"token": "str", "description": "str", "columns": "list[
|
|
36
|
+
column_types = {"token": "str", "description": "str", "columns": "list[ApiDatasetColumn]"}
|
|
37
37
|
|
|
38
38
|
attribute_map = {"token": "token", "description": "description", "columns": "columns"}
|
|
39
39
|
|
|
@@ -107,7 +107,7 @@ class UploadFile(object):
|
|
|
107
107
|
A list of dataset column metadata # noqa: E501
|
|
108
108
|
|
|
109
109
|
:return: The columns of this UploadFile. # noqa: E501
|
|
110
|
-
:rtype: list[
|
|
110
|
+
:rtype: list[ApiDatasetColumn]
|
|
111
111
|
"""
|
|
112
112
|
return self._columns
|
|
113
113
|
|
|
@@ -118,7 +118,7 @@ class UploadFile(object):
|
|
|
118
118
|
A list of dataset column metadata # noqa: E501
|
|
119
119
|
|
|
120
120
|
:param columns: The columns of this UploadFile. # noqa: E501
|
|
121
|
-
:type: list[
|
|
121
|
+
:type: list[ApiDatasetColumn]
|
|
122
122
|
"""
|
|
123
123
|
|
|
124
124
|
self._columns = columns
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kaggle
|
|
3
|
-
Version: 1.8.
|
|
3
|
+
Version: 1.8.4
|
|
4
4
|
Summary: Access Kaggle resources anywhere
|
|
5
|
-
Project-URL: Homepage, https://github.com/Kaggle/kaggle-
|
|
6
|
-
Project-URL: Issues, https://github.com/Kaggle/kaggle-
|
|
5
|
+
Project-URL: Homepage, https://github.com/Kaggle/kaggle-cli
|
|
6
|
+
Project-URL: Issues, https://github.com/Kaggle/kaggle-cli/issues
|
|
7
7
|
Author-email: Kaggle <support@kaggle.com>
|
|
8
8
|
License: Apache License
|
|
9
9
|
Version 2.0, January 2004
|
|
@@ -212,46 +212,57 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
212
212
|
Classifier: Operating System :: OS Independent
|
|
213
213
|
Classifier: Programming Language :: Python :: 3
|
|
214
214
|
Requires-Python: >=3.11
|
|
215
|
-
Requires-Dist: black>=24.10.0
|
|
216
215
|
Requires-Dist: bleach
|
|
217
|
-
Requires-Dist: kagglesdk<1.0,>=0.1.
|
|
218
|
-
Requires-Dist: mypy>=1.15.0
|
|
216
|
+
Requires-Dist: kagglesdk<1.0,>=0.1.15
|
|
219
217
|
Requires-Dist: packaging
|
|
220
218
|
Requires-Dist: protobuf
|
|
221
219
|
Requires-Dist: python-dateutil
|
|
222
220
|
Requires-Dist: python-slugify
|
|
223
221
|
Requires-Dist: requests
|
|
224
|
-
Requires-Dist: six>=1.10
|
|
225
222
|
Requires-Dist: tqdm
|
|
226
|
-
Requires-Dist: types-requests
|
|
227
|
-
Requires-Dist: types-tqdm
|
|
228
223
|
Requires-Dist: urllib3>=1.15.1
|
|
229
224
|
Description-Content-Type: text/markdown
|
|
230
225
|
|
|
231
|
-
# Kaggle
|
|
226
|
+
# Kaggle CLI
|
|
232
227
|
|
|
233
|
-
|
|
228
|
+
The official CLI to interact with [Kaggle](https://www.kaggle.com).
|
|
229
|
+
|
|
230
|
+
---
|
|
234
231
|
|
|
235
232
|
[User documentation](docs/README.md)
|
|
236
233
|
|
|
237
|
-
|
|
234
|
+
---
|
|
238
235
|
|
|
239
|
-
|
|
236
|
+
## Key Features
|
|
240
237
|
|
|
241
|
-
|
|
238
|
+
Some of the key features are:
|
|
239
|
+
|
|
240
|
+
* List competitions, download competition data, submit to a competition.
|
|
241
|
+
* List, create, update, download or delete datasets.
|
|
242
|
+
* List, create, update, download or delete models & model variations.
|
|
243
|
+
* List, update & run, download code & output or delete kernels (notebooks).
|
|
244
|
+
|
|
245
|
+
## Installation
|
|
246
|
+
|
|
247
|
+
Install the `kaggle` package with [pip](https://pypi.org/project/pip/):
|
|
242
248
|
|
|
243
249
|
```sh
|
|
244
250
|
pip install kaggle
|
|
245
251
|
```
|
|
246
252
|
|
|
247
|
-
|
|
253
|
+
Additional installation instructions can be found [here](docs/README.md#installation).
|
|
248
254
|
|
|
249
|
-
|
|
255
|
+
## Quick start
|
|
250
256
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
Explore the available commands by running:
|
|
258
|
+
|
|
259
|
+
```sh
|
|
260
|
+
kaggle --help
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
See the [User documentation](docs/README.md) for more examples & tutorials.
|
|
264
|
+
|
|
265
|
+
## Development
|
|
255
266
|
|
|
256
267
|
### Prerequisites
|
|
257
268
|
|
|
@@ -259,87 +270,67 @@ We use [hatch](https://hatch.pypa.io) to manage this project.
|
|
|
259
270
|
|
|
260
271
|
Follow these [instructions](https://hatch.pypa.io/latest/install/) to install it.
|
|
261
272
|
|
|
262
|
-
|
|
263
|
-
try `sudo apt install pipx`. Then you should be able to proceed with `pipx install hatch`.
|
|
273
|
+
### Run `kaggle` from source
|
|
264
274
|
|
|
265
|
-
|
|
275
|
+
#### Option 1: Execute a one-liner of code from the command line
|
|
266
276
|
|
|
267
277
|
```sh
|
|
268
|
-
hatch run
|
|
278
|
+
hatch run kaggle datasets list
|
|
269
279
|
```
|
|
270
280
|
|
|
271
|
-
|
|
281
|
+
#### Option 2: Run many commands in a shell
|
|
272
282
|
|
|
273
283
|
```sh
|
|
274
|
-
hatch
|
|
284
|
+
hatch shell
|
|
285
|
+
|
|
286
|
+
# Inside the shell, you can run many commands
|
|
287
|
+
kaggle datasets list
|
|
288
|
+
kaggle competitions list
|
|
289
|
+
...
|
|
275
290
|
```
|
|
276
291
|
|
|
277
|
-
|
|
292
|
+
### Lint / Format
|
|
278
293
|
|
|
279
|
-
|
|
294
|
+
```sh
|
|
295
|
+
# Lint check
|
|
296
|
+
hatch run lint:style
|
|
297
|
+
hatch run lint:typing
|
|
298
|
+
hatch run lint:all # for both
|
|
280
299
|
|
|
281
|
-
|
|
300
|
+
# Format
|
|
301
|
+
hatch run lint:fmt
|
|
302
|
+
```
|
|
282
303
|
|
|
283
|
-
|
|
284
|
-
To run that version locally for testing, use hatch: `hatch run kaggle -v`. If you'd rather not
|
|
285
|
-
type `hatch run` every time, launch a new shell in the hatch environment: `hatch shell`.
|
|
304
|
+
### Tests
|
|
286
305
|
|
|
287
|
-
|
|
306
|
+
Note: These tests are not true unit tests and are calling the Kaggle web server.
|
|
288
307
|
|
|
289
308
|
```sh
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
```python
|
|
294
|
-
import kaggle
|
|
295
|
-
from kaggle.api.kaggle_api_extended import KaggleApi
|
|
296
|
-
api = KaggleApi()
|
|
297
|
-
api.authenticate()
|
|
298
|
-
api.model_list_cli()
|
|
299
|
-
|
|
300
|
-
Next Page Token = [...]
|
|
301
|
-
[...]
|
|
309
|
+
# Run against kaggle.com
|
|
310
|
+
hatch run test:prod
|
|
302
311
|
|
|
312
|
+
# Run against a local web server (Kaggle engineers only)
|
|
313
|
+
hatch run test:local
|
|
303
314
|
```
|
|
304
315
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
```sh
|
|
308
|
-
hatch run python -c "import kaggle; from kaggle.api.kaggle_api_extended import KaggleApi; api = KaggleApi(); api.authenticate(); api.model_list_cli()"
|
|
309
|
-
```
|
|
316
|
+
### Integration Tests
|
|
310
317
|
|
|
311
|
-
|
|
318
|
+
To run integration tests on your local machine, you need to set up your Kaggle credentials. You can do this by following the [authentication instructions](docs/README.md#authentication).
|
|
312
319
|
|
|
313
|
-
|
|
320
|
+
After setting up your credentials, you can run the integration tests as follows:
|
|
314
321
|
|
|
315
322
|
```sh
|
|
316
|
-
|
|
317
|
-
[...]
|
|
318
|
-
+ print('hello Kaggle CLI update')^M
|
|
319
|
-
models = self.model_list(sort_by, search, owner, page_size, page_token)
|
|
320
|
-
[...]
|
|
321
|
-
|
|
322
|
-
❯ hatch run compile
|
|
323
|
-
[...]
|
|
324
|
-
|
|
325
|
-
❯ hatch run python -c "import kaggle; from kaggle.api.kaggle_api_extended import KaggleApi; api = KaggleApi(); api.authenticate(); api.model_list_cli()"
|
|
326
|
-
hello Kaggle CLI update
|
|
327
|
-
Next Page Token = [...]
|
|
323
|
+
hatch run test:integration
|
|
328
324
|
```
|
|
329
325
|
|
|
330
|
-
|
|
326
|
+
## Changelog
|
|
331
327
|
|
|
332
|
-
|
|
333
|
-
- Using environment variables
|
|
334
|
-
- Using credentials file
|
|
328
|
+
See [CHANGELOG](CHANGELOG.md).
|
|
335
329
|
|
|
336
|
-
|
|
330
|
+
## Contributing
|
|
337
331
|
|
|
338
|
-
|
|
339
|
-
# Run all tests
|
|
340
|
-
hatch run integration-test
|
|
341
|
-
```
|
|
332
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
342
333
|
|
|
343
334
|
## License
|
|
344
335
|
|
|
345
|
-
The Kaggle
|
|
336
|
+
The Kaggle CLI is released under the [Apache 2.0 license](LICENSE.txt).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
kaggle/LICENSE,sha256=PN5H3cwV3xW9nvUXKcB_XOH60cWqne6qK3SAE8NI74s,11340
|
|
2
|
+
kaggle/__init__.py,sha256=fUks8_ewdXRldJ0jq82KRKgsyUae8DtxU6QFrGtaxeE,280
|
|
3
|
+
kaggle/cli.py,sha256=f6RX_XZJNwMkbj5ftDSHcHGrV_czqwWrfRqK63y-Lx0,69820
|
|
4
|
+
kaggle/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
kaggle/api/kaggle_api.py,sha256=k_Fm5TxiUM6O19dMy43XTdYyBNIWWGWDE9QRf6otwUE,25521
|
|
6
|
+
kaggle/api/kaggle_api_extended.py,sha256=H50hT_jbQcD0DirfX89jT3HvqGiX6Eko3LyAx_gulFI,228320
|
|
7
|
+
kaggle/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
kaggle/models/kaggle_models_extended.py,sha256=w-IEn0AQvIZRj3ialSoOMOJm8vu48whqte36IdggI7Q,7997
|
|
9
|
+
kaggle/models/upload_file.py,sha256=i_8CfypwOToCoxAvG96Gle3IgNkrVnc38Y4oMHKqNjg,5081
|
|
10
|
+
kaggle/test/test_authenticate.py,sha256=6HvLhQ4noCXs3hVJpQP-tlSYv1_I9kKfAT2Nu3PeC7Q,1185
|
|
11
|
+
kaggle-1.8.4.dist-info/METADATA,sha256=KD5dM79V1y57b-X76cdRuWi0pvmn45oMYOkR1y0fpTA,15925
|
|
12
|
+
kaggle-1.8.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
13
|
+
kaggle-1.8.4.dist-info/entry_points.txt,sha256=hl3dQAS4qpVkC5FWiqfnU6qKJU924OEN6PsHEiw-FGg,43
|
|
14
|
+
kaggle-1.8.4.dist-info/licenses/LICENSE.txt,sha256=IzhfWrxIlFAci3lzZCg5WWHZJBI1QSzsHxO0plI63vk,11541
|
|
15
|
+
kaggle-1.8.4.dist-info/RECORD,,
|
kaggle/models/api_blob_type.py
DELETED
kaggle/models/dataset_column.py
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
#
|
|
3
|
-
# Copyright 2024 Kaggle Inc
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# coding: utf-8
|
|
18
|
-
|
|
19
|
-
import pprint
|
|
20
|
-
import re # noqa: F401
|
|
21
|
-
|
|
22
|
-
import six
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class DatasetColumn(object):
|
|
26
|
-
"""
|
|
27
|
-
Attributes:
|
|
28
|
-
column_types (dict): The key is attribute name
|
|
29
|
-
and the value is attribute type.
|
|
30
|
-
attribute_map (dict): The key is attribute name
|
|
31
|
-
and the value is json key in definition.
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
column_types = {"order": "float", "name": "str", "type": "str", "original_type": "str", "description": "str"}
|
|
35
|
-
|
|
36
|
-
attribute_map = {
|
|
37
|
-
"order": "order",
|
|
38
|
-
"name": "name",
|
|
39
|
-
"type": "type",
|
|
40
|
-
"original_type": "originalType",
|
|
41
|
-
"description": "description",
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
def __init__(self, order=None, name=None, type=None, original_type=None, description=None): # noqa: E501
|
|
45
|
-
"""DatasetColumn - a model defined in Swagger""" # noqa: E501
|
|
46
|
-
|
|
47
|
-
self._order = None
|
|
48
|
-
self._name = None
|
|
49
|
-
self._type = None
|
|
50
|
-
self._original_type = None
|
|
51
|
-
self._description = None
|
|
52
|
-
self.discriminator = None
|
|
53
|
-
|
|
54
|
-
if order is not None:
|
|
55
|
-
self.order = order
|
|
56
|
-
if name is not None:
|
|
57
|
-
self.name = name
|
|
58
|
-
if type is not None:
|
|
59
|
-
self.type = type
|
|
60
|
-
if original_type is not None:
|
|
61
|
-
self.original_type = original_type
|
|
62
|
-
if description is not None:
|
|
63
|
-
self.description = description
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def order(self):
|
|
67
|
-
"""Gets the order of this DatasetColumn. # noqa: E501.
|
|
68
|
-
|
|
69
|
-
The order that the column comes in, 0-based. (The first column is 0,
|
|
70
|
-
second is 1, etc.) # noqa: E501
|
|
71
|
-
|
|
72
|
-
:return: The order of this DatasetColumn. # noqa: E501
|
|
73
|
-
:rtype: float
|
|
74
|
-
"""
|
|
75
|
-
return self._order
|
|
76
|
-
|
|
77
|
-
@order.setter
|
|
78
|
-
def order(self, order):
|
|
79
|
-
"""Sets the order of this DatasetColumn.
|
|
80
|
-
|
|
81
|
-
The order that the column comes in, 0-based. (The first column is 0,
|
|
82
|
-
second is 1, etc.) # noqa: E501
|
|
83
|
-
|
|
84
|
-
:param order: The order of this DatasetColumn. # noqa: E501
|
|
85
|
-
:type: float
|
|
86
|
-
"""
|
|
87
|
-
|
|
88
|
-
self._order = order
|
|
89
|
-
|
|
90
|
-
@property
|
|
91
|
-
def name(self):
|
|
92
|
-
"""Gets the name of this DatasetColumn. # noqa: E501.
|
|
93
|
-
|
|
94
|
-
The column name # noqa: E501
|
|
95
|
-
|
|
96
|
-
:return: The name of this DatasetColumn. # noqa: E501
|
|
97
|
-
:rtype: str
|
|
98
|
-
"""
|
|
99
|
-
return self._name
|
|
100
|
-
|
|
101
|
-
@name.setter
|
|
102
|
-
def name(self, name):
|
|
103
|
-
"""Sets the name of this DatasetColumn.
|
|
104
|
-
|
|
105
|
-
The column name # noqa: E501
|
|
106
|
-
|
|
107
|
-
:param name: The name of this DatasetColumn. # noqa: E501
|
|
108
|
-
:type: str
|
|
109
|
-
"""
|
|
110
|
-
|
|
111
|
-
self._name = name
|
|
112
|
-
|
|
113
|
-
@property
|
|
114
|
-
def type(self):
|
|
115
|
-
"""Gets the type of this DatasetColumn. # noqa: E501.
|
|
116
|
-
|
|
117
|
-
The type of all of the fields in the column. Please see the data
|
|
118
|
-
types on
|
|
119
|
-
https://github.com/Kaggle/kaggle-api/wiki/Dataset-Metadata
|
|
120
|
-
# noqa: E501
|
|
121
|
-
|
|
122
|
-
:return: The type of this DatasetColumn. # noqa: E501
|
|
123
|
-
:rtype: str
|
|
124
|
-
"""
|
|
125
|
-
return self._type
|
|
126
|
-
|
|
127
|
-
@type.setter
|
|
128
|
-
def type(self, type):
|
|
129
|
-
"""Sets the type of this DatasetColumn.
|
|
130
|
-
|
|
131
|
-
The type of all of the fields in the column. Please see the data
|
|
132
|
-
types on
|
|
133
|
-
https://github.com/Kaggle/kaggle-api/wiki/Dataset-Metadata
|
|
134
|
-
# noqa: E501
|
|
135
|
-
|
|
136
|
-
:param type: The type of this DatasetColumn. # noqa: E501
|
|
137
|
-
:type: str
|
|
138
|
-
"""
|
|
139
|
-
|
|
140
|
-
self._type = type
|
|
141
|
-
|
|
142
|
-
@property
|
|
143
|
-
def original_type(self):
|
|
144
|
-
"""Gets the original_type of this DatasetColumn. # noqa: E501.
|
|
145
|
-
|
|
146
|
-
Used to store the original type of the column, which will be converted to Kaggle's types. For example, an `originalType` of `\"integer\"` would convert to a `type` of `\"numeric\"` # noqa: E501
|
|
147
|
-
|
|
148
|
-
:return: The original_type of this DatasetColumn. # noqa: E501
|
|
149
|
-
:rtype: str
|
|
150
|
-
"""
|
|
151
|
-
return self._original_type
|
|
152
|
-
|
|
153
|
-
@original_type.setter
|
|
154
|
-
def original_type(self, original_type):
|
|
155
|
-
"""Sets the original_type of this DatasetColumn.
|
|
156
|
-
|
|
157
|
-
Used to store the original type of the column, which will be converted to Kaggle's types. For example, an `originalType` of `\"integer\"` would convert to a `type` of `\"numeric\"` # noqa: E501
|
|
158
|
-
|
|
159
|
-
:param original_type: The original_type of this DatasetColumn. # noqa: E501
|
|
160
|
-
:type: str
|
|
161
|
-
"""
|
|
162
|
-
|
|
163
|
-
self._original_type = original_type
|
|
164
|
-
|
|
165
|
-
@property
|
|
166
|
-
def description(self):
|
|
167
|
-
"""Gets the description of this DatasetColumn. # noqa: E501.
|
|
168
|
-
|
|
169
|
-
The description of the column # noqa: E501
|
|
170
|
-
|
|
171
|
-
:return: The description of this DatasetColumn. # noqa: E501
|
|
172
|
-
:rtype: str
|
|
173
|
-
"""
|
|
174
|
-
return self._description
|
|
175
|
-
|
|
176
|
-
@description.setter
|
|
177
|
-
def description(self, description):
|
|
178
|
-
"""Sets the description of this DatasetColumn.
|
|
179
|
-
|
|
180
|
-
The description of the column # noqa: E501
|
|
181
|
-
|
|
182
|
-
:param description: The description of this DatasetColumn. # noqa:
|
|
183
|
-
E501
|
|
184
|
-
:type: str
|
|
185
|
-
"""
|
|
186
|
-
|
|
187
|
-
self._description = description
|
|
188
|
-
|
|
189
|
-
def to_dict(self):
|
|
190
|
-
"""Returns the model properties as a dict."""
|
|
191
|
-
result = {}
|
|
192
|
-
|
|
193
|
-
for attr, _ in six.iteritems(self.column_types):
|
|
194
|
-
value = getattr(self, attr)
|
|
195
|
-
if isinstance(value, list):
|
|
196
|
-
result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value))
|
|
197
|
-
elif hasattr(value, "to_dict"):
|
|
198
|
-
result[attr] = value.to_dict()
|
|
199
|
-
elif isinstance(value, dict):
|
|
200
|
-
result[attr] = dict(
|
|
201
|
-
map(
|
|
202
|
-
lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item,
|
|
203
|
-
value.items(),
|
|
204
|
-
)
|
|
205
|
-
)
|
|
206
|
-
else:
|
|
207
|
-
result[attr] = value
|
|
208
|
-
|
|
209
|
-
return result
|
|
210
|
-
|
|
211
|
-
def to_str(self):
|
|
212
|
-
"""Returns the string representation of the model."""
|
|
213
|
-
return pprint.pformat(self.to_dict())
|
|
214
|
-
|
|
215
|
-
def __repr__(self):
|
|
216
|
-
"""For `print` and `pprint`"""
|
|
217
|
-
return self.to_str()
|
|
218
|
-
|
|
219
|
-
def __eq__(self, other):
|
|
220
|
-
"""Returns true if both objects are equal."""
|
|
221
|
-
if not isinstance(other, DatasetColumn):
|
|
222
|
-
return False
|
|
223
|
-
|
|
224
|
-
return self.__dict__ == other.__dict__
|
|
225
|
-
|
|
226
|
-
def __ne__(self, other):
|
|
227
|
-
"""Returns true if both objects are not equal."""
|
|
228
|
-
return not self == other
|