maxframe 1.3.0__cp37-cp37m-win32.whl → 2.0.0__cp37-cp37m-win32.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.
Potentially problematic release.
This version of maxframe might be problematic. Click here for more details.
- maxframe/_utils.cp37-win32.pyd +0 -0
- maxframe/_utils.pyi +21 -0
- maxframe/_utils.pyx +4 -3
- maxframe/codegen/__init__.py +27 -0
- maxframe/{codegen.py → codegen/core.py} +49 -43
- maxframe/codegen/spe/__init__.py +16 -0
- maxframe/codegen/spe/core.py +307 -0
- maxframe/codegen/spe/dataframe/__init__.py +37 -0
- maxframe/codegen/spe/dataframe/accessors/__init__.py +15 -0
- maxframe/codegen/spe/dataframe/accessors/base.py +53 -0
- maxframe/codegen/spe/dataframe/accessors/dict_.py +194 -0
- maxframe/codegen/spe/dataframe/accessors/list_.py +80 -0
- maxframe/codegen/spe/dataframe/arithmetic.py +84 -0
- maxframe/codegen/spe/dataframe/datasource.py +181 -0
- maxframe/codegen/spe/dataframe/datastore.py +204 -0
- maxframe/codegen/spe/dataframe/extensions.py +63 -0
- maxframe/codegen/spe/dataframe/fetch.py +26 -0
- maxframe/codegen/spe/dataframe/groupby.py +224 -0
- maxframe/codegen/spe/dataframe/indexing.py +238 -0
- maxframe/codegen/spe/dataframe/merge.py +73 -0
- maxframe/codegen/spe/dataframe/misc.py +286 -0
- maxframe/codegen/spe/dataframe/missing.py +64 -0
- maxframe/codegen/spe/dataframe/reduction.py +160 -0
- maxframe/codegen/spe/dataframe/sort.py +83 -0
- maxframe/codegen/spe/dataframe/statistics.py +46 -0
- maxframe/codegen/spe/dataframe/tests/__init__.py +13 -0
- maxframe/codegen/spe/dataframe/tests/accessors/__init__.py +13 -0
- maxframe/codegen/spe/dataframe/tests/accessors/test_base.py +33 -0
- maxframe/codegen/spe/dataframe/tests/accessors/test_dict.py +310 -0
- maxframe/codegen/spe/dataframe/tests/accessors/test_list.py +137 -0
- maxframe/codegen/spe/dataframe/tests/indexing/__init__.py +13 -0
- maxframe/codegen/spe/dataframe/tests/indexing/conftest.py +58 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_getitem.py +124 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_iloc.py +76 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_indexing.py +39 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_rename.py +51 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_reset_index.py +88 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_sample.py +45 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_set_axis.py +45 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_set_index.py +41 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_setitem.py +46 -0
- maxframe/codegen/spe/dataframe/tests/misc/__init__.py +13 -0
- maxframe/codegen/spe/dataframe/tests/misc/test_apply.py +133 -0
- maxframe/codegen/spe/dataframe/tests/misc/test_drop_duplicates.py +92 -0
- maxframe/codegen/spe/dataframe/tests/misc/test_misc.py +234 -0
- maxframe/codegen/spe/dataframe/tests/missing/__init__.py +13 -0
- maxframe/codegen/spe/dataframe/tests/missing/test_checkna.py +94 -0
- maxframe/codegen/spe/dataframe/tests/missing/test_dropna.py +50 -0
- maxframe/codegen/spe/dataframe/tests/missing/test_fillna.py +94 -0
- maxframe/codegen/spe/dataframe/tests/missing/test_replace.py +45 -0
- maxframe/codegen/spe/dataframe/tests/test_arithmetic.py +73 -0
- maxframe/codegen/spe/dataframe/tests/test_datasource.py +184 -0
- maxframe/codegen/spe/dataframe/tests/test_datastore.py +200 -0
- maxframe/codegen/spe/dataframe/tests/test_extensions.py +88 -0
- maxframe/codegen/spe/dataframe/tests/test_groupby.py +225 -0
- maxframe/codegen/spe/dataframe/tests/test_merge.py +400 -0
- maxframe/codegen/spe/dataframe/tests/test_reduction.py +104 -0
- maxframe/codegen/spe/dataframe/tests/test_sort.py +159 -0
- maxframe/codegen/spe/dataframe/tests/test_statistics.py +70 -0
- maxframe/codegen/spe/dataframe/tests/test_tseries.py +29 -0
- maxframe/codegen/spe/dataframe/tests/test_value_counts.py +60 -0
- maxframe/codegen/spe/dataframe/tests/test_window.py +69 -0
- maxframe/codegen/spe/dataframe/tseries.py +46 -0
- maxframe/codegen/spe/dataframe/udf.py +62 -0
- maxframe/codegen/spe/dataframe/value_counts.py +31 -0
- maxframe/codegen/spe/dataframe/window.py +65 -0
- maxframe/codegen/spe/learn/__init__.py +15 -0
- maxframe/codegen/spe/learn/contrib/__init__.py +15 -0
- maxframe/codegen/spe/learn/contrib/lightgbm.py +160 -0
- maxframe/codegen/spe/learn/contrib/models.py +41 -0
- maxframe/codegen/spe/learn/contrib/pytorch.py +49 -0
- maxframe/codegen/spe/learn/contrib/tests/__init__.py +13 -0
- maxframe/codegen/spe/learn/contrib/tests/test_lightgbm.py +123 -0
- maxframe/codegen/spe/learn/contrib/tests/test_models.py +41 -0
- maxframe/codegen/spe/learn/contrib/tests/test_pytorch.py +53 -0
- maxframe/codegen/spe/learn/contrib/tests/test_xgboost.py +98 -0
- maxframe/codegen/spe/learn/contrib/xgboost.py +152 -0
- maxframe/codegen/spe/learn/metrics/__init__.py +15 -0
- maxframe/codegen/spe/learn/metrics/_classification.py +120 -0
- maxframe/codegen/spe/learn/metrics/tests/__init__.py +13 -0
- maxframe/codegen/spe/learn/metrics/tests/test_classification.py +93 -0
- maxframe/codegen/spe/learn/model_selection/__init__.py +13 -0
- maxframe/codegen/spe/learn/model_selection/tests/__init__.py +13 -0
- maxframe/codegen/spe/learn/model_selection/tests/test_split.py +41 -0
- maxframe/codegen/spe/learn/preprocessing/__init__.py +15 -0
- maxframe/codegen/spe/learn/preprocessing/_data.py +37 -0
- maxframe/codegen/spe/learn/preprocessing/_label.py +47 -0
- maxframe/codegen/spe/learn/preprocessing/tests/__init__.py +13 -0
- maxframe/codegen/spe/learn/preprocessing/tests/test_data.py +31 -0
- maxframe/codegen/spe/learn/preprocessing/tests/test_label.py +43 -0
- maxframe/codegen/spe/learn/utils/__init__.py +15 -0
- maxframe/codegen/spe/learn/utils/checks.py +55 -0
- maxframe/codegen/spe/learn/utils/multiclass.py +60 -0
- maxframe/codegen/spe/learn/utils/shuffle.py +85 -0
- maxframe/codegen/spe/learn/utils/sparsefuncs.py +35 -0
- maxframe/codegen/spe/learn/utils/tests/__init__.py +13 -0
- maxframe/codegen/spe/learn/utils/tests/test_checks.py +48 -0
- maxframe/codegen/spe/learn/utils/tests/test_multiclass.py +52 -0
- maxframe/codegen/spe/learn/utils/tests/test_shuffle.py +50 -0
- maxframe/codegen/spe/learn/utils/tests/test_sparsefuncs.py +34 -0
- maxframe/codegen/spe/learn/utils/tests/test_validation.py +44 -0
- maxframe/codegen/spe/learn/utils/validation.py +35 -0
- maxframe/codegen/spe/objects.py +26 -0
- maxframe/codegen/spe/remote.py +29 -0
- maxframe/codegen/spe/tensor/__init__.py +28 -0
- maxframe/codegen/spe/tensor/arithmetic.py +95 -0
- maxframe/codegen/spe/tensor/core.py +41 -0
- maxframe/codegen/spe/tensor/datasource.py +165 -0
- maxframe/codegen/spe/tensor/extensions.py +35 -0
- maxframe/codegen/spe/tensor/fetch.py +26 -0
- maxframe/codegen/spe/tensor/indexing.py +63 -0
- maxframe/codegen/spe/tensor/linalg.py +63 -0
- maxframe/codegen/spe/tensor/merge.py +31 -0
- maxframe/codegen/spe/tensor/misc.py +121 -0
- maxframe/codegen/spe/tensor/random.py +29 -0
- maxframe/codegen/spe/tensor/reduction.py +39 -0
- maxframe/codegen/spe/tensor/reshape.py +26 -0
- maxframe/codegen/spe/tensor/sort.py +42 -0
- maxframe/codegen/spe/tensor/special.py +35 -0
- maxframe/codegen/spe/tensor/statistics.py +24 -0
- maxframe/codegen/spe/tensor/tests/__init__.py +13 -0
- maxframe/codegen/spe/tensor/tests/test_arithmetic.py +103 -0
- maxframe/codegen/spe/tensor/tests/test_datasource.py +99 -0
- maxframe/codegen/spe/tensor/tests/test_extensions.py +37 -0
- maxframe/codegen/spe/tensor/tests/test_indexing.py +44 -0
- maxframe/codegen/spe/tensor/tests/test_linalg.py +38 -0
- maxframe/codegen/spe/tensor/tests/test_merge.py +28 -0
- maxframe/codegen/spe/tensor/tests/test_misc.py +94 -0
- maxframe/codegen/spe/tensor/tests/test_random.py +55 -0
- maxframe/codegen/spe/tensor/tests/test_reduction.py +65 -0
- maxframe/codegen/spe/tensor/tests/test_reshape.py +39 -0
- maxframe/codegen/spe/tensor/tests/test_sort.py +49 -0
- maxframe/codegen/spe/tensor/tests/test_special.py +28 -0
- maxframe/codegen/spe/tensor/tests/test_statistics.py +29 -0
- maxframe/codegen/spe/tests/__init__.py +13 -0
- maxframe/codegen/spe/tests/test_remote.py +29 -0
- maxframe/codegen/spe/tests/test_spe_codegen.py +141 -0
- maxframe/codegen/spe/utils.py +54 -0
- maxframe/codegen/tests/__init__.py +13 -0
- maxframe/{tests → codegen/tests}/test_codegen.py +3 -5
- maxframe/config/__init__.py +1 -1
- maxframe/config/config.py +50 -23
- maxframe/config/tests/test_config.py +4 -12
- maxframe/config/validators.py +5 -0
- maxframe/conftest.py +38 -10
- maxframe/core/__init__.py +1 -0
- maxframe/core/context.py +110 -0
- maxframe/core/entity/__init__.py +1 -0
- maxframe/core/entity/core.py +0 -7
- maxframe/core/entity/objects.py +19 -5
- maxframe/core/entity/output_types.py +11 -0
- maxframe/core/entity/tests/test_objects.py +11 -12
- maxframe/core/entity/tileables.py +3 -1
- maxframe/core/entity/utils.py +15 -0
- maxframe/core/graph/__init__.py +6 -1
- maxframe/core/graph/builder/base.py +5 -1
- maxframe/core/graph/core.cp37-win32.pyd +0 -0
- maxframe/core/graph/core.pyx +17 -6
- maxframe/core/graph/entity.py +18 -6
- maxframe/core/operator/__init__.py +8 -3
- maxframe/core/operator/base.py +35 -12
- maxframe/core/operator/core.py +37 -14
- maxframe/core/operator/fetch.py +5 -18
- maxframe/core/operator/objects.py +0 -20
- maxframe/core/operator/shuffle.py +6 -72
- maxframe/dataframe/__init__.py +1 -0
- maxframe/dataframe/accessors/datetime_/core.py +7 -4
- maxframe/dataframe/accessors/string_/core.py +9 -6
- maxframe/dataframe/arithmetic/core.py +31 -20
- maxframe/dataframe/arithmetic/tests/test_arithmetic.py +6 -0
- maxframe/dataframe/core.py +98 -91
- maxframe/dataframe/datasource/core.py +8 -1
- maxframe/dataframe/datasource/date_range.py +8 -0
- maxframe/dataframe/datasource/from_index.py +9 -5
- maxframe/dataframe/datasource/from_records.py +9 -2
- maxframe/dataframe/datasource/from_tensor.py +32 -21
- maxframe/dataframe/datasource/read_csv.py +8 -2
- maxframe/dataframe/datasource/read_odps_query.py +109 -19
- maxframe/dataframe/datasource/read_odps_table.py +20 -5
- maxframe/dataframe/datasource/read_parquet.py +8 -3
- maxframe/dataframe/datasource/tests/test_datasource.py +80 -1
- maxframe/dataframe/datastore/tests/test_to_odps.py +52 -1
- maxframe/dataframe/datastore/to_csv.py +7 -3
- maxframe/dataframe/datastore/to_odps.py +42 -6
- maxframe/dataframe/extensions/__init__.py +6 -1
- maxframe/dataframe/extensions/apply_chunk.py +96 -136
- maxframe/dataframe/extensions/flatjson.py +3 -2
- maxframe/dataframe/extensions/flatmap.py +15 -7
- maxframe/dataframe/fetch/core.py +12 -1
- maxframe/dataframe/groupby/__init__.py +7 -0
- maxframe/dataframe/groupby/aggregation.py +62 -9
- maxframe/dataframe/groupby/apply.py +50 -74
- maxframe/dataframe/groupby/apply_chunk.py +393 -0
- maxframe/dataframe/groupby/core.py +80 -17
- maxframe/dataframe/groupby/extensions.py +26 -0
- maxframe/dataframe/groupby/fill.py +9 -4
- maxframe/dataframe/groupby/sample.py +7 -7
- maxframe/dataframe/groupby/tests/test_groupby.py +3 -3
- maxframe/dataframe/groupby/transform.py +57 -54
- maxframe/dataframe/indexing/align.py +7 -6
- maxframe/dataframe/indexing/getitem.py +9 -8
- maxframe/dataframe/indexing/iloc.py +28 -23
- maxframe/dataframe/indexing/insert.py +7 -3
- maxframe/dataframe/indexing/loc.py +9 -8
- maxframe/dataframe/indexing/reindex.py +36 -30
- maxframe/dataframe/indexing/rename_axis.py +18 -10
- maxframe/dataframe/indexing/reset_index.py +0 -2
- maxframe/dataframe/indexing/sample.py +13 -9
- maxframe/dataframe/indexing/set_axis.py +9 -6
- maxframe/dataframe/indexing/setitem.py +8 -5
- maxframe/dataframe/indexing/where.py +12 -9
- maxframe/dataframe/merge/__init__.py +0 -1
- maxframe/dataframe/merge/concat.py +10 -31
- maxframe/dataframe/merge/merge.py +2 -24
- maxframe/dataframe/misc/__init__.py +6 -0
- maxframe/dataframe/misc/_duplicate.py +7 -3
- maxframe/dataframe/misc/apply.py +106 -139
- maxframe/dataframe/misc/astype.py +3 -2
- maxframe/dataframe/misc/case_when.py +11 -7
- maxframe/dataframe/misc/cut.py +11 -10
- maxframe/dataframe/misc/describe.py +7 -3
- maxframe/dataframe/misc/drop.py +13 -11
- maxframe/dataframe/misc/eval.py +0 -2
- maxframe/dataframe/misc/get_dummies.py +78 -49
- maxframe/dataframe/misc/isin.py +13 -10
- maxframe/dataframe/misc/map.py +21 -6
- maxframe/dataframe/misc/melt.py +8 -1
- maxframe/dataframe/misc/pivot.py +232 -0
- maxframe/dataframe/misc/pivot_table.py +52 -40
- maxframe/dataframe/misc/rechunk.py +59 -0
- maxframe/dataframe/misc/shift.py +7 -4
- maxframe/dataframe/misc/stack.py +5 -3
- maxframe/dataframe/misc/tests/test_misc.py +167 -1
- maxframe/dataframe/misc/transform.py +63 -65
- maxframe/dataframe/misc/value_counts.py +7 -4
- maxframe/dataframe/missing/dropna.py +16 -7
- maxframe/dataframe/missing/fillna.py +18 -10
- maxframe/dataframe/missing/replace.py +10 -6
- maxframe/dataframe/missing/tests/test_missing.py +2 -2
- maxframe/dataframe/operators.py +1 -27
- maxframe/dataframe/reduction/aggregation.py +128 -3
- maxframe/dataframe/reduction/core.py +20 -6
- maxframe/dataframe/reduction/median.py +1 -1
- maxframe/dataframe/reduction/tests/test_reduction.py +33 -0
- maxframe/dataframe/reduction/unique.py +53 -7
- maxframe/dataframe/statistics/corr.py +9 -6
- maxframe/dataframe/statistics/quantile.py +9 -6
- maxframe/dataframe/tseries/to_datetime.py +6 -4
- maxframe/dataframe/utils.py +219 -31
- maxframe/dataframe/window/rolling.py +7 -4
- maxframe/env.py +1 -0
- maxframe/errors.py +9 -0
- maxframe/extension.py +13 -2
- maxframe/io/objects/core.py +67 -51
- maxframe/io/objects/tensor.py +73 -17
- maxframe/io/objects/tests/test_object_io.py +10 -55
- maxframe/io/odpsio/arrow.py +15 -2
- maxframe/io/odpsio/schema.py +43 -13
- maxframe/io/odpsio/tableio.py +63 -11
- maxframe/io/odpsio/tests/test_arrow.py +1 -2
- maxframe/io/odpsio/tests/test_schema.py +114 -1
- maxframe/io/odpsio/tests/test_tableio.py +42 -0
- maxframe/io/odpsio/tests/test_volumeio.py +21 -58
- maxframe/io/odpsio/volumeio.py +23 -8
- maxframe/learn/__init__.py +2 -2
- maxframe/learn/contrib/__init__.py +2 -2
- maxframe/learn/contrib/graph/connected_components.py +2 -1
- maxframe/learn/contrib/lightgbm/__init__.py +33 -0
- maxframe/learn/contrib/lightgbm/_predict.py +138 -0
- maxframe/learn/contrib/lightgbm/_train.py +163 -0
- maxframe/learn/contrib/lightgbm/callback.py +114 -0
- maxframe/learn/contrib/lightgbm/classifier.py +199 -0
- maxframe/learn/contrib/lightgbm/core.py +372 -0
- maxframe/learn/contrib/lightgbm/dataset.py +153 -0
- maxframe/learn/contrib/lightgbm/regressor.py +29 -0
- maxframe/learn/contrib/lightgbm/tests/__init__.py +13 -0
- maxframe/learn/contrib/lightgbm/tests/test_callback.py +58 -0
- maxframe/learn/contrib/llm/models/dashscope.py +34 -0
- maxframe/learn/contrib/llm/models/managed.py +15 -0
- maxframe/learn/contrib/llm/multi_modal.py +92 -0
- maxframe/learn/contrib/llm/text.py +21 -5
- maxframe/learn/contrib/models.py +38 -9
- maxframe/learn/contrib/utils.py +55 -0
- maxframe/learn/contrib/xgboost/callback.py +86 -0
- maxframe/learn/contrib/xgboost/classifier.py +26 -30
- maxframe/learn/contrib/xgboost/core.py +54 -42
- maxframe/learn/contrib/xgboost/dmatrix.py +19 -12
- maxframe/learn/contrib/xgboost/predict.py +13 -8
- maxframe/learn/contrib/xgboost/regressor.py +28 -27
- maxframe/learn/contrib/xgboost/tests/test_callback.py +41 -0
- maxframe/learn/contrib/xgboost/train.py +59 -16
- maxframe/learn/core.py +252 -0
- maxframe/learn/datasets/__init__.py +20 -0
- maxframe/learn/datasets/samples_generator.py +628 -0
- maxframe/learn/linear_model/__init__.py +15 -0
- maxframe/learn/linear_model/_base.py +163 -0
- maxframe/learn/linear_model/_lin_reg.py +175 -0
- maxframe/learn/metrics/__init__.py +25 -0
- maxframe/learn/metrics/_check_targets.py +95 -0
- maxframe/learn/metrics/_classification.py +1121 -0
- maxframe/learn/metrics/_regression.py +256 -0
- maxframe/learn/model_selection/__init__.py +15 -0
- maxframe/learn/model_selection/_split.py +451 -0
- maxframe/learn/model_selection/tests/__init__.py +13 -0
- maxframe/learn/model_selection/tests/test_split.py +156 -0
- maxframe/learn/preprocessing/__init__.py +16 -0
- maxframe/learn/preprocessing/_data/__init__.py +17 -0
- maxframe/learn/preprocessing/_data/min_max_scaler.py +390 -0
- maxframe/learn/preprocessing/_data/normalize.py +127 -0
- maxframe/learn/preprocessing/_data/standard_scaler.py +503 -0
- maxframe/learn/preprocessing/_data/utils.py +79 -0
- maxframe/learn/preprocessing/_label/__init__.py +16 -0
- maxframe/learn/preprocessing/_label/_label_binarizer.py +599 -0
- maxframe/learn/preprocessing/_label/_label_encoder.py +174 -0
- maxframe/learn/utils/__init__.py +4 -0
- maxframe/learn/utils/_encode.py +314 -0
- maxframe/learn/utils/checks.py +161 -0
- maxframe/learn/utils/core.py +33 -0
- maxframe/learn/utils/extmath.py +176 -0
- maxframe/learn/utils/multiclass.py +292 -0
- maxframe/learn/utils/shuffle.py +114 -0
- maxframe/learn/utils/sparsefuncs.py +87 -0
- maxframe/learn/utils/validation.py +775 -0
- maxframe/lib/__init__.py +0 -2
- maxframe/lib/compat.py +145 -0
- maxframe/lib/filesystem/_oss_lib/glob.py +1 -1
- maxframe/lib/mmh3.cp37-win32.pyd +0 -0
- maxframe/lib/sparse/__init__.py +10 -15
- maxframe/lib/sparse/array.py +45 -33
- maxframe/lib/sparse/core.py +0 -2
- maxframe/lib/sparse/linalg.py +31 -0
- maxframe/lib/sparse/matrix.py +5 -2
- maxframe/lib/sparse/tests/__init__.py +0 -2
- maxframe/lib/sparse/tests/test_sparse.py +53 -53
- maxframe/lib/sparse/vector.py +0 -2
- maxframe/mixin.py +59 -2
- maxframe/opcodes.py +13 -5
- maxframe/protocol.py +67 -14
- maxframe/remote/core.py +16 -14
- maxframe/remote/run_script.py +6 -3
- maxframe/serialization/__init__.py +2 -0
- maxframe/serialization/core.cp37-win32.pyd +0 -0
- maxframe/serialization/core.pxd +3 -0
- maxframe/serialization/core.pyi +3 -1
- maxframe/serialization/core.pyx +82 -4
- maxframe/serialization/pandas.py +5 -1
- maxframe/serialization/serializables/core.py +6 -5
- maxframe/serialization/serializables/field.py +2 -2
- maxframe/serialization/serializables/tests/test_field_type.py +3 -5
- maxframe/serialization/tests/test_serial.py +27 -0
- maxframe/session.py +4 -71
- maxframe/sperunner.py +165 -0
- maxframe/tensor/__init__.py +35 -2
- maxframe/tensor/arithmetic/__init__.py +2 -4
- maxframe/tensor/arithmetic/abs.py +0 -2
- maxframe/tensor/arithmetic/absolute.py +0 -2
- maxframe/tensor/arithmetic/add.py +34 -4
- maxframe/tensor/arithmetic/angle.py +0 -2
- maxframe/tensor/arithmetic/arccos.py +1 -4
- maxframe/tensor/arithmetic/arccosh.py +1 -3
- maxframe/tensor/arithmetic/arcsin.py +0 -2
- maxframe/tensor/arithmetic/arcsinh.py +0 -2
- maxframe/tensor/arithmetic/arctan.py +0 -2
- maxframe/tensor/arithmetic/arctan2.py +0 -2
- maxframe/tensor/arithmetic/arctanh.py +0 -2
- maxframe/tensor/arithmetic/around.py +0 -2
- maxframe/tensor/arithmetic/bitand.py +0 -2
- maxframe/tensor/arithmetic/bitor.py +1 -3
- maxframe/tensor/arithmetic/bitxor.py +1 -3
- maxframe/tensor/arithmetic/cbrt.py +0 -2
- maxframe/tensor/arithmetic/ceil.py +0 -2
- maxframe/tensor/arithmetic/clip.py +13 -13
- maxframe/tensor/arithmetic/conj.py +0 -2
- maxframe/tensor/arithmetic/copysign.py +0 -2
- maxframe/tensor/arithmetic/core.py +47 -39
- maxframe/tensor/arithmetic/cos.py +1 -3
- maxframe/tensor/arithmetic/cosh.py +0 -2
- maxframe/tensor/arithmetic/deg2rad.py +0 -2
- maxframe/tensor/arithmetic/degrees.py +0 -2
- maxframe/tensor/arithmetic/divide.py +0 -2
- maxframe/tensor/arithmetic/equal.py +0 -2
- maxframe/tensor/arithmetic/exp.py +1 -3
- maxframe/tensor/arithmetic/exp2.py +0 -2
- maxframe/tensor/arithmetic/expm1.py +0 -2
- maxframe/tensor/arithmetic/fabs.py +0 -2
- maxframe/tensor/arithmetic/fix.py +0 -2
- maxframe/tensor/arithmetic/float_power.py +0 -2
- maxframe/tensor/arithmetic/floor.py +0 -2
- maxframe/tensor/arithmetic/floordiv.py +0 -2
- maxframe/tensor/arithmetic/fmax.py +0 -2
- maxframe/tensor/arithmetic/fmin.py +0 -2
- maxframe/tensor/arithmetic/fmod.py +0 -2
- maxframe/tensor/arithmetic/frexp.py +6 -2
- maxframe/tensor/arithmetic/greater.py +0 -2
- maxframe/tensor/arithmetic/greater_equal.py +0 -2
- maxframe/tensor/arithmetic/hypot.py +0 -2
- maxframe/tensor/arithmetic/i0.py +1 -3
- maxframe/tensor/arithmetic/imag.py +0 -2
- maxframe/tensor/arithmetic/invert.py +1 -3
- maxframe/tensor/arithmetic/isclose.py +0 -2
- maxframe/tensor/arithmetic/iscomplex.py +0 -2
- maxframe/tensor/arithmetic/isfinite.py +1 -3
- maxframe/tensor/arithmetic/isinf.py +0 -2
- maxframe/tensor/arithmetic/isnan.py +0 -2
- maxframe/tensor/arithmetic/isreal.py +0 -2
- maxframe/tensor/arithmetic/ldexp.py +0 -2
- maxframe/tensor/arithmetic/less.py +0 -2
- maxframe/tensor/arithmetic/less_equal.py +0 -2
- maxframe/tensor/arithmetic/log.py +1 -3
- maxframe/tensor/arithmetic/log10.py +1 -3
- maxframe/tensor/arithmetic/log1p.py +1 -3
- maxframe/tensor/arithmetic/log2.py +1 -3
- maxframe/tensor/arithmetic/logaddexp.py +0 -2
- maxframe/tensor/arithmetic/logaddexp2.py +0 -2
- maxframe/tensor/arithmetic/logical_and.py +0 -2
- maxframe/tensor/arithmetic/logical_not.py +1 -3
- maxframe/tensor/arithmetic/logical_or.py +0 -2
- maxframe/tensor/arithmetic/logical_xor.py +0 -2
- maxframe/tensor/arithmetic/lshift.py +0 -2
- maxframe/tensor/arithmetic/maximum.py +0 -2
- maxframe/tensor/arithmetic/minimum.py +0 -2
- maxframe/tensor/arithmetic/mod.py +0 -2
- maxframe/tensor/arithmetic/modf.py +6 -2
- maxframe/tensor/arithmetic/multiply.py +37 -4
- maxframe/tensor/arithmetic/nan_to_num.py +0 -2
- maxframe/tensor/arithmetic/negative.py +0 -2
- maxframe/tensor/arithmetic/nextafter.py +0 -2
- maxframe/tensor/arithmetic/not_equal.py +0 -2
- maxframe/tensor/arithmetic/positive.py +0 -2
- maxframe/tensor/arithmetic/power.py +0 -2
- maxframe/tensor/arithmetic/rad2deg.py +0 -2
- maxframe/tensor/arithmetic/radians.py +0 -2
- maxframe/tensor/arithmetic/real.py +0 -2
- maxframe/tensor/arithmetic/reciprocal.py +5 -3
- maxframe/tensor/arithmetic/rint.py +1 -3
- maxframe/tensor/arithmetic/rshift.py +0 -2
- maxframe/tensor/arithmetic/setimag.py +0 -2
- maxframe/tensor/arithmetic/setreal.py +0 -2
- maxframe/tensor/arithmetic/sign.py +0 -2
- maxframe/tensor/arithmetic/signbit.py +0 -2
- maxframe/tensor/arithmetic/sin.py +0 -2
- maxframe/tensor/arithmetic/sinc.py +1 -3
- maxframe/tensor/arithmetic/sinh.py +0 -2
- maxframe/tensor/arithmetic/spacing.py +0 -2
- maxframe/tensor/arithmetic/sqrt.py +0 -2
- maxframe/tensor/arithmetic/square.py +0 -2
- maxframe/tensor/arithmetic/subtract.py +4 -2
- maxframe/tensor/arithmetic/tan.py +0 -2
- maxframe/tensor/arithmetic/tanh.py +0 -2
- maxframe/tensor/arithmetic/tests/__init__.py +0 -2
- maxframe/tensor/arithmetic/tests/test_arithmetic.py +43 -9
- maxframe/tensor/arithmetic/truediv.py +0 -2
- maxframe/tensor/arithmetic/trunc.py +0 -2
- maxframe/tensor/arithmetic/utils.py +32 -6
- maxframe/tensor/array_utils.py +3 -25
- maxframe/tensor/core.py +6 -6
- maxframe/tensor/datasource/__init__.py +10 -2
- maxframe/tensor/datasource/arange.py +0 -2
- maxframe/tensor/datasource/array.py +3 -22
- maxframe/tensor/datasource/core.py +15 -10
- maxframe/tensor/datasource/diag.py +140 -0
- maxframe/tensor/datasource/diagflat.py +69 -0
- maxframe/tensor/datasource/empty.py +0 -2
- maxframe/tensor/datasource/eye.py +95 -0
- maxframe/tensor/datasource/from_dataframe.py +0 -2
- maxframe/tensor/datasource/from_dense.py +0 -17
- maxframe/tensor/datasource/from_sparse.py +0 -2
- maxframe/tensor/datasource/full.py +0 -2
- maxframe/tensor/datasource/identity.py +54 -0
- maxframe/tensor/datasource/indices.py +115 -0
- maxframe/tensor/datasource/linspace.py +140 -0
- maxframe/tensor/datasource/meshgrid.py +135 -0
- maxframe/tensor/datasource/ones.py +8 -3
- maxframe/tensor/datasource/tests/test_datasource.py +32 -1
- maxframe/tensor/datasource/tri_array.py +107 -0
- maxframe/tensor/datasource/zeros.py +7 -3
- maxframe/tensor/extensions/__init__.py +31 -0
- maxframe/tensor/extensions/accessor.py +25 -0
- maxframe/tensor/extensions/apply_chunk.py +137 -0
- maxframe/tensor/indexing/__init__.py +1 -1
- maxframe/tensor/indexing/choose.py +8 -6
- maxframe/tensor/indexing/compress.py +0 -2
- maxframe/tensor/indexing/extract.py +0 -2
- maxframe/tensor/indexing/fill_diagonal.py +9 -6
- maxframe/tensor/indexing/flatnonzero.py +1 -3
- maxframe/tensor/indexing/getitem.py +10 -43
- maxframe/tensor/indexing/nonzero.py +2 -4
- maxframe/tensor/indexing/setitem.py +19 -9
- maxframe/tensor/indexing/slice.py +6 -3
- maxframe/tensor/indexing/take.py +0 -2
- maxframe/tensor/indexing/tests/__init__.py +0 -2
- maxframe/tensor/indexing/tests/test_indexing.py +0 -2
- maxframe/tensor/indexing/unravel_index.py +6 -6
- maxframe/tensor/lib/__init__.py +16 -0
- maxframe/tensor/lib/index_tricks.py +404 -0
- maxframe/tensor/linalg/__init__.py +36 -0
- maxframe/tensor/linalg/dot.py +145 -0
- maxframe/tensor/linalg/inner.py +36 -0
- maxframe/tensor/linalg/inv.py +83 -0
- maxframe/tensor/linalg/lu.py +115 -0
- maxframe/tensor/linalg/matmul.py +225 -0
- maxframe/tensor/linalg/qr.py +124 -0
- maxframe/tensor/linalg/solve_triangular.py +103 -0
- maxframe/tensor/linalg/svd.py +167 -0
- maxframe/tensor/linalg/tensordot.py +213 -0
- maxframe/tensor/linalg/vdot.py +73 -0
- maxframe/tensor/merge/__init__.py +4 -0
- maxframe/tensor/merge/append.py +74 -0
- maxframe/tensor/merge/column_stack.py +63 -0
- maxframe/tensor/merge/concatenate.py +3 -2
- maxframe/tensor/merge/dstack.py +71 -0
- maxframe/tensor/merge/hstack.py +70 -0
- maxframe/tensor/merge/stack.py +0 -2
- maxframe/tensor/merge/tests/test_merge.py +0 -2
- maxframe/tensor/misc/__init__.py +18 -5
- maxframe/tensor/misc/astype.py +10 -8
- maxframe/tensor/misc/broadcast_to.py +1 -1
- maxframe/tensor/misc/copy.py +64 -0
- maxframe/tensor/misc/diff.py +115 -0
- maxframe/tensor/misc/flatten.py +63 -0
- maxframe/tensor/misc/in1d.py +94 -0
- maxframe/tensor/misc/isin.py +130 -0
- maxframe/tensor/misc/ndim.py +53 -0
- maxframe/tensor/misc/ravel.py +0 -2
- maxframe/tensor/misc/repeat.py +129 -0
- maxframe/tensor/misc/searchsorted.py +147 -0
- maxframe/tensor/misc/setdiff1d.py +58 -0
- maxframe/tensor/misc/squeeze.py +117 -0
- maxframe/tensor/misc/swapaxes.py +113 -0
- maxframe/tensor/misc/tests/test_misc.py +0 -2
- maxframe/tensor/misc/transpose.py +8 -4
- maxframe/tensor/misc/trapezoid.py +123 -0
- maxframe/tensor/misc/unique.py +0 -1
- maxframe/tensor/misc/where.py +10 -8
- maxframe/tensor/operators.py +0 -34
- maxframe/tensor/random/__init__.py +3 -5
- maxframe/tensor/random/binomial.py +0 -2
- maxframe/tensor/random/bytes.py +0 -2
- maxframe/tensor/random/chisquare.py +0 -2
- maxframe/tensor/random/choice.py +9 -8
- maxframe/tensor/random/core.py +20 -5
- maxframe/tensor/random/dirichlet.py +0 -2
- maxframe/tensor/random/exponential.py +0 -2
- maxframe/tensor/random/f.py +2 -4
- maxframe/tensor/random/gamma.py +0 -2
- maxframe/tensor/random/geometric.py +0 -2
- maxframe/tensor/random/gumbel.py +0 -2
- maxframe/tensor/random/hypergeometric.py +0 -2
- maxframe/tensor/random/laplace.py +2 -4
- maxframe/tensor/random/logistic.py +0 -2
- maxframe/tensor/random/lognormal.py +0 -2
- maxframe/tensor/random/logseries.py +0 -2
- maxframe/tensor/random/multinomial.py +0 -2
- maxframe/tensor/random/multivariate_normal.py +0 -2
- maxframe/tensor/random/negative_binomial.py +0 -2
- maxframe/tensor/random/noncentral_chisquare.py +0 -2
- maxframe/tensor/random/noncentral_f.py +1 -3
- maxframe/tensor/random/normal.py +0 -2
- maxframe/tensor/random/pareto.py +0 -2
- maxframe/tensor/random/permutation.py +6 -3
- maxframe/tensor/random/poisson.py +0 -2
- maxframe/tensor/random/power.py +0 -2
- maxframe/tensor/random/rand.py +0 -2
- maxframe/tensor/random/randint.py +0 -2
- maxframe/tensor/random/randn.py +0 -2
- maxframe/tensor/random/random_integers.py +0 -2
- maxframe/tensor/random/random_sample.py +0 -2
- maxframe/tensor/random/rayleigh.py +0 -2
- maxframe/tensor/random/standard_cauchy.py +0 -2
- maxframe/tensor/random/standard_exponential.py +0 -2
- maxframe/tensor/random/standard_gamma.py +0 -2
- maxframe/tensor/random/standard_normal.py +0 -2
- maxframe/tensor/random/standard_t.py +0 -2
- maxframe/tensor/random/tests/__init__.py +0 -2
- maxframe/tensor/random/tests/test_random.py +0 -2
- maxframe/tensor/random/triangular.py +0 -2
- maxframe/tensor/random/uniform.py +0 -2
- maxframe/tensor/random/vonmises.py +0 -2
- maxframe/tensor/random/wald.py +0 -2
- maxframe/tensor/random/weibull.py +0 -2
- maxframe/tensor/random/zipf.py +0 -2
- maxframe/tensor/reduction/__init__.py +0 -2
- maxframe/tensor/reduction/all.py +0 -2
- maxframe/tensor/reduction/allclose.py +0 -2
- maxframe/tensor/reduction/any.py +0 -2
- maxframe/tensor/reduction/argmax.py +1 -3
- maxframe/tensor/reduction/argmin.py +1 -3
- maxframe/tensor/reduction/array_equal.py +0 -2
- maxframe/tensor/reduction/core.py +0 -2
- maxframe/tensor/reduction/count_nonzero.py +0 -2
- maxframe/tensor/reduction/cumprod.py +0 -2
- maxframe/tensor/reduction/cumsum.py +0 -2
- maxframe/tensor/reduction/max.py +0 -2
- maxframe/tensor/reduction/mean.py +0 -2
- maxframe/tensor/reduction/min.py +0 -2
- maxframe/tensor/reduction/nanargmax.py +0 -2
- maxframe/tensor/reduction/nanargmin.py +0 -2
- maxframe/tensor/reduction/nancumprod.py +0 -2
- maxframe/tensor/reduction/nancumsum.py +0 -2
- maxframe/tensor/reduction/nanmax.py +0 -2
- maxframe/tensor/reduction/nanmean.py +0 -2
- maxframe/tensor/reduction/nanmin.py +0 -2
- maxframe/tensor/reduction/nanprod.py +0 -2
- maxframe/tensor/reduction/nanstd.py +0 -2
- maxframe/tensor/reduction/nansum.py +0 -2
- maxframe/tensor/reduction/nanvar.py +0 -2
- maxframe/tensor/reduction/prod.py +0 -2
- maxframe/tensor/reduction/std.py +0 -2
- maxframe/tensor/reduction/sum.py +0 -2
- maxframe/tensor/reduction/tests/test_reduction.py +1 -4
- maxframe/tensor/reduction/var.py +0 -2
- maxframe/tensor/reshape/__init__.py +0 -2
- maxframe/tensor/reshape/reshape.py +6 -5
- maxframe/tensor/reshape/tests/__init__.py +0 -2
- maxframe/tensor/reshape/tests/test_reshape.py +0 -2
- maxframe/tensor/sort/__init__.py +16 -0
- maxframe/tensor/sort/argsort.py +150 -0
- maxframe/tensor/sort/sort.py +295 -0
- maxframe/tensor/special/__init__.py +37 -0
- maxframe/tensor/special/core.py +38 -0
- maxframe/tensor/special/misc.py +142 -0
- maxframe/tensor/special/statistical.py +56 -0
- maxframe/tensor/statistics/__init__.py +5 -0
- maxframe/tensor/statistics/average.py +143 -0
- maxframe/tensor/statistics/bincount.py +133 -0
- maxframe/tensor/statistics/quantile.py +10 -8
- maxframe/tensor/ufunc/__init__.py +0 -2
- maxframe/tensor/ufunc/ufunc.py +0 -2
- maxframe/tensor/utils.py +21 -3
- maxframe/tests/test_protocol.py +3 -3
- maxframe/tests/test_utils.py +210 -1
- maxframe/tests/utils.py +59 -1
- maxframe/udf.py +76 -6
- maxframe/utils.py +418 -17
- {maxframe-1.3.0.dist-info → maxframe-2.0.0.dist-info}/METADATA +5 -1
- maxframe-2.0.0.dist-info/RECORD +939 -0
- maxframe_client/clients/framedriver.py +19 -3
- maxframe_client/fetcher.py +113 -6
- maxframe_client/session/odps.py +173 -38
- maxframe_client/session/task.py +3 -1
- maxframe_client/tests/test_session.py +41 -5
- maxframe-1.3.0.dist-info/RECORD +0 -705
- {maxframe-1.3.0.dist-info → maxframe-2.0.0.dist-info}/WHEEL +0 -0
- {maxframe-1.3.0.dist-info → maxframe-2.0.0.dist-info}/top_level.txt +0 -0
maxframe/mixin.py
CHANGED
|
@@ -12,15 +12,18 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import errno
|
|
15
16
|
import logging.config
|
|
16
|
-
|
|
17
|
+
import os
|
|
18
|
+
from typing import List, Union
|
|
17
19
|
|
|
18
20
|
import traitlets as T
|
|
21
|
+
from tornado import httpserver, web
|
|
19
22
|
from tornado.log import enable_pretty_logging
|
|
20
23
|
from traitlets.config import Configurable
|
|
21
24
|
|
|
22
25
|
from . import env
|
|
23
|
-
from .utils import trait_from_env
|
|
26
|
+
from .utils import random_ports, trait_from_env
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
class ServiceConfigMixin(Configurable):
|
|
@@ -66,6 +69,55 @@ class ServiceConfigMixin(Configurable):
|
|
|
66
69
|
)
|
|
67
70
|
base_url_default = trait_from_env("base_url", base_url_env)
|
|
68
71
|
|
|
72
|
+
def init_http_server(self) -> None:
|
|
73
|
+
"""Initializes an HTTP server for the Tornado web application on the
|
|
74
|
+
configured interface and port.
|
|
75
|
+
|
|
76
|
+
Tries to find an open port if the one configured is not available using
|
|
77
|
+
the same logic as the Jupyter Notebook server.
|
|
78
|
+
"""
|
|
79
|
+
self.http_server = httpserver.HTTPServer(self.web_app)
|
|
80
|
+
|
|
81
|
+
for port in random_ports(self.port, self.port_retries + 1):
|
|
82
|
+
try:
|
|
83
|
+
self.http_server.listen(port, self.ip)
|
|
84
|
+
except OSError as e:
|
|
85
|
+
if e.errno == errno.EADDRINUSE:
|
|
86
|
+
self.log.info(
|
|
87
|
+
"The port %i is already in use, trying another port." % port
|
|
88
|
+
)
|
|
89
|
+
continue
|
|
90
|
+
elif e.errno in (
|
|
91
|
+
errno.EACCES,
|
|
92
|
+
getattr(errno, "WSAEACCES", errno.EACCES),
|
|
93
|
+
):
|
|
94
|
+
self.log.warning("Permission to listen on port %i denied" % port)
|
|
95
|
+
continue
|
|
96
|
+
else:
|
|
97
|
+
raise
|
|
98
|
+
else:
|
|
99
|
+
self.port = port
|
|
100
|
+
if env.MAXFRAME_HTTP_PORT_FILE in os.environ:
|
|
101
|
+
try:
|
|
102
|
+
with open(os.getenv(env.MAXFRAME_HTTP_PORT_FILE), "w") as outf:
|
|
103
|
+
outf.write(str(port))
|
|
104
|
+
except IOError: # pragma: no cover
|
|
105
|
+
self.log.warning(
|
|
106
|
+
"Failed to write port file %s",
|
|
107
|
+
os.getenv(env.MAXFRAME_HTTP_PORT_FILE),
|
|
108
|
+
)
|
|
109
|
+
break
|
|
110
|
+
else:
|
|
111
|
+
self.log.critical(
|
|
112
|
+
"ERROR: the gateway server could not be started because "
|
|
113
|
+
"no available port could be found."
|
|
114
|
+
)
|
|
115
|
+
self.exit(1)
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def get_health_handlers(cls) -> List[tuple]:
|
|
119
|
+
return [("/health", HealthHandler)]
|
|
120
|
+
|
|
69
121
|
|
|
70
122
|
class LoggerConfigMixin(Configurable):
|
|
71
123
|
log_config_file_env = env.MAXFRAME_SERVICE_LOG_CONFIG_FILE
|
|
@@ -98,3 +150,8 @@ class LoggerConfigMixin(Configurable):
|
|
|
98
150
|
logging.getLogger().setLevel(log_level)
|
|
99
151
|
# Adjust kubernetes logging level to hide secrets when logging
|
|
100
152
|
logging.getLogger("kubernetes").setLevel(logging.WARNING)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class HealthHandler(web.RequestHandler):
|
|
156
|
+
async def get(self):
|
|
157
|
+
self.set_status(200)
|
maxframe/opcodes.py
CHANGED
|
@@ -305,7 +305,7 @@ QUANTILE = 440
|
|
|
305
305
|
FILL_DIAGONAL = 441
|
|
306
306
|
NORMALIZE = 442
|
|
307
307
|
TOPK = 443
|
|
308
|
-
|
|
308
|
+
TRAPEZOID = 444
|
|
309
309
|
GET_SHAPE = 445
|
|
310
310
|
BINCOUNT = 446
|
|
311
311
|
# fancy index, distributed phase is a shuffle operation that
|
|
@@ -528,7 +528,7 @@ START_TRACKER = 3004
|
|
|
528
528
|
# LightGBM
|
|
529
529
|
LGBM_TRAIN = 3020
|
|
530
530
|
LGBM_PREDICT = 3021
|
|
531
|
-
|
|
531
|
+
TO_LGBM_DATASET = 3022
|
|
532
532
|
|
|
533
533
|
# TensorFlow
|
|
534
534
|
RUN_TENSORFLOW = 3010
|
|
@@ -560,19 +560,27 @@ COLLECT_PORTS = 3306
|
|
|
560
560
|
UNIQUE_LABELS = 3307
|
|
561
561
|
# preprocessing
|
|
562
562
|
LABEL_BINARIZE = 3308
|
|
563
|
-
#
|
|
564
|
-
|
|
565
|
-
|
|
563
|
+
# check consistent length
|
|
564
|
+
CHECK_CONSISTENT_LENGTH = 3309
|
|
565
|
+
|
|
566
566
|
# ensemble: bagging
|
|
567
567
|
BAGGING_SHUFFLE_SAMPLE = 3400
|
|
568
568
|
BAGGING_SHUFFLE_REINDEX = 3401
|
|
569
569
|
BAGGING_FIT = 3402
|
|
570
570
|
BAGGING_PREDICTION = 3403
|
|
571
571
|
|
|
572
|
+
# ensemble: blockwise
|
|
573
|
+
BLOCKWISE_ENSEMBLE_FIT = 3410
|
|
574
|
+
BLOCKWISE_ENSEMBLE_PREDICT = 3411
|
|
575
|
+
|
|
572
576
|
# Remote Functions and class
|
|
573
577
|
REMOTE_FUNCATION = 5001
|
|
574
578
|
RUN_SCRIPT = 5002
|
|
575
579
|
|
|
580
|
+
# learn metrics
|
|
581
|
+
MULTILABEL_CONFUSION_MATRIX = 5201
|
|
582
|
+
PRECISION_RECALL_F_SCORE_SUPPORT = 5202
|
|
583
|
+
|
|
576
584
|
CHOLESKY_FUSE = 999988
|
|
577
585
|
|
|
578
586
|
# MaxFrame-dedicated functions
|
maxframe/protocol.py
CHANGED
|
@@ -44,6 +44,26 @@ pickling_support.install()
|
|
|
44
44
|
|
|
45
45
|
BodyType = TypeVar("BodyType", bound="Serializable")
|
|
46
46
|
|
|
47
|
+
_PANDAS_HAS_MGR = hasattr(pd.Series([0]), "_mgr")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _base64_pickle(val: Any) -> str:
|
|
51
|
+
return base64.b64encode(pickle.dumps(val)).decode()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _base64_unpickle(val: str) -> Any:
|
|
55
|
+
# as pandas prior to 1.1.0 use _data instead of _mgr to hold BlockManager,
|
|
56
|
+
# deserializing from high versions may produce mal-functioned pandas objects,
|
|
57
|
+
# thus the patch is needed
|
|
58
|
+
|
|
59
|
+
res = pickle.loads(base64.b64decode(val))
|
|
60
|
+
if _PANDAS_HAS_MGR or not isinstance(res, (pd.DataFrame, pd.Series)):
|
|
61
|
+
return res
|
|
62
|
+
if hasattr(res, "_mgr"):
|
|
63
|
+
res._data = getattr(res, "_mgr")
|
|
64
|
+
delattr(res, "_mgr")
|
|
65
|
+
return res
|
|
66
|
+
|
|
47
67
|
|
|
48
68
|
class JsonSerializable(Serializable):
|
|
49
69
|
_ignore_non_existing_keys = True
|
|
@@ -63,7 +83,7 @@ class ProtocolBody(Generic[BodyType], Serializable):
|
|
|
63
83
|
body: BodyType = AnyField("body", default=None)
|
|
64
84
|
|
|
65
85
|
|
|
66
|
-
class
|
|
86
|
+
class ExecutionStatus(enum.Enum):
|
|
67
87
|
PREPARING = 0
|
|
68
88
|
RUNNING = 1
|
|
69
89
|
SUCCEEDED = 2
|
|
@@ -72,7 +92,15 @@ class DagStatus(enum.Enum):
|
|
|
72
92
|
CANCELLED = 5
|
|
73
93
|
|
|
74
94
|
def is_terminated(self):
|
|
75
|
-
return self in (
|
|
95
|
+
return self in (
|
|
96
|
+
ExecutionStatus.CANCELLED,
|
|
97
|
+
ExecutionStatus.SUCCEEDED,
|
|
98
|
+
ExecutionStatus.FAILED,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# keep compatibility
|
|
103
|
+
DagStatus = ExecutionStatus
|
|
76
104
|
|
|
77
105
|
|
|
78
106
|
class DimensionIndex(Serializable):
|
|
@@ -85,6 +113,7 @@ class ResultType(enum.Enum):
|
|
|
85
113
|
NULL = 0
|
|
86
114
|
ODPS_TABLE = 1
|
|
87
115
|
ODPS_VOLUME = 2
|
|
116
|
+
CONSTANT = 3
|
|
88
117
|
|
|
89
118
|
|
|
90
119
|
class DataSerializeType(enum.Enum):
|
|
@@ -133,6 +162,26 @@ class ResultInfo(JsonSerializable):
|
|
|
133
162
|
ResultInfoType = TypeVar("ResultInfoType", bound=ResultInfo)
|
|
134
163
|
|
|
135
164
|
|
|
165
|
+
class ConstantResultInfo(ResultInfo):
|
|
166
|
+
_result_type = ResultType.CONSTANT
|
|
167
|
+
|
|
168
|
+
data: Any = AnyField("data", default=None)
|
|
169
|
+
|
|
170
|
+
def __init__(self, result_type: ResultType = None, **kw):
|
|
171
|
+
result_type = result_type or ResultType.CONSTANT
|
|
172
|
+
super().__init__(result_type=result_type, **kw)
|
|
173
|
+
|
|
174
|
+
def to_json(self) -> dict:
|
|
175
|
+
ret = super().to_json()
|
|
176
|
+
ret["data"] = _base64_pickle(self.data)
|
|
177
|
+
return ret
|
|
178
|
+
|
|
179
|
+
def _json_to_kwargs(self, serialized: dict) -> dict:
|
|
180
|
+
kw = super()._json_to_kwargs(serialized)
|
|
181
|
+
kw["data"] = _base64_unpickle(kw["data"])
|
|
182
|
+
return kw
|
|
183
|
+
|
|
184
|
+
|
|
136
185
|
class ODPSTableResultInfo(ResultInfo):
|
|
137
186
|
_result_type = ResultType.ODPS_TABLE
|
|
138
187
|
|
|
@@ -254,7 +303,9 @@ class ErrorInfo(JsonSerializable):
|
|
|
254
303
|
class DagInfo(JsonSerializable):
|
|
255
304
|
session_id: str = StringField("session_id", default=None)
|
|
256
305
|
dag_id: str = StringField("dag_id", default=None)
|
|
257
|
-
status:
|
|
306
|
+
status: ExecutionStatus = EnumField(
|
|
307
|
+
"status", ExecutionStatus, FieldTypes.int8, default=None
|
|
308
|
+
)
|
|
258
309
|
progress: float = Float64Field("progress", default=None)
|
|
259
310
|
tileable_to_result_infos: Dict[str, ResultInfo] = DictField(
|
|
260
311
|
"tileable_to_result_infos",
|
|
@@ -277,7 +328,7 @@ class DagInfo(JsonSerializable):
|
|
|
277
328
|
if serialized is None:
|
|
278
329
|
return None
|
|
279
330
|
kw = serialized.copy()
|
|
280
|
-
kw["status"] =
|
|
331
|
+
kw["status"] = ExecutionStatus(kw["status"])
|
|
281
332
|
if kw.get("tileable_to_result_infos"):
|
|
282
333
|
kw["tileable_to_result_infos"] = {
|
|
283
334
|
k: ResultInfo.from_json(s)
|
|
@@ -402,7 +453,9 @@ class SubDagSubmitInstanceInfo(JsonSerializable):
|
|
|
402
453
|
|
|
403
454
|
class SubDagInfo(JsonSerializable):
|
|
404
455
|
subdag_id: str = StringField("subdag_id")
|
|
405
|
-
status:
|
|
456
|
+
status: ExecutionStatus = EnumField(
|
|
457
|
+
"status", ExecutionStatus, FieldTypes.int8, default=None
|
|
458
|
+
)
|
|
406
459
|
progress: float = Float64Field("progress", default=None)
|
|
407
460
|
error_info: Optional[ErrorInfo] = ReferenceField(
|
|
408
461
|
"error_info", reference_type=ErrorInfo, default=None
|
|
@@ -424,7 +477,7 @@ class SubDagInfo(JsonSerializable):
|
|
|
424
477
|
@classmethod
|
|
425
478
|
def from_json(cls, serialized: dict) -> "SubDagInfo":
|
|
426
479
|
kw = serialized.copy()
|
|
427
|
-
kw["status"] =
|
|
480
|
+
kw["status"] = ExecutionStatus(kw["status"])
|
|
428
481
|
if kw.get("tileable_to_result_infos"):
|
|
429
482
|
kw["tileable_to_result_infos"] = {
|
|
430
483
|
k: ResultInfo.from_json(s)
|
|
@@ -516,27 +569,27 @@ class DataFrameTableMeta(JsonSerializable):
|
|
|
516
569
|
return True
|
|
517
570
|
|
|
518
571
|
def to_json(self) -> dict:
|
|
519
|
-
b64_pk = lambda x: base64.b64encode(pickle.dumps(x)).decode()
|
|
520
572
|
ret = {
|
|
521
573
|
"table_name": self.table_name,
|
|
522
574
|
"type": self.type.value,
|
|
523
575
|
"table_column_names": self.table_column_names,
|
|
524
576
|
"table_index_column_names": self.table_index_column_names,
|
|
525
|
-
"pd_column_dtypes":
|
|
526
|
-
"pd_column_level_names":
|
|
527
|
-
"pd_index_dtypes":
|
|
577
|
+
"pd_column_dtypes": _base64_pickle(self.pd_column_dtypes),
|
|
578
|
+
"pd_column_level_names": _base64_pickle(self.pd_column_level_names),
|
|
579
|
+
"pd_index_dtypes": _base64_pickle(self.pd_index_dtypes),
|
|
528
580
|
}
|
|
529
581
|
return ret
|
|
530
582
|
|
|
531
583
|
@classmethod
|
|
532
584
|
def from_json(cls, serialized: dict) -> "DataFrameTableMeta":
|
|
533
|
-
b64_upk = lambda x: pickle.loads(base64.b64decode(x))
|
|
534
585
|
serialized.update(
|
|
535
586
|
{
|
|
536
587
|
"type": OutputType(serialized["type"]),
|
|
537
|
-
"pd_column_dtypes":
|
|
538
|
-
"pd_column_level_names":
|
|
539
|
-
|
|
588
|
+
"pd_column_dtypes": _base64_unpickle(serialized["pd_column_dtypes"]),
|
|
589
|
+
"pd_column_level_names": _base64_unpickle(
|
|
590
|
+
serialized["pd_column_level_names"]
|
|
591
|
+
),
|
|
592
|
+
"pd_index_dtypes": _base64_unpickle(serialized["pd_index_dtypes"]),
|
|
540
593
|
}
|
|
541
594
|
)
|
|
542
595
|
return DataFrameTableMeta(**serialized)
|
maxframe/remote/core.py
CHANGED
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from functools import partial
|
|
16
|
+
from typing import List
|
|
16
17
|
|
|
17
18
|
from .. import opcodes
|
|
18
|
-
from ..core import ENTITY_TYPE
|
|
19
|
+
from ..core import ENTITY_TYPE, EntityData
|
|
19
20
|
from ..core.operator import ObjectOperator, ObjectOperatorMixin
|
|
20
21
|
from ..dataframe.core import DATAFRAME_TYPE, INDEX_TYPE, SERIES_TYPE
|
|
21
22
|
from ..serialization.serializables import (
|
|
@@ -26,6 +27,7 @@ from ..serialization.serializables import (
|
|
|
26
27
|
ListField,
|
|
27
28
|
)
|
|
28
29
|
from ..tensor.core import TENSOR_TYPE
|
|
30
|
+
from ..udf import BuiltinFunction
|
|
29
31
|
from ..utils import find_objects, replace_objects
|
|
30
32
|
|
|
31
33
|
|
|
@@ -54,21 +56,21 @@ class RemoteFunction(ObjectOperatorMixin, ObjectOperator):
|
|
|
54
56
|
tileable, (TENSOR_TYPE, DATAFRAME_TYPE, SERIES_TYPE, INDEX_TYPE)
|
|
55
57
|
)
|
|
56
58
|
|
|
57
|
-
def
|
|
58
|
-
|
|
59
|
-
super()._set_inputs(inputs)
|
|
59
|
+
def has_custom_code(self) -> bool:
|
|
60
|
+
return not isinstance(self.function, BuiltinFunction)
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
@classmethod
|
|
63
|
+
def _set_inputs(cls, op: "RemoteFunction", inputs: List[EntityData]):
|
|
64
|
+
raw_inputs = getattr(op, "_inputs", None)
|
|
65
|
+
super()._set_inputs(op, inputs)
|
|
66
|
+
|
|
67
|
+
function_inputs = iter(inp for inp in op._inputs)
|
|
68
|
+
mapping = {inp: new_inp for inp, new_inp in zip(inputs, op._inputs)}
|
|
63
69
|
if raw_inputs is not None:
|
|
64
70
|
for raw_inp in raw_inputs:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
else:
|
|
69
|
-
mapping[raw_inp] = next(function_inputs)
|
|
70
|
-
self.function_args = replace_objects(self.function_args, mapping)
|
|
71
|
-
self.function_kwargs = replace_objects(self.function_kwargs, mapping)
|
|
71
|
+
mapping[raw_inp] = next(function_inputs)
|
|
72
|
+
op.function_args = replace_objects(op.function_args, mapping)
|
|
73
|
+
op.function_kwargs = replace_objects(op.function_kwargs, mapping)
|
|
72
74
|
|
|
73
75
|
def __call__(self):
|
|
74
76
|
find_inputs = partial(find_objects, types=ENTITY_TYPE)
|
|
@@ -85,7 +87,7 @@ def spawn(
|
|
|
85
87
|
func,
|
|
86
88
|
args=(),
|
|
87
89
|
kwargs=None,
|
|
88
|
-
retry_when_fail=
|
|
90
|
+
retry_when_fail=True,
|
|
89
91
|
resolve_tileable_input=False,
|
|
90
92
|
n_output=None,
|
|
91
93
|
**kw,
|
maxframe/remote/run_script.py
CHANGED
|
@@ -17,7 +17,7 @@ from typing import Any, BinaryIO, Dict, List, TextIO, Union
|
|
|
17
17
|
|
|
18
18
|
from .. import opcodes
|
|
19
19
|
from ..core import TILEABLE_TYPE, OutputType
|
|
20
|
-
from ..core.operator import
|
|
20
|
+
from ..core.operator import ObjectOperator, ObjectOperatorMixin
|
|
21
21
|
from ..serialization.serializables import (
|
|
22
22
|
BoolField,
|
|
23
23
|
BytesField,
|
|
@@ -29,7 +29,7 @@ from ..typing_ import SessionType, TileableType
|
|
|
29
29
|
from ..utils import to_binary
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
class RunScript(
|
|
32
|
+
class RunScript(ObjectOperator, ObjectOperatorMixin):
|
|
33
33
|
_op_type_ = opcodes.RUN_SCRIPT
|
|
34
34
|
|
|
35
35
|
code: bytes = BytesField("code", default=None)
|
|
@@ -49,6 +49,9 @@ class RunScript(MergeDictOperator):
|
|
|
49
49
|
def retryable(self):
|
|
50
50
|
return self.retry_when_fail
|
|
51
51
|
|
|
52
|
+
def has_custom_code(self) -> bool:
|
|
53
|
+
return True
|
|
54
|
+
|
|
52
55
|
def __call__(self, inputs):
|
|
53
56
|
return self.new_tileable(inputs)
|
|
54
57
|
|
|
@@ -74,7 +77,7 @@ def run_script(
|
|
|
74
77
|
n_workers: int = 1,
|
|
75
78
|
command_argv: List[str] = None,
|
|
76
79
|
session: SessionType = None,
|
|
77
|
-
retry_when_fail: bool =
|
|
80
|
+
retry_when_fail: bool = True,
|
|
78
81
|
run_kwargs: Dict[str, Any] = None,
|
|
79
82
|
):
|
|
80
83
|
"""
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
from . import arrow, exception, maxframe_objects, numpy, pandas, scipy, serializables
|
|
16
16
|
from .core import (
|
|
17
17
|
PickleContainer,
|
|
18
|
+
PickleHookOptions,
|
|
18
19
|
Serializer,
|
|
19
20
|
clear_type_cache,
|
|
20
21
|
deserialize,
|
|
22
|
+
load_member,
|
|
21
23
|
load_type,
|
|
22
24
|
pickle_buffers,
|
|
23
25
|
serialize,
|
|
Binary file
|
maxframe/serialization/core.pxd
CHANGED
maxframe/serialization/core.pyi
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from concurrent.futures import Executor
|
|
16
|
-
from typing import Any, Callable, Dict, List, TypeVar
|
|
16
|
+
from typing import Any, Callable, Dict, List, Type, TypeVar
|
|
17
17
|
|
|
18
18
|
def buffered(func: Callable) -> Callable: ...
|
|
19
19
|
def fast_id(obj: Any) -> int: ...
|
|
@@ -21,6 +21,8 @@ def fast_id(obj: Any) -> int: ...
|
|
|
21
21
|
LoadType = TypeVar("LoadType")
|
|
22
22
|
|
|
23
23
|
def load_type(class_name: str, parent_class: LoadType) -> LoadType: ...
|
|
24
|
+
def load_member(class_name: str, restrict_type: Type[LoadType]) -> LoadType: ...
|
|
25
|
+
def reload_unpickle_flag(): ...
|
|
24
26
|
|
|
25
27
|
class PickleContainer:
|
|
26
28
|
def __init__(self, buffers: List[bytes]): ...
|
maxframe/serialization/core.pyx
CHANGED
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
16
|
import asyncio
|
|
17
|
+
import contextvars
|
|
18
|
+
import copy
|
|
17
19
|
import datetime
|
|
18
20
|
import hashlib
|
|
19
21
|
import importlib
|
|
22
|
+
import os
|
|
20
23
|
import re
|
|
21
24
|
from collections import OrderedDict
|
|
22
25
|
from functools import partial, wraps
|
|
@@ -38,7 +41,7 @@ from .._utils cimport TypeDispatcher
|
|
|
38
41
|
|
|
39
42
|
from ..lib import wrapped_pickle as pickle
|
|
40
43
|
from ..lib.dtypes_extension import ArrowDtype
|
|
41
|
-
from ..utils import NoDefault, arrow_type_from_str, no_default
|
|
44
|
+
from ..utils import NoDefault, arrow_type_from_str, no_default, str_to_bool
|
|
42
45
|
|
|
43
46
|
# resolve pandas pickle compatibility between <1.2 and >=1.3
|
|
44
47
|
try:
|
|
@@ -98,14 +101,50 @@ cdef:
|
|
|
98
101
|
cdef dict _type_cache = dict()
|
|
99
102
|
|
|
100
103
|
|
|
101
|
-
|
|
104
|
+
cdef object pickle_serial_hook = contextvars.ContextVar("pickle_serial_hook", default=None)
|
|
105
|
+
cdef object pickle_deserial_hook = contextvars.ContextVar("pickle_deserial_hook", default=None)
|
|
106
|
+
|
|
107
|
+
cdef class PickleHookOptions:
|
|
108
|
+
cdef:
|
|
109
|
+
object _serial_hook
|
|
110
|
+
object _pre_serial_hook
|
|
111
|
+
object _deserial_hook
|
|
112
|
+
object _pre_deserial_hook
|
|
113
|
+
|
|
114
|
+
def __init__(self, serial_hook: object = None, deserial_hook: object = None):
|
|
115
|
+
self._serial_hook = serial_hook
|
|
116
|
+
self._deserial_hook = deserial_hook
|
|
117
|
+
|
|
118
|
+
def __enter__(self):
|
|
119
|
+
self._pre_serial_hook = pickle_serial_hook.set(self._serial_hook)
|
|
120
|
+
self._pre_deserial_hook = pickle_deserial_hook.set(self._deserial_hook)
|
|
121
|
+
|
|
122
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
123
|
+
pickle_serial_hook.reset(self._pre_serial_hook)
|
|
124
|
+
pickle_deserial_hook.reset(self._pre_deserial_hook)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
cdef bint unpickle_allowed
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def reload_unpickle_flag():
|
|
131
|
+
global unpickle_allowed
|
|
132
|
+
unpickle_allowed = str_to_bool(
|
|
133
|
+
os.getenv("MAXFRAME_SERIALIZE_UNPICKLE_ALLOWED", "1")
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
reload_unpickle_flag()
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
cdef object _load_by_name(str class_name):
|
|
102
141
|
if class_name in _type_cache:
|
|
103
142
|
cls = _type_cache[class_name]
|
|
104
143
|
else:
|
|
105
144
|
try:
|
|
106
|
-
from .deserializer import
|
|
145
|
+
from .deserializer import safe_load_by_name
|
|
107
146
|
|
|
108
|
-
cls =
|
|
147
|
+
cls = safe_load_by_name(class_name)
|
|
109
148
|
except ImportError:
|
|
110
149
|
if pickle.is_unpickle_forbidden():
|
|
111
150
|
raise
|
|
@@ -123,12 +162,27 @@ cpdef object load_type(str class_name, object parent_class):
|
|
|
123
162
|
for sub_cls_name in cls_name.split("."):
|
|
124
163
|
cls = getattr(cls, sub_cls_name)
|
|
125
164
|
_type_cache[class_name] = cls
|
|
165
|
+
return cls
|
|
166
|
+
|
|
126
167
|
|
|
168
|
+
cpdef object load_type(str class_name, object parent_class):
|
|
169
|
+
cls = _load_by_name(class_name)
|
|
170
|
+
if not isinstance(cls, type):
|
|
171
|
+
raise ValueError(f"Class {class_name} not a type, cannot be deserialized")
|
|
127
172
|
if not issubclass(cls, parent_class):
|
|
128
173
|
raise ValueError(f"Class {class_name} not a {parent_class}")
|
|
129
174
|
return cls
|
|
130
175
|
|
|
131
176
|
|
|
177
|
+
cpdef object load_member(str class_name, object restrict_type):
|
|
178
|
+
member = _load_by_name(class_name)
|
|
179
|
+
if not isinstance(member, restrict_type):
|
|
180
|
+
raise ValueError(
|
|
181
|
+
f"Class {class_name} not a {restrict_type}, cannot be deserialized"
|
|
182
|
+
)
|
|
183
|
+
return member
|
|
184
|
+
|
|
185
|
+
|
|
132
186
|
cpdef void clear_type_cache():
|
|
133
187
|
_type_cache.clear()
|
|
134
188
|
|
|
@@ -358,17 +412,37 @@ cdef class PickleContainer:
|
|
|
358
412
|
self.buffers = buffers
|
|
359
413
|
|
|
360
414
|
cpdef get(self):
|
|
415
|
+
if not unpickle_allowed:
|
|
416
|
+
raise ValueError("Unpickle not allowed in this environment")
|
|
361
417
|
return unpickle_buffers(self.buffers)
|
|
362
418
|
|
|
363
419
|
cpdef list get_buffers(self):
|
|
364
420
|
return self.buffers
|
|
365
421
|
|
|
422
|
+
def __copy__(self):
|
|
423
|
+
return PickleContainer(self.buffers)
|
|
424
|
+
|
|
425
|
+
def __deepcopy__(self, memo=None):
|
|
426
|
+
return PickleContainer(copy.deepcopy(self.buffers, memo))
|
|
427
|
+
|
|
428
|
+
def __maxframe_tokenize__(self):
|
|
429
|
+
return self.buffers
|
|
430
|
+
|
|
431
|
+
def __reduce__(self):
|
|
432
|
+
return PickleContainer, (self.buffers, )
|
|
433
|
+
|
|
366
434
|
|
|
367
435
|
cdef class PickleSerializer(Serializer):
|
|
368
436
|
serializer_id = PICKLE_SERIALIZER
|
|
369
437
|
|
|
370
438
|
cpdef serial(self, obj: Any, dict context):
|
|
371
439
|
cdef uint64_t obj_id
|
|
440
|
+
cdef object serial_hook
|
|
441
|
+
|
|
442
|
+
serial_hook = pickle_serial_hook.get()
|
|
443
|
+
if serial_hook is not None:
|
|
444
|
+
serial_hook()
|
|
445
|
+
|
|
372
446
|
obj_id = _fast_id(<PyObject*>obj)
|
|
373
447
|
if obj_id in context:
|
|
374
448
|
return Placeholder(obj_id)
|
|
@@ -380,7 +454,11 @@ cdef class PickleSerializer(Serializer):
|
|
|
380
454
|
|
|
381
455
|
cpdef deserial(self, list serialized, dict context, list subs):
|
|
382
456
|
from .deserializer import deserial_pickle
|
|
457
|
+
cdef object deserial_hook
|
|
383
458
|
|
|
459
|
+
deserial_hook = pickle_deserial_hook.get()
|
|
460
|
+
if deserial_hook is not None:
|
|
461
|
+
deserial_hook()
|
|
384
462
|
return deserial_pickle(serialized, context, subs)
|
|
385
463
|
|
|
386
464
|
|
maxframe/serialization/pandas.py
CHANGED
|
@@ -39,7 +39,11 @@ class DataFrameSerializer(Serializer):
|
|
|
39
39
|
self, serialized: List, context: Dict, subs: List[Any]
|
|
40
40
|
) -> pd.DataFrame:
|
|
41
41
|
dtypes, idx = subs[:2]
|
|
42
|
-
|
|
42
|
+
seriess = [pd.Series(d, index=idx) for d in subs[2:]]
|
|
43
|
+
if seriess:
|
|
44
|
+
df = pd.concat([pd.Series(d, index=idx) for d in subs[2:]], axis=1)
|
|
45
|
+
else:
|
|
46
|
+
df = pd.DataFrame([], index=idx)
|
|
43
47
|
df.columns = dtypes.index
|
|
44
48
|
df.index = idx
|
|
45
49
|
return df.astype(dtypes)
|
|
@@ -21,15 +21,15 @@ import msgpack
|
|
|
21
21
|
|
|
22
22
|
from ...errors import MaxFrameDeprecationError
|
|
23
23
|
from ...lib.mmh3 import hash
|
|
24
|
-
from ...utils import no_default
|
|
24
|
+
from ...utils import extract_class_name, no_default
|
|
25
25
|
from ..core import Placeholder, Serializer, buffered, load_type
|
|
26
26
|
from .field import Field
|
|
27
27
|
from .field_type import DictType, ListType, PrimitiveFieldType, TupleType
|
|
28
28
|
|
|
29
29
|
try:
|
|
30
|
-
from ..deserializer import
|
|
30
|
+
from ..deserializer import get_legacy_class_name
|
|
31
31
|
except ImportError:
|
|
32
|
-
|
|
32
|
+
get_legacy_class_name = lambda x: x
|
|
33
33
|
|
|
34
34
|
logger = logging.getLogger(__name__)
|
|
35
35
|
_deprecate_log_key = "_SER_DEPRECATE_LOGGED"
|
|
@@ -62,8 +62,9 @@ def _is_field_primitive_compound(field: Field):
|
|
|
62
62
|
class SerializableMeta(type):
|
|
63
63
|
def __new__(mcs, name: str, bases: Tuple[Type], properties: Dict):
|
|
64
64
|
# All the fields including misc fields.
|
|
65
|
+
legacy_name = properties.get("_legacy_name", name)
|
|
65
66
|
legacy_name_hash = hash(
|
|
66
|
-
f"{
|
|
67
|
+
get_legacy_class_name(f"{properties.get('__module__')}.{legacy_name}")
|
|
67
68
|
)
|
|
68
69
|
name_hash = hash(
|
|
69
70
|
f"{properties.get('__module__')}.{properties.get('__qualname__')}"
|
|
@@ -300,7 +301,7 @@ class SerializableSerializer(Serializer):
|
|
|
300
301
|
_primitive_serial_cache[obj] = primitive_vals
|
|
301
302
|
|
|
302
303
|
compound_vals = self._get_field_values(obj, obj._NON_PRIMITIVE_FIELDS)
|
|
303
|
-
cls_module =
|
|
304
|
+
cls_module = extract_class_name(type(obj))
|
|
304
305
|
|
|
305
306
|
field_count_key = self._get_obj_field_count_key(obj)
|
|
306
307
|
if not self.is_public_data_exist(context, field_count_key):
|
|
@@ -20,7 +20,7 @@ import os
|
|
|
20
20
|
from abc import ABC, ABCMeta, abstractmethod
|
|
21
21
|
from typing import Any, Callable, Optional, Type, Union
|
|
22
22
|
|
|
23
|
-
from ...utils import no_default
|
|
23
|
+
from ...utils import no_default, str_to_bool
|
|
24
24
|
from .field_type import (
|
|
25
25
|
AbstractFieldType,
|
|
26
26
|
DictType,
|
|
@@ -30,7 +30,7 @@ from .field_type import (
|
|
|
30
30
|
TupleType,
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
_is_ci = (os.environ.get("CI")
|
|
33
|
+
_is_ci = bool(str_to_bool(os.environ.get("CI")))
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class Field(ABC):
|
|
@@ -69,8 +69,8 @@ fields_values = [
|
|
|
69
69
|
[FieldTypes.reference(MyClass), [MyClass()], [object()]],
|
|
70
70
|
[
|
|
71
71
|
FieldTypes.tuple(FieldTypes.int64, ...),
|
|
72
|
-
[
|
|
73
|
-
[list(),
|
|
72
|
+
[(), (1, 2)],
|
|
73
|
+
[list(), (1, 2.0)],
|
|
74
74
|
],
|
|
75
75
|
[
|
|
76
76
|
FieldTypes.list(FieldTypes.int64, FieldTypes.float64),
|
|
@@ -101,9 +101,7 @@ def test_field_type(field_type, valid_values, invalid_values):
|
|
|
101
101
|
|
|
102
102
|
def test_collction_field_error():
|
|
103
103
|
with pytest.raises(ValueError):
|
|
104
|
-
FieldTypes.tuple(FieldTypes.int64, FieldTypes.float32).validate(
|
|
105
|
-
tuple([1, 3.0, 3.0])
|
|
106
|
-
)
|
|
104
|
+
FieldTypes.tuple(FieldTypes.int64, FieldTypes.float32).validate((1, 3.0, 3.0))
|
|
107
105
|
|
|
108
106
|
|
|
109
107
|
def test_field_name():
|