maxframe 2.4.0rc1__cp312-cp312-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.
- maxframe/__init__.py +33 -0
- maxframe/_utils.cp312-win32.pyd +0 -0
- maxframe/_utils.pxd +33 -0
- maxframe/_utils.pyi +21 -0
- maxframe/_utils.pyx +561 -0
- maxframe/codegen/__init__.py +27 -0
- maxframe/codegen/core.py +597 -0
- maxframe/codegen/spe/__init__.py +16 -0
- maxframe/codegen/spe/core.py +307 -0
- maxframe/codegen/spe/dataframe/__init__.py +38 -0
- maxframe/codegen/spe/dataframe/accessors/__init__.py +15 -0
- maxframe/codegen/spe/dataframe/accessors/base.py +71 -0
- maxframe/codegen/spe/dataframe/accessors/dict_.py +89 -0
- maxframe/codegen/spe/dataframe/accessors/list_.py +44 -0
- maxframe/codegen/spe/dataframe/accessors/struct_.py +28 -0
- maxframe/codegen/spe/dataframe/arithmetic.py +89 -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 +312 -0
- maxframe/codegen/spe/dataframe/indexing.py +333 -0
- maxframe/codegen/spe/dataframe/merge.py +110 -0
- maxframe/codegen/spe/dataframe/misc.py +264 -0
- maxframe/codegen/spe/dataframe/missing.py +64 -0
- maxframe/codegen/spe/dataframe/reduction.py +183 -0
- maxframe/codegen/spe/dataframe/reshape.py +46 -0
- maxframe/codegen/spe/dataframe/sort.py +104 -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 +304 -0
- maxframe/codegen/spe/dataframe/tests/accessors/test_list.py +134 -0
- maxframe/codegen/spe/dataframe/tests/accessors/test_struct.py +75 -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 +95 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_indexing.py +39 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_loc.py +35 -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 +202 -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 +288 -0
- maxframe/codegen/spe/dataframe/tests/test_merge.py +426 -0
- maxframe/codegen/spe/dataframe/tests/test_reduction.py +117 -0
- maxframe/codegen/spe/dataframe/tests/test_reshape.py +79 -0
- maxframe/codegen/spe/dataframe/tests/test_sort.py +179 -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 +55 -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 +161 -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 +99 -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/_ranking.py +76 -0
- maxframe/codegen/spe/learn/metrics/pairwise.py +51 -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/metrics/tests/test_pairwise.py +36 -0
- maxframe/codegen/spe/learn/metrics/tests/test_ranking.py +59 -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 +31 -0
- maxframe/codegen/spe/tensor/arithmetic.py +95 -0
- maxframe/codegen/spe/tensor/core.py +41 -0
- maxframe/codegen/spe/tensor/datasource.py +166 -0
- maxframe/codegen/spe/tensor/extensions.py +35 -0
- maxframe/codegen/spe/tensor/fetch.py +26 -0
- maxframe/codegen/spe/tensor/fft.py +74 -0
- maxframe/codegen/spe/tensor/indexing.py +63 -0
- maxframe/codegen/spe/tensor/linalg.py +90 -0
- maxframe/codegen/spe/tensor/merge.py +31 -0
- maxframe/codegen/spe/tensor/misc.py +175 -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/spatial.py +45 -0
- maxframe/codegen/spe/tensor/special.py +35 -0
- maxframe/codegen/spe/tensor/statistics.py +68 -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_fft.py +64 -0
- maxframe/codegen/spe/tensor/tests/test_indexing.py +44 -0
- maxframe/codegen/spe/tensor/tests/test_linalg.py +52 -0
- maxframe/codegen/spe/tensor/tests/test_merge.py +28 -0
- maxframe/codegen/spe/tensor/tests/test_misc.py +144 -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_spatial.py +33 -0
- maxframe/codegen/spe/tensor/tests/test_special.py +28 -0
- maxframe/codegen/spe/tensor/tests/test_statistics.py +43 -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 +135 -0
- maxframe/codegen/spe/utils.py +56 -0
- maxframe/codegen/tests/__init__.py +13 -0
- maxframe/codegen/tests/test_codegen.py +67 -0
- maxframe/config/__init__.py +15 -0
- maxframe/config/config.py +630 -0
- maxframe/config/tests/__init__.py +13 -0
- maxframe/config/tests/test_config.py +114 -0
- maxframe/config/tests/test_validators.py +46 -0
- maxframe/config/validators.py +142 -0
- maxframe/conftest.py +261 -0
- maxframe/core/__init__.py +53 -0
- maxframe/core/accessor.py +45 -0
- maxframe/core/base.py +157 -0
- maxframe/core/context.py +110 -0
- maxframe/core/entity/__init__.py +34 -0
- maxframe/core/entity/core.py +150 -0
- maxframe/core/entity/executable.py +337 -0
- maxframe/core/entity/objects.py +115 -0
- maxframe/core/entity/output_types.py +101 -0
- maxframe/core/entity/tests/__init__.py +13 -0
- maxframe/core/entity/tests/test_objects.py +42 -0
- maxframe/core/entity/tileables.py +376 -0
- maxframe/core/entity/utils.py +39 -0
- maxframe/core/graph/__init__.py +22 -0
- maxframe/core/graph/builder/__init__.py +15 -0
- maxframe/core/graph/builder/base.py +90 -0
- maxframe/core/graph/builder/tileable.py +34 -0
- maxframe/core/graph/builder/utils.py +37 -0
- maxframe/core/graph/core.cp312-win32.pyd +0 -0
- maxframe/core/graph/core.pyx +478 -0
- maxframe/core/graph/entity.py +187 -0
- maxframe/core/graph/tests/__init__.py +13 -0
- maxframe/core/graph/tests/test_graph.py +205 -0
- maxframe/core/mode.py +101 -0
- maxframe/core/operator/__init__.py +32 -0
- maxframe/core/operator/base.py +481 -0
- maxframe/core/operator/core.py +307 -0
- maxframe/core/operator/fetch.py +40 -0
- maxframe/core/operator/objects.py +43 -0
- maxframe/core/operator/shuffle.py +45 -0
- maxframe/core/operator/tests/__init__.py +13 -0
- maxframe/core/operator/tests/test_core.py +64 -0
- maxframe/core/operator/utils.py +68 -0
- maxframe/core/tests/__init__.py +13 -0
- maxframe/core/tests/test_mode.py +75 -0
- maxframe/dataframe/__init__.py +90 -0
- maxframe/dataframe/accessors/__init__.py +20 -0
- maxframe/dataframe/accessors/compat.py +45 -0
- maxframe/dataframe/accessors/datetime_/__init__.py +35 -0
- maxframe/dataframe/accessors/datetime_/accessor.py +67 -0
- maxframe/dataframe/accessors/datetime_/core.py +106 -0
- maxframe/dataframe/accessors/datetime_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/datetime_/tests/test_datetime_accessor.py +41 -0
- maxframe/dataframe/accessors/dict_/__init__.py +45 -0
- maxframe/dataframe/accessors/dict_/accessor.py +39 -0
- maxframe/dataframe/accessors/dict_/contains.py +72 -0
- maxframe/dataframe/accessors/dict_/core.py +48 -0
- maxframe/dataframe/accessors/dict_/getitem.py +140 -0
- maxframe/dataframe/accessors/dict_/length.py +64 -0
- maxframe/dataframe/accessors/dict_/remove.py +75 -0
- maxframe/dataframe/accessors/dict_/setitem.py +79 -0
- maxframe/dataframe/accessors/dict_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/dict_/tests/test_dict_accessor.py +168 -0
- maxframe/dataframe/accessors/list_/__init__.py +39 -0
- maxframe/dataframe/accessors/list_/accessor.py +39 -0
- maxframe/dataframe/accessors/list_/core.py +48 -0
- maxframe/dataframe/accessors/list_/getitem.py +128 -0
- maxframe/dataframe/accessors/list_/length.py +64 -0
- maxframe/dataframe/accessors/list_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/list_/tests/test_list_accessor.py +81 -0
- maxframe/dataframe/accessors/plotting/__init__.py +40 -0
- maxframe/dataframe/accessors/plotting/core.py +78 -0
- maxframe/dataframe/accessors/plotting/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/plotting/tests/test_plotting_accessor.py +136 -0
- maxframe/dataframe/accessors/string_/__init__.py +36 -0
- maxframe/dataframe/accessors/string_/accessor.py +215 -0
- maxframe/dataframe/accessors/string_/core.py +226 -0
- maxframe/dataframe/accessors/string_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/string_/tests/test_string_accessor.py +73 -0
- maxframe/dataframe/accessors/struct_/__init__.py +39 -0
- maxframe/dataframe/accessors/struct_/accessor.py +39 -0
- maxframe/dataframe/accessors/struct_/core.py +43 -0
- maxframe/dataframe/accessors/struct_/dtypes.py +53 -0
- maxframe/dataframe/accessors/struct_/field.py +123 -0
- maxframe/dataframe/accessors/struct_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/struct_/tests/test_struct_accessor.py +91 -0
- maxframe/dataframe/arithmetic/__init__.py +373 -0
- maxframe/dataframe/arithmetic/abs.py +33 -0
- maxframe/dataframe/arithmetic/add.py +60 -0
- maxframe/dataframe/arithmetic/arccos.py +28 -0
- maxframe/dataframe/arithmetic/arccosh.py +28 -0
- maxframe/dataframe/arithmetic/arcsin.py +28 -0
- maxframe/dataframe/arithmetic/arcsinh.py +28 -0
- maxframe/dataframe/arithmetic/arctan.py +28 -0
- maxframe/dataframe/arithmetic/arctanh.py +28 -0
- maxframe/dataframe/arithmetic/between.py +106 -0
- maxframe/dataframe/arithmetic/bitwise_and.py +46 -0
- maxframe/dataframe/arithmetic/bitwise_or.py +50 -0
- maxframe/dataframe/arithmetic/bitwise_xor.py +46 -0
- maxframe/dataframe/arithmetic/ceil.py +28 -0
- maxframe/dataframe/arithmetic/core.py +361 -0
- maxframe/dataframe/arithmetic/cos.py +28 -0
- maxframe/dataframe/arithmetic/cosh.py +28 -0
- maxframe/dataframe/arithmetic/degrees.py +28 -0
- maxframe/dataframe/arithmetic/docstring.py +416 -0
- maxframe/dataframe/arithmetic/dot.py +237 -0
- maxframe/dataframe/arithmetic/equal.py +58 -0
- maxframe/dataframe/arithmetic/exp.py +28 -0
- maxframe/dataframe/arithmetic/exp2.py +28 -0
- maxframe/dataframe/arithmetic/expm1.py +28 -0
- maxframe/dataframe/arithmetic/floor.py +28 -0
- maxframe/dataframe/arithmetic/floordiv.py +64 -0
- maxframe/dataframe/arithmetic/greater.py +59 -0
- maxframe/dataframe/arithmetic/greater_equal.py +59 -0
- maxframe/dataframe/arithmetic/invert.py +33 -0
- maxframe/dataframe/arithmetic/is_ufuncs.py +62 -0
- maxframe/dataframe/arithmetic/less.py +57 -0
- maxframe/dataframe/arithmetic/less_equal.py +59 -0
- maxframe/dataframe/arithmetic/log.py +28 -0
- maxframe/dataframe/arithmetic/log10.py +28 -0
- maxframe/dataframe/arithmetic/log2.py +28 -0
- maxframe/dataframe/arithmetic/maximum.py +33 -0
- maxframe/dataframe/arithmetic/minimum.py +33 -0
- maxframe/dataframe/arithmetic/mod.py +60 -0
- maxframe/dataframe/arithmetic/multiply.py +60 -0
- maxframe/dataframe/arithmetic/negative.py +33 -0
- maxframe/dataframe/arithmetic/not_equal.py +58 -0
- maxframe/dataframe/arithmetic/power.py +68 -0
- maxframe/dataframe/arithmetic/radians.py +28 -0
- maxframe/dataframe/arithmetic/round.py +144 -0
- maxframe/dataframe/arithmetic/sin.py +28 -0
- maxframe/dataframe/arithmetic/sinh.py +28 -0
- maxframe/dataframe/arithmetic/sqrt.py +28 -0
- maxframe/dataframe/arithmetic/subtract.py +64 -0
- maxframe/dataframe/arithmetic/tan.py +28 -0
- maxframe/dataframe/arithmetic/tanh.py +28 -0
- maxframe/dataframe/arithmetic/tests/__init__.py +13 -0
- maxframe/dataframe/arithmetic/tests/test_arithmetic.py +747 -0
- maxframe/dataframe/arithmetic/truediv.py +64 -0
- maxframe/dataframe/arithmetic/trunc.py +28 -0
- maxframe/dataframe/core.py +2386 -0
- maxframe/dataframe/datasource/__init__.py +33 -0
- maxframe/dataframe/datasource/core.py +112 -0
- maxframe/dataframe/datasource/dataframe.py +59 -0
- maxframe/dataframe/datasource/date_range.py +512 -0
- maxframe/dataframe/datasource/direct.py +57 -0
- maxframe/dataframe/datasource/from_dict.py +124 -0
- maxframe/dataframe/datasource/from_index.py +58 -0
- maxframe/dataframe/datasource/from_records.py +191 -0
- maxframe/dataframe/datasource/from_tensor.py +503 -0
- maxframe/dataframe/datasource/index.py +117 -0
- maxframe/dataframe/datasource/read_csv.py +534 -0
- maxframe/dataframe/datasource/read_odps_query.py +536 -0
- maxframe/dataframe/datasource/read_odps_table.py +295 -0
- maxframe/dataframe/datasource/read_parquet.py +278 -0
- maxframe/dataframe/datasource/series.py +55 -0
- maxframe/dataframe/datasource/tests/__init__.py +13 -0
- maxframe/dataframe/datasource/tests/test_datasource.py +663 -0
- maxframe/dataframe/datastore/__init__.py +41 -0
- maxframe/dataframe/datastore/core.py +28 -0
- maxframe/dataframe/datastore/direct.py +268 -0
- maxframe/dataframe/datastore/tests/__init__.py +13 -0
- maxframe/dataframe/datastore/tests/test_to_odps.py +99 -0
- maxframe/dataframe/datastore/to_csv.py +219 -0
- maxframe/dataframe/datastore/to_json.py +215 -0
- maxframe/dataframe/datastore/to_odps.py +285 -0
- maxframe/dataframe/datastore/to_parquet.py +121 -0
- maxframe/dataframe/extensions/__init__.py +70 -0
- maxframe/dataframe/extensions/accessor.py +35 -0
- maxframe/dataframe/extensions/apply_chunk.py +733 -0
- maxframe/dataframe/extensions/cartesian_chunk.py +153 -0
- maxframe/dataframe/extensions/collect_kv.py +126 -0
- maxframe/dataframe/extensions/extract_kv.py +177 -0
- maxframe/dataframe/extensions/flatjson.py +133 -0
- maxframe/dataframe/extensions/flatmap.py +329 -0
- maxframe/dataframe/extensions/map_reduce.py +263 -0
- maxframe/dataframe/extensions/rebalance.py +62 -0
- maxframe/dataframe/extensions/reshuffle.py +83 -0
- maxframe/dataframe/extensions/tests/__init__.py +13 -0
- maxframe/dataframe/extensions/tests/test_apply_chunk.py +194 -0
- maxframe/dataframe/extensions/tests/test_extensions.py +198 -0
- maxframe/dataframe/extensions/tests/test_map_reduce.py +135 -0
- maxframe/dataframe/fetch/__init__.py +15 -0
- maxframe/dataframe/fetch/core.py +97 -0
- maxframe/dataframe/groupby/__init__.py +105 -0
- maxframe/dataframe/groupby/aggregation.py +485 -0
- maxframe/dataframe/groupby/apply.py +235 -0
- maxframe/dataframe/groupby/apply_chunk.py +407 -0
- maxframe/dataframe/groupby/core.py +342 -0
- maxframe/dataframe/groupby/cum.py +102 -0
- maxframe/dataframe/groupby/expanding.py +264 -0
- maxframe/dataframe/groupby/extensions.py +26 -0
- maxframe/dataframe/groupby/fill.py +149 -0
- maxframe/dataframe/groupby/getitem.py +105 -0
- maxframe/dataframe/groupby/head.py +115 -0
- maxframe/dataframe/groupby/rank.py +136 -0
- maxframe/dataframe/groupby/rolling.py +206 -0
- maxframe/dataframe/groupby/sample.py +214 -0
- maxframe/dataframe/groupby/shift.py +114 -0
- maxframe/dataframe/groupby/tests/__init__.py +13 -0
- maxframe/dataframe/groupby/tests/test_groupby.py +373 -0
- maxframe/dataframe/groupby/transform.py +264 -0
- maxframe/dataframe/indexing/__init__.py +104 -0
- maxframe/dataframe/indexing/add_prefix_suffix.py +110 -0
- maxframe/dataframe/indexing/align.py +350 -0
- maxframe/dataframe/indexing/at.py +83 -0
- maxframe/dataframe/indexing/droplevel.py +195 -0
- maxframe/dataframe/indexing/filter.py +169 -0
- maxframe/dataframe/indexing/get_level_values.py +76 -0
- maxframe/dataframe/indexing/getitem.py +205 -0
- maxframe/dataframe/indexing/iat.py +82 -0
- maxframe/dataframe/indexing/iloc.py +711 -0
- maxframe/dataframe/indexing/insert.py +118 -0
- maxframe/dataframe/indexing/loc.py +694 -0
- maxframe/dataframe/indexing/reindex.py +541 -0
- maxframe/dataframe/indexing/rename.py +445 -0
- maxframe/dataframe/indexing/rename_axis.py +217 -0
- maxframe/dataframe/indexing/reorder_levels.py +143 -0
- maxframe/dataframe/indexing/reset_index.py +427 -0
- maxframe/dataframe/indexing/sample.py +232 -0
- maxframe/dataframe/indexing/set_axis.py +197 -0
- maxframe/dataframe/indexing/set_index.py +128 -0
- maxframe/dataframe/indexing/setitem.py +133 -0
- maxframe/dataframe/indexing/swaplevel.py +185 -0
- maxframe/dataframe/indexing/take.py +99 -0
- maxframe/dataframe/indexing/tests/__init__.py +13 -0
- maxframe/dataframe/indexing/tests/test_indexing.py +488 -0
- maxframe/dataframe/indexing/truncate.py +140 -0
- maxframe/dataframe/indexing/where.py +300 -0
- maxframe/dataframe/indexing/xs.py +148 -0
- maxframe/dataframe/initializer.py +298 -0
- maxframe/dataframe/merge/__init__.py +53 -0
- maxframe/dataframe/merge/append.py +120 -0
- maxframe/dataframe/merge/combine.py +244 -0
- maxframe/dataframe/merge/combine_first.py +120 -0
- maxframe/dataframe/merge/compare.py +387 -0
- maxframe/dataframe/merge/concat.py +500 -0
- maxframe/dataframe/merge/merge.py +806 -0
- maxframe/dataframe/merge/tests/__init__.py +13 -0
- maxframe/dataframe/merge/tests/test_merge.py +390 -0
- maxframe/dataframe/merge/update.py +271 -0
- maxframe/dataframe/misc/__init__.py +145 -0
- maxframe/dataframe/misc/_duplicate.py +56 -0
- maxframe/dataframe/misc/apply.py +730 -0
- maxframe/dataframe/misc/astype.py +237 -0
- maxframe/dataframe/misc/case_when.py +145 -0
- maxframe/dataframe/misc/check_monotonic.py +84 -0
- maxframe/dataframe/misc/check_unique.py +82 -0
- maxframe/dataframe/misc/clip.py +145 -0
- maxframe/dataframe/misc/cut.py +386 -0
- maxframe/dataframe/misc/describe.py +278 -0
- maxframe/dataframe/misc/diff.py +210 -0
- maxframe/dataframe/misc/drop.py +473 -0
- maxframe/dataframe/misc/drop_duplicates.py +251 -0
- maxframe/dataframe/misc/duplicated.py +292 -0
- maxframe/dataframe/misc/eval.py +730 -0
- maxframe/dataframe/misc/explode.py +171 -0
- maxframe/dataframe/misc/factorize.py +160 -0
- maxframe/dataframe/misc/get_dummies.py +241 -0
- maxframe/dataframe/misc/infer_dtypes.py +251 -0
- maxframe/dataframe/misc/isin.py +220 -0
- maxframe/dataframe/misc/map.py +360 -0
- maxframe/dataframe/misc/memory_usage.py +248 -0
- maxframe/dataframe/misc/pct_change.py +68 -0
- maxframe/dataframe/misc/qcut.py +104 -0
- maxframe/dataframe/misc/rechunk.py +59 -0
- maxframe/dataframe/misc/repeat.py +159 -0
- maxframe/dataframe/misc/select_dtypes.py +104 -0
- maxframe/dataframe/misc/shift.py +259 -0
- maxframe/dataframe/misc/tests/__init__.py +13 -0
- maxframe/dataframe/misc/tests/test_misc.py +649 -0
- maxframe/dataframe/misc/to_numeric.py +181 -0
- maxframe/dataframe/misc/transform.py +346 -0
- maxframe/dataframe/misc/transpose.py +148 -0
- maxframe/dataframe/misc/valid_index.py +115 -0
- maxframe/dataframe/misc/value_counts.py +206 -0
- maxframe/dataframe/missing/__init__.py +53 -0
- maxframe/dataframe/missing/checkna.py +231 -0
- maxframe/dataframe/missing/dropna.py +294 -0
- maxframe/dataframe/missing/fillna.py +283 -0
- maxframe/dataframe/missing/replace.py +446 -0
- maxframe/dataframe/missing/tests/__init__.py +13 -0
- maxframe/dataframe/missing/tests/test_missing.py +90 -0
- maxframe/dataframe/operators.py +231 -0
- maxframe/dataframe/reduction/__init__.py +129 -0
- maxframe/dataframe/reduction/aggregation.py +502 -0
- maxframe/dataframe/reduction/all.py +78 -0
- maxframe/dataframe/reduction/any.py +78 -0
- maxframe/dataframe/reduction/argmax.py +103 -0
- maxframe/dataframe/reduction/argmin.py +103 -0
- maxframe/dataframe/reduction/core.py +923 -0
- maxframe/dataframe/reduction/count.py +63 -0
- maxframe/dataframe/reduction/cov.py +166 -0
- maxframe/dataframe/reduction/cummax.py +30 -0
- maxframe/dataframe/reduction/cummin.py +30 -0
- maxframe/dataframe/reduction/cumprod.py +30 -0
- maxframe/dataframe/reduction/cumsum.py +30 -0
- maxframe/dataframe/reduction/custom_reduction.py +42 -0
- maxframe/dataframe/reduction/idxmax.py +185 -0
- maxframe/dataframe/reduction/idxmin.py +185 -0
- maxframe/dataframe/reduction/kurtosis.py +111 -0
- maxframe/dataframe/reduction/max.py +65 -0
- maxframe/dataframe/reduction/mean.py +63 -0
- maxframe/dataframe/reduction/median.py +56 -0
- maxframe/dataframe/reduction/min.py +65 -0
- maxframe/dataframe/reduction/mode.py +190 -0
- maxframe/dataframe/reduction/nunique.py +149 -0
- maxframe/dataframe/reduction/prod.py +81 -0
- maxframe/dataframe/reduction/reduction_size.py +36 -0
- maxframe/dataframe/reduction/sem.py +73 -0
- maxframe/dataframe/reduction/skew.py +93 -0
- maxframe/dataframe/reduction/std.py +53 -0
- maxframe/dataframe/reduction/str_concat.py +51 -0
- maxframe/dataframe/reduction/sum.py +81 -0
- maxframe/dataframe/reduction/tests/__init__.py +13 -0
- maxframe/dataframe/reduction/tests/test_reduction.py +598 -0
- maxframe/dataframe/reduction/unique.py +153 -0
- maxframe/dataframe/reduction/var.py +76 -0
- maxframe/dataframe/reshape/__init__.py +38 -0
- maxframe/dataframe/reshape/melt.py +169 -0
- maxframe/dataframe/reshape/pivot.py +233 -0
- maxframe/dataframe/reshape/pivot_table.py +275 -0
- maxframe/dataframe/reshape/stack.py +240 -0
- maxframe/dataframe/reshape/unstack.py +114 -0
- maxframe/dataframe/sort/__init__.py +49 -0
- maxframe/dataframe/sort/argsort.py +68 -0
- maxframe/dataframe/sort/core.py +37 -0
- maxframe/dataframe/sort/nlargest.py +238 -0
- maxframe/dataframe/sort/nsmallest.py +228 -0
- maxframe/dataframe/sort/rank.py +147 -0
- maxframe/dataframe/sort/sort_index.py +153 -0
- maxframe/dataframe/sort/sort_values.py +308 -0
- maxframe/dataframe/sort/tests/__init__.py +13 -0
- maxframe/dataframe/sort/tests/test_sort.py +85 -0
- maxframe/dataframe/statistics/__init__.py +33 -0
- maxframe/dataframe/statistics/corr.py +284 -0
- maxframe/dataframe/statistics/quantile.py +338 -0
- maxframe/dataframe/statistics/tests/__init__.py +13 -0
- maxframe/dataframe/statistics/tests/test_statistics.py +82 -0
- maxframe/dataframe/tests/__init__.py +13 -0
- maxframe/dataframe/tests/test_initializer.py +60 -0
- maxframe/dataframe/tests/test_typing.py +119 -0
- maxframe/dataframe/tests/test_utils.py +169 -0
- maxframe/dataframe/tseries/__init__.py +32 -0
- maxframe/dataframe/tseries/at_time.py +61 -0
- maxframe/dataframe/tseries/between_time.py +122 -0
- maxframe/dataframe/tseries/tests/__init__.py +13 -0
- maxframe/dataframe/tseries/tests/test_tseries.py +30 -0
- maxframe/dataframe/tseries/to_datetime.py +299 -0
- maxframe/dataframe/typing_.py +196 -0
- maxframe/dataframe/ufunc/__init__.py +27 -0
- maxframe/dataframe/ufunc/tensor.py +54 -0
- maxframe/dataframe/ufunc/ufunc.py +53 -0
- maxframe/dataframe/utils.py +1728 -0
- maxframe/dataframe/window/__init__.py +29 -0
- maxframe/dataframe/window/aggregation.py +100 -0
- maxframe/dataframe/window/core.py +82 -0
- maxframe/dataframe/window/ewm.py +247 -0
- maxframe/dataframe/window/expanding.py +151 -0
- maxframe/dataframe/window/rolling.py +389 -0
- maxframe/dataframe/window/tests/__init__.py +13 -0
- maxframe/dataframe/window/tests/test_ewm.py +70 -0
- maxframe/dataframe/window/tests/test_expanding.py +60 -0
- maxframe/dataframe/window/tests/test_rolling.py +57 -0
- maxframe/env.py +37 -0
- maxframe/errors.py +52 -0
- maxframe/extension.py +131 -0
- maxframe/io/__init__.py +13 -0
- maxframe/io/objects/__init__.py +24 -0
- maxframe/io/objects/core.py +156 -0
- maxframe/io/objects/tensor.py +133 -0
- maxframe/io/objects/tests/__init__.py +13 -0
- maxframe/io/objects/tests/test_object_io.py +85 -0
- maxframe/io/odpsio/__init__.py +24 -0
- maxframe/io/odpsio/arrow.py +161 -0
- maxframe/io/odpsio/schema.py +533 -0
- maxframe/io/odpsio/tableio.py +736 -0
- maxframe/io/odpsio/tests/__init__.py +13 -0
- maxframe/io/odpsio/tests/test_arrow.py +132 -0
- maxframe/io/odpsio/tests/test_schema.py +582 -0
- maxframe/io/odpsio/tests/test_tableio.py +205 -0
- maxframe/io/odpsio/tests/test_volumeio.py +75 -0
- maxframe/io/odpsio/volumeio.py +102 -0
- maxframe/learn/__init__.py +25 -0
- maxframe/learn/cluster/__init__.py +15 -0
- maxframe/learn/cluster/_kmeans.py +782 -0
- maxframe/learn/contrib/__init__.py +17 -0
- maxframe/learn/contrib/graph/__init__.py +15 -0
- maxframe/learn/contrib/graph/connected_components.py +216 -0
- maxframe/learn/contrib/graph/tests/__init__.py +13 -0
- maxframe/learn/contrib/graph/tests/test_connected_components.py +53 -0
- 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/__init__.py +17 -0
- maxframe/learn/contrib/llm/core.py +105 -0
- maxframe/learn/contrib/llm/deploy/__init__.py +13 -0
- maxframe/learn/contrib/llm/deploy/config.py +221 -0
- maxframe/learn/contrib/llm/deploy/core.py +247 -0
- maxframe/learn/contrib/llm/deploy/framework.py +35 -0
- maxframe/learn/contrib/llm/deploy/loader.py +360 -0
- maxframe/learn/contrib/llm/deploy/tests/__init__.py +13 -0
- maxframe/learn/contrib/llm/deploy/tests/test_register_models.py +359 -0
- maxframe/learn/contrib/llm/models/__init__.py +16 -0
- maxframe/learn/contrib/llm/models/dashscope.py +114 -0
- maxframe/learn/contrib/llm/models/managed.py +119 -0
- maxframe/learn/contrib/llm/models/openai.py +72 -0
- maxframe/learn/contrib/llm/multi_modal.py +135 -0
- maxframe/learn/contrib/llm/tests/__init__.py +13 -0
- maxframe/learn/contrib/llm/tests/test_core.py +34 -0
- maxframe/learn/contrib/llm/tests/test_openai.py +187 -0
- maxframe/learn/contrib/llm/tests/test_text_gen.py +155 -0
- maxframe/learn/contrib/llm/text.py +608 -0
- maxframe/learn/contrib/models.py +109 -0
- maxframe/learn/contrib/pytorch/__init__.py +16 -0
- maxframe/learn/contrib/pytorch/run_function.py +110 -0
- maxframe/learn/contrib/pytorch/run_script.py +102 -0
- maxframe/learn/contrib/pytorch/tests/__init__.py +13 -0
- maxframe/learn/contrib/pytorch/tests/test_pytorch.py +42 -0
- maxframe/learn/contrib/utils.py +108 -0
- maxframe/learn/contrib/xgboost/__init__.py +33 -0
- maxframe/learn/contrib/xgboost/callback.py +86 -0
- maxframe/learn/contrib/xgboost/classifier.py +119 -0
- maxframe/learn/contrib/xgboost/core.py +469 -0
- maxframe/learn/contrib/xgboost/dmatrix.py +157 -0
- maxframe/learn/contrib/xgboost/predict.py +133 -0
- maxframe/learn/contrib/xgboost/regressor.py +91 -0
- maxframe/learn/contrib/xgboost/tests/__init__.py +13 -0
- maxframe/learn/contrib/xgboost/tests/test_callback.py +41 -0
- maxframe/learn/contrib/xgboost/tests/test_core.py +43 -0
- maxframe/learn/contrib/xgboost/train.py +181 -0
- maxframe/learn/core.py +344 -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 +220 -0
- maxframe/learn/linear_model/_lin_reg.py +175 -0
- maxframe/learn/metrics/__init__.py +31 -0
- maxframe/learn/metrics/_check_targets.py +95 -0
- maxframe/learn/metrics/_classification.py +1266 -0
- maxframe/learn/metrics/_ranking.py +477 -0
- maxframe/learn/metrics/_regression.py +256 -0
- maxframe/learn/metrics/_scorer.py +60 -0
- maxframe/learn/metrics/pairwise/__init__.py +21 -0
- maxframe/learn/metrics/pairwise/core.py +77 -0
- maxframe/learn/metrics/pairwise/cosine.py +115 -0
- maxframe/learn/metrics/pairwise/euclidean.py +176 -0
- maxframe/learn/metrics/pairwise/haversine.py +96 -0
- maxframe/learn/metrics/pairwise/manhattan.py +80 -0
- maxframe/learn/metrics/pairwise/pairwise.py +127 -0
- maxframe/learn/metrics/pairwise/pairwise_distances_topk.py +121 -0
- maxframe/learn/metrics/pairwise/rbf_kernel.py +51 -0
- maxframe/learn/metrics/tests/__init__.py +13 -0
- maxframe/learn/metrics/tests/test_scorer.py +26 -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 +401 -0
- maxframe/learn/preprocessing/_data/normalize.py +127 -0
- maxframe/learn/preprocessing/_data/standard_scaler.py +512 -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 +20 -0
- maxframe/learn/utils/_encode.py +312 -0
- maxframe/learn/utils/checks.py +160 -0
- maxframe/learn/utils/core.py +121 -0
- maxframe/learn/utils/extmath.py +246 -0
- maxframe/learn/utils/multiclass.py +292 -0
- maxframe/learn/utils/odpsio.py +262 -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 +13 -0
- maxframe/lib/aio/__init__.py +27 -0
- maxframe/lib/aio/_runners.py +162 -0
- maxframe/lib/aio/_threads.py +35 -0
- maxframe/lib/aio/base.py +82 -0
- maxframe/lib/aio/file.py +85 -0
- maxframe/lib/aio/isolation.py +100 -0
- maxframe/lib/aio/lru.py +242 -0
- maxframe/lib/aio/parallelism.py +37 -0
- maxframe/lib/aio/tests/__init__.py +13 -0
- maxframe/lib/aio/tests/test_aio_file.py +55 -0
- maxframe/lib/compat.py +185 -0
- maxframe/lib/compression.py +55 -0
- maxframe/lib/cython/__init__.py +13 -0
- maxframe/lib/cython/libcpp.pxd +30 -0
- maxframe/lib/dtypes_extension/__init__.py +30 -0
- maxframe/lib/dtypes_extension/_fake_arrow_dtype.py +609 -0
- maxframe/lib/dtypes_extension/blob.py +304 -0
- maxframe/lib/dtypes_extension/dtypes.py +106 -0
- maxframe/lib/dtypes_extension/tests/__init__.py +13 -0
- maxframe/lib/dtypes_extension/tests/test_blob.py +88 -0
- maxframe/lib/dtypes_extension/tests/test_dtypes.py +63 -0
- maxframe/lib/dtypes_extension/tests/test_fake_arrow_dtype.py +75 -0
- maxframe/lib/filesystem/__init__.py +22 -0
- maxframe/lib/filesystem/_glob.py +173 -0
- maxframe/lib/filesystem/_oss_lib/__init__.py +13 -0
- maxframe/lib/filesystem/_oss_lib/common.py +274 -0
- maxframe/lib/filesystem/_oss_lib/glob.py +147 -0
- maxframe/lib/filesystem/_oss_lib/handle.py +180 -0
- maxframe/lib/filesystem/arrow.py +240 -0
- maxframe/lib/filesystem/base.py +327 -0
- maxframe/lib/filesystem/core.py +95 -0
- maxframe/lib/filesystem/fshandler.py +136 -0
- maxframe/lib/filesystem/fsmap.py +164 -0
- maxframe/lib/filesystem/hdfs.py +31 -0
- maxframe/lib/filesystem/local.py +120 -0
- maxframe/lib/filesystem/oss.py +283 -0
- maxframe/lib/filesystem/tests/__init__.py +13 -0
- maxframe/lib/filesystem/tests/test_filesystem.py +205 -0
- maxframe/lib/filesystem/tests/test_fshandler.py +281 -0
- maxframe/lib/filesystem/tests/test_oss.py +220 -0
- maxframe/lib/functools_compat.py +81 -0
- maxframe/lib/mmh3.cp312-win32.pyd +0 -0
- maxframe/lib/mmh3.pyi +43 -0
- maxframe/lib/mmh3_src/MurmurHash3.cpp +339 -0
- maxframe/lib/mmh3_src/MurmurHash3.h +43 -0
- maxframe/lib/mmh3_src/mmh3module.cpp +387 -0
- maxframe/lib/sparse/__init__.py +856 -0
- maxframe/lib/sparse/array.py +1616 -0
- maxframe/lib/sparse/core.py +90 -0
- maxframe/lib/sparse/linalg.py +31 -0
- maxframe/lib/sparse/matrix.py +244 -0
- maxframe/lib/sparse/tests/__init__.py +13 -0
- maxframe/lib/sparse/tests/test_sparse.py +476 -0
- maxframe/lib/sparse/vector.py +148 -0
- maxframe/lib/tblib/LICENSE +20 -0
- maxframe/lib/tblib/__init__.py +327 -0
- maxframe/lib/tblib/cpython.py +83 -0
- maxframe/lib/tblib/decorators.py +44 -0
- maxframe/lib/tblib/pickling_support.py +90 -0
- maxframe/lib/tests/__init__.py +13 -0
- maxframe/lib/tests/test_wrapped_pickle.py +51 -0
- maxframe/lib/version.py +620 -0
- maxframe/lib/wrapped_pickle.py +177 -0
- maxframe/mixin.py +157 -0
- maxframe/opcodes.py +654 -0
- maxframe/protocol.py +611 -0
- maxframe/remote/__init__.py +18 -0
- maxframe/remote/core.py +212 -0
- maxframe/remote/run_script.py +124 -0
- maxframe/serialization/__init__.py +39 -0
- maxframe/serialization/arrow.py +107 -0
- maxframe/serialization/blob.py +32 -0
- maxframe/serialization/core.cp312-win32.pyd +0 -0
- maxframe/serialization/core.pxd +50 -0
- maxframe/serialization/core.pyi +66 -0
- maxframe/serialization/core.pyx +1282 -0
- maxframe/serialization/exception.py +90 -0
- maxframe/serialization/maxframe_objects.py +39 -0
- maxframe/serialization/numpy.py +110 -0
- maxframe/serialization/pandas.py +278 -0
- maxframe/serialization/scipy.py +71 -0
- maxframe/serialization/serializables/__init__.py +55 -0
- maxframe/serialization/serializables/core.py +469 -0
- maxframe/serialization/serializables/field.py +624 -0
- maxframe/serialization/serializables/field_type.py +592 -0
- maxframe/serialization/serializables/tests/__init__.py +13 -0
- maxframe/serialization/serializables/tests/test_field_type.py +119 -0
- maxframe/serialization/serializables/tests/test_serializable.py +313 -0
- maxframe/serialization/tests/__init__.py +13 -0
- maxframe/serialization/tests/test_serial.py +516 -0
- maxframe/session.py +1250 -0
- maxframe/sperunner.py +165 -0
- maxframe/tensor/__init__.py +325 -0
- maxframe/tensor/arithmetic/__init__.py +322 -0
- maxframe/tensor/arithmetic/abs.py +66 -0
- maxframe/tensor/arithmetic/absolute.py +66 -0
- maxframe/tensor/arithmetic/add.py +112 -0
- maxframe/tensor/arithmetic/angle.py +70 -0
- maxframe/tensor/arithmetic/arccos.py +101 -0
- maxframe/tensor/arithmetic/arccosh.py +89 -0
- maxframe/tensor/arithmetic/arcsin.py +92 -0
- maxframe/tensor/arithmetic/arcsinh.py +84 -0
- maxframe/tensor/arithmetic/arctan.py +104 -0
- maxframe/tensor/arithmetic/arctan2.py +126 -0
- maxframe/tensor/arithmetic/arctanh.py +84 -0
- maxframe/tensor/arithmetic/around.py +112 -0
- maxframe/tensor/arithmetic/bitand.py +93 -0
- maxframe/tensor/arithmetic/bitor.py +100 -0
- maxframe/tensor/arithmetic/bitxor.py +93 -0
- maxframe/tensor/arithmetic/cbrt.py +64 -0
- maxframe/tensor/arithmetic/ceil.py +69 -0
- maxframe/tensor/arithmetic/clip.py +165 -0
- maxframe/tensor/arithmetic/conj.py +72 -0
- maxframe/tensor/arithmetic/copysign.py +76 -0
- maxframe/tensor/arithmetic/core.py +546 -0
- maxframe/tensor/arithmetic/cos.py +83 -0
- maxframe/tensor/arithmetic/cosh.py +70 -0
- maxframe/tensor/arithmetic/deg2rad.py +70 -0
- maxframe/tensor/arithmetic/degrees.py +75 -0
- maxframe/tensor/arithmetic/divide.py +112 -0
- maxframe/tensor/arithmetic/equal.py +74 -0
- maxframe/tensor/arithmetic/exp.py +104 -0
- maxframe/tensor/arithmetic/exp2.py +65 -0
- maxframe/tensor/arithmetic/expm1.py +77 -0
- maxframe/tensor/arithmetic/fabs.py +72 -0
- maxframe/tensor/arithmetic/fix.py +67 -0
- maxframe/tensor/arithmetic/float_power.py +101 -0
- maxframe/tensor/arithmetic/floor.py +75 -0
- maxframe/tensor/arithmetic/floordiv.py +92 -0
- maxframe/tensor/arithmetic/fmax.py +103 -0
- maxframe/tensor/arithmetic/fmin.py +104 -0
- maxframe/tensor/arithmetic/fmod.py +97 -0
- maxframe/tensor/arithmetic/frexp.py +96 -0
- maxframe/tensor/arithmetic/greater.py +75 -0
- maxframe/tensor/arithmetic/greater_equal.py +67 -0
- maxframe/tensor/arithmetic/hypot.py +75 -0
- maxframe/tensor/arithmetic/i0.py +87 -0
- maxframe/tensor/arithmetic/imag.py +65 -0
- maxframe/tensor/arithmetic/invert.py +108 -0
- maxframe/tensor/arithmetic/isclose.py +114 -0
- maxframe/tensor/arithmetic/iscomplex.py +62 -0
- maxframe/tensor/arithmetic/iscomplexobj.py +53 -0
- maxframe/tensor/arithmetic/isfinite.py +104 -0
- maxframe/tensor/arithmetic/isinf.py +101 -0
- maxframe/tensor/arithmetic/isnan.py +80 -0
- maxframe/tensor/arithmetic/isreal.py +61 -0
- maxframe/tensor/arithmetic/ldexp.py +97 -0
- maxframe/tensor/arithmetic/less.py +67 -0
- maxframe/tensor/arithmetic/less_equal.py +67 -0
- maxframe/tensor/arithmetic/log.py +90 -0
- maxframe/tensor/arithmetic/log10.py +83 -0
- maxframe/tensor/arithmetic/log1p.py +93 -0
- maxframe/tensor/arithmetic/log2.py +83 -0
- maxframe/tensor/arithmetic/logaddexp.py +78 -0
- maxframe/tensor/arithmetic/logaddexp2.py +76 -0
- maxframe/tensor/arithmetic/logical_and.py +79 -0
- maxframe/tensor/arithmetic/logical_not.py +72 -0
- maxframe/tensor/arithmetic/logical_or.py +80 -0
- maxframe/tensor/arithmetic/logical_xor.py +86 -0
- maxframe/tensor/arithmetic/lshift.py +80 -0
- maxframe/tensor/arithmetic/maximum.py +106 -0
- maxframe/tensor/arithmetic/minimum.py +106 -0
- maxframe/tensor/arithmetic/mod.py +102 -0
- maxframe/tensor/arithmetic/modf.py +87 -0
- maxframe/tensor/arithmetic/multiply.py +114 -0
- maxframe/tensor/arithmetic/nan_to_num.py +97 -0
- maxframe/tensor/arithmetic/negative.py +63 -0
- maxframe/tensor/arithmetic/nextafter.py +66 -0
- maxframe/tensor/arithmetic/not_equal.py +70 -0
- maxframe/tensor/arithmetic/positive.py +45 -0
- maxframe/tensor/arithmetic/power.py +104 -0
- maxframe/tensor/arithmetic/rad2deg.py +69 -0
- maxframe/tensor/arithmetic/radians.py +75 -0
- maxframe/tensor/arithmetic/real.py +68 -0
- maxframe/tensor/arithmetic/reciprocal.py +78 -0
- maxframe/tensor/arithmetic/rint.py +66 -0
- maxframe/tensor/arithmetic/rshift.py +79 -0
- maxframe/tensor/arithmetic/setimag.py +27 -0
- maxframe/tensor/arithmetic/setreal.py +27 -0
- maxframe/tensor/arithmetic/sign.py +79 -0
- maxframe/tensor/arithmetic/signbit.py +63 -0
- maxframe/tensor/arithmetic/sin.py +96 -0
- maxframe/tensor/arithmetic/sinc.py +100 -0
- maxframe/tensor/arithmetic/sinh.py +91 -0
- maxframe/tensor/arithmetic/spacing.py +70 -0
- maxframe/tensor/arithmetic/sqrt.py +79 -0
- maxframe/tensor/arithmetic/square.py +67 -0
- maxframe/tensor/arithmetic/subtract.py +83 -0
- maxframe/tensor/arithmetic/tan.py +86 -0
- maxframe/tensor/arithmetic/tanh.py +90 -0
- maxframe/tensor/arithmetic/tests/__init__.py +13 -0
- maxframe/tensor/arithmetic/tests/test_arithmetic.py +449 -0
- maxframe/tensor/arithmetic/truediv.py +102 -0
- maxframe/tensor/arithmetic/trunc.py +70 -0
- maxframe/tensor/arithmetic/utils.py +91 -0
- maxframe/tensor/array_utils.py +164 -0
- maxframe/tensor/core.py +597 -0
- maxframe/tensor/datasource/__init__.py +40 -0
- maxframe/tensor/datasource/arange.py +154 -0
- maxframe/tensor/datasource/array.py +399 -0
- maxframe/tensor/datasource/core.py +114 -0
- maxframe/tensor/datasource/diag.py +140 -0
- maxframe/tensor/datasource/diagflat.py +69 -0
- maxframe/tensor/datasource/empty.py +167 -0
- maxframe/tensor/datasource/eye.py +95 -0
- maxframe/tensor/datasource/from_dataframe.py +68 -0
- maxframe/tensor/datasource/from_dense.py +37 -0
- maxframe/tensor/datasource/from_sparse.py +45 -0
- maxframe/tensor/datasource/full.py +184 -0
- 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 +178 -0
- maxframe/tensor/datasource/scalar.py +40 -0
- maxframe/tensor/datasource/tests/__init__.py +13 -0
- maxframe/tensor/datasource/tests/test_datasource.py +310 -0
- maxframe/tensor/datasource/tri_array.py +107 -0
- maxframe/tensor/datasource/zeros.py +192 -0
- maxframe/tensor/extensions/__init__.py +33 -0
- maxframe/tensor/extensions/accessor.py +25 -0
- maxframe/tensor/extensions/apply_chunk.py +137 -0
- maxframe/tensor/extensions/rebalance.py +65 -0
- maxframe/tensor/fetch/__init__.py +15 -0
- maxframe/tensor/fetch/core.py +54 -0
- maxframe/tensor/fft/__init__.py +32 -0
- maxframe/tensor/fft/core.py +168 -0
- maxframe/tensor/fft/fft.py +112 -0
- maxframe/tensor/fft/fft2.py +118 -0
- maxframe/tensor/fft/fftfreq.py +80 -0
- maxframe/tensor/fft/fftn.py +123 -0
- maxframe/tensor/fft/fftshift.py +79 -0
- maxframe/tensor/fft/hfft.py +112 -0
- maxframe/tensor/fft/ifft.py +114 -0
- maxframe/tensor/fft/ifft2.py +115 -0
- maxframe/tensor/fft/ifftn.py +123 -0
- maxframe/tensor/fft/ifftshift.py +73 -0
- maxframe/tensor/fft/ihfft.py +93 -0
- maxframe/tensor/fft/irfft.py +118 -0
- maxframe/tensor/fft/irfft2.py +62 -0
- maxframe/tensor/fft/irfftn.py +114 -0
- maxframe/tensor/fft/rfft.py +116 -0
- maxframe/tensor/fft/rfft2.py +63 -0
- maxframe/tensor/fft/rfftfreq.py +87 -0
- maxframe/tensor/fft/rfftn.py +113 -0
- maxframe/tensor/indexing/__init__.py +47 -0
- maxframe/tensor/indexing/choose.py +198 -0
- maxframe/tensor/indexing/compress.py +122 -0
- maxframe/tensor/indexing/core.py +190 -0
- maxframe/tensor/indexing/extract.py +69 -0
- maxframe/tensor/indexing/fill_diagonal.py +180 -0
- maxframe/tensor/indexing/flatnonzero.py +58 -0
- maxframe/tensor/indexing/getitem.py +144 -0
- maxframe/tensor/indexing/nonzero.py +118 -0
- maxframe/tensor/indexing/setitem.py +142 -0
- maxframe/tensor/indexing/slice.py +32 -0
- maxframe/tensor/indexing/take.py +128 -0
- maxframe/tensor/indexing/tests/__init__.py +13 -0
- maxframe/tensor/indexing/tests/test_indexing.py +232 -0
- maxframe/tensor/indexing/unravel_index.py +103 -0
- maxframe/tensor/lib/__init__.py +16 -0
- maxframe/tensor/lib/index_tricks.py +404 -0
- maxframe/tensor/linalg/__init__.py +43 -0
- maxframe/tensor/linalg/_einsumfunc.py +1025 -0
- maxframe/tensor/linalg/cholesky.py +117 -0
- maxframe/tensor/linalg/dot.py +145 -0
- maxframe/tensor/linalg/einsum.py +339 -0
- maxframe/tensor/linalg/inner.py +36 -0
- maxframe/tensor/linalg/inv.py +83 -0
- maxframe/tensor/linalg/lstsq.py +100 -0
- maxframe/tensor/linalg/lu.py +115 -0
- maxframe/tensor/linalg/matmul.py +225 -0
- maxframe/tensor/linalg/matrix_norm.py +75 -0
- maxframe/tensor/linalg/norm.py +249 -0
- maxframe/tensor/linalg/qr.py +124 -0
- maxframe/tensor/linalg/solve.py +72 -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/linalg/vector_norm.py +113 -0
- maxframe/tensor/merge/__init__.py +21 -0
- maxframe/tensor/merge/append.py +74 -0
- maxframe/tensor/merge/column_stack.py +63 -0
- maxframe/tensor/merge/concatenate.py +103 -0
- maxframe/tensor/merge/dstack.py +71 -0
- maxframe/tensor/merge/hstack.py +70 -0
- maxframe/tensor/merge/stack.py +130 -0
- maxframe/tensor/merge/tests/__init__.py +13 -0
- maxframe/tensor/merge/tests/test_merge.py +79 -0
- maxframe/tensor/merge/vstack.py +74 -0
- maxframe/tensor/misc/__init__.py +72 -0
- maxframe/tensor/misc/argwhere.py +72 -0
- maxframe/tensor/misc/array_split.py +46 -0
- maxframe/tensor/misc/astype.py +121 -0
- maxframe/tensor/misc/atleast_1d.py +72 -0
- maxframe/tensor/misc/atleast_2d.py +70 -0
- maxframe/tensor/misc/atleast_3d.py +85 -0
- maxframe/tensor/misc/broadcast_arrays.py +57 -0
- maxframe/tensor/misc/broadcast_to.py +89 -0
- maxframe/tensor/misc/copy.py +64 -0
- maxframe/tensor/misc/copyto.py +130 -0
- maxframe/tensor/misc/delete.py +104 -0
- maxframe/tensor/misc/diff.py +115 -0
- maxframe/tensor/misc/dsplit.py +68 -0
- maxframe/tensor/misc/ediff1d.py +74 -0
- maxframe/tensor/misc/expand_dims.py +85 -0
- maxframe/tensor/misc/flatten.py +63 -0
- maxframe/tensor/misc/flip.py +90 -0
- maxframe/tensor/misc/fliplr.py +64 -0
- maxframe/tensor/misc/flipud.py +68 -0
- maxframe/tensor/misc/hsplit.py +85 -0
- maxframe/tensor/misc/in1d.py +94 -0
- maxframe/tensor/misc/insert.py +139 -0
- maxframe/tensor/misc/isin.py +130 -0
- maxframe/tensor/misc/moveaxis.py +83 -0
- maxframe/tensor/misc/ndim.py +53 -0
- maxframe/tensor/misc/ravel.py +90 -0
- maxframe/tensor/misc/repeat.py +129 -0
- maxframe/tensor/misc/result_type.py +88 -0
- maxframe/tensor/misc/roll.py +124 -0
- maxframe/tensor/misc/rollaxis.py +77 -0
- maxframe/tensor/misc/searchsorted.py +147 -0
- maxframe/tensor/misc/setdiff1d.py +58 -0
- maxframe/tensor/misc/shape.py +89 -0
- maxframe/tensor/misc/split.py +190 -0
- maxframe/tensor/misc/squeeze.py +117 -0
- maxframe/tensor/misc/swapaxes.py +113 -0
- maxframe/tensor/misc/tests/__init__.py +13 -0
- maxframe/tensor/misc/tests/test_misc.py +112 -0
- maxframe/tensor/misc/tile.py +109 -0
- maxframe/tensor/misc/transpose.py +133 -0
- maxframe/tensor/misc/trapezoid.py +123 -0
- maxframe/tensor/misc/unique.py +227 -0
- maxframe/tensor/misc/vsplit.py +74 -0
- maxframe/tensor/misc/where.py +129 -0
- maxframe/tensor/operators.py +83 -0
- maxframe/tensor/random/__init__.py +166 -0
- maxframe/tensor/random/beta.py +87 -0
- maxframe/tensor/random/binomial.py +135 -0
- maxframe/tensor/random/bytes.py +37 -0
- maxframe/tensor/random/chisquare.py +108 -0
- maxframe/tensor/random/choice.py +187 -0
- maxframe/tensor/random/core.py +249 -0
- maxframe/tensor/random/dirichlet.py +121 -0
- maxframe/tensor/random/exponential.py +92 -0
- maxframe/tensor/random/f.py +133 -0
- maxframe/tensor/random/gamma.py +126 -0
- maxframe/tensor/random/geometric.py +91 -0
- maxframe/tensor/random/gumbel.py +165 -0
- maxframe/tensor/random/hypergeometric.py +146 -0
- maxframe/tensor/random/laplace.py +131 -0
- maxframe/tensor/random/logistic.py +127 -0
- maxframe/tensor/random/lognormal.py +157 -0
- maxframe/tensor/random/logseries.py +120 -0
- maxframe/tensor/random/multinomial.py +131 -0
- maxframe/tensor/random/multivariate_normal.py +190 -0
- maxframe/tensor/random/negative_binomial.py +123 -0
- maxframe/tensor/random/noncentral_chisquare.py +130 -0
- maxframe/tensor/random/noncentral_f.py +124 -0
- maxframe/tensor/random/normal.py +141 -0
- maxframe/tensor/random/pareto.py +138 -0
- maxframe/tensor/random/permutation.py +107 -0
- maxframe/tensor/random/poisson.py +109 -0
- maxframe/tensor/random/power.py +140 -0
- maxframe/tensor/random/rand.py +80 -0
- maxframe/tensor/random/randint.py +119 -0
- maxframe/tensor/random/randn.py +94 -0
- maxframe/tensor/random/random_integers.py +121 -0
- maxframe/tensor/random/random_sample.py +84 -0
- maxframe/tensor/random/rayleigh.py +108 -0
- maxframe/tensor/random/shuffle.py +61 -0
- maxframe/tensor/random/standard_cauchy.py +103 -0
- maxframe/tensor/random/standard_exponential.py +70 -0
- maxframe/tensor/random/standard_gamma.py +118 -0
- maxframe/tensor/random/standard_normal.py +72 -0
- maxframe/tensor/random/standard_t.py +133 -0
- maxframe/tensor/random/tests/__init__.py +13 -0
- maxframe/tensor/random/tests/test_random.py +165 -0
- maxframe/tensor/random/triangular.py +117 -0
- maxframe/tensor/random/uniform.py +129 -0
- maxframe/tensor/random/vonmises.py +129 -0
- maxframe/tensor/random/wald.py +112 -0
- maxframe/tensor/random/weibull.py +138 -0
- maxframe/tensor/random/zipf.py +120 -0
- maxframe/tensor/rechunk/__init__.py +26 -0
- maxframe/tensor/rechunk/rechunk.py +43 -0
- maxframe/tensor/reduction/__init__.py +64 -0
- maxframe/tensor/reduction/all.py +101 -0
- maxframe/tensor/reduction/allclose.py +86 -0
- maxframe/tensor/reduction/any.py +103 -0
- maxframe/tensor/reduction/argmax.py +101 -0
- maxframe/tensor/reduction/argmin.py +101 -0
- maxframe/tensor/reduction/array_equal.py +63 -0
- maxframe/tensor/reduction/core.py +166 -0
- maxframe/tensor/reduction/count_nonzero.py +80 -0
- maxframe/tensor/reduction/cumprod.py +95 -0
- maxframe/tensor/reduction/cumsum.py +99 -0
- maxframe/tensor/reduction/max.py +118 -0
- maxframe/tensor/reduction/mean.py +122 -0
- maxframe/tensor/reduction/min.py +118 -0
- maxframe/tensor/reduction/nanargmax.py +80 -0
- maxframe/tensor/reduction/nanargmin.py +74 -0
- maxframe/tensor/reduction/nancumprod.py +89 -0
- maxframe/tensor/reduction/nancumsum.py +92 -0
- maxframe/tensor/reduction/nanmax.py +109 -0
- maxframe/tensor/reduction/nanmean.py +105 -0
- maxframe/tensor/reduction/nanmin.py +109 -0
- maxframe/tensor/reduction/nanprod.py +92 -0
- maxframe/tensor/reduction/nanstd.py +124 -0
- maxframe/tensor/reduction/nansum.py +113 -0
- maxframe/tensor/reduction/nanvar.py +149 -0
- maxframe/tensor/reduction/prod.py +128 -0
- maxframe/tensor/reduction/std.py +132 -0
- maxframe/tensor/reduction/sum.py +123 -0
- maxframe/tensor/reduction/tests/__init__.py +13 -0
- maxframe/tensor/reduction/tests/test_reduction.py +189 -0
- maxframe/tensor/reduction/var.py +176 -0
- maxframe/tensor/reshape/__init__.py +15 -0
- maxframe/tensor/reshape/reshape.py +192 -0
- maxframe/tensor/reshape/tests/__init__.py +13 -0
- maxframe/tensor/reshape/tests/test_reshape.py +35 -0
- maxframe/tensor/sort/__init__.py +18 -0
- maxframe/tensor/sort/argpartition.py +98 -0
- maxframe/tensor/sort/argsort.py +150 -0
- maxframe/tensor/sort/partition.py +228 -0
- maxframe/tensor/sort/sort.py +295 -0
- maxframe/tensor/spatial/__init__.py +15 -0
- maxframe/tensor/spatial/distance/__init__.py +17 -0
- maxframe/tensor/spatial/distance/cdist.py +421 -0
- maxframe/tensor/spatial/distance/pdist.py +398 -0
- maxframe/tensor/spatial/distance/squareform.py +153 -0
- maxframe/tensor/special/__init__.py +175 -0
- maxframe/tensor/special/airy.py +55 -0
- maxframe/tensor/special/bessel.py +199 -0
- maxframe/tensor/special/core.py +99 -0
- maxframe/tensor/special/ellip_func_integrals.py +155 -0
- maxframe/tensor/special/ellip_harm.py +55 -0
- maxframe/tensor/special/err_fresnel.py +223 -0
- maxframe/tensor/special/gamma_funcs.py +303 -0
- maxframe/tensor/special/hypergeometric_funcs.py +69 -0
- maxframe/tensor/special/info_theory.py +189 -0
- maxframe/tensor/special/misc.py +163 -0
- maxframe/tensor/special/statistical.py +56 -0
- maxframe/tensor/statistics/__init__.py +24 -0
- maxframe/tensor/statistics/average.py +143 -0
- maxframe/tensor/statistics/bincount.py +133 -0
- maxframe/tensor/statistics/corrcoef.py +77 -0
- maxframe/tensor/statistics/cov.py +222 -0
- maxframe/tensor/statistics/digitize.py +126 -0
- maxframe/tensor/statistics/histogram.py +520 -0
- maxframe/tensor/statistics/median.py +85 -0
- maxframe/tensor/statistics/percentile.py +175 -0
- maxframe/tensor/statistics/ptp.py +89 -0
- maxframe/tensor/statistics/quantile.py +290 -0
- maxframe/tensor/ufunc/__init__.py +24 -0
- maxframe/tensor/ufunc/ufunc.py +198 -0
- maxframe/tensor/utils.py +719 -0
- maxframe/tests/__init__.py +13 -0
- maxframe/tests/test_protocol.py +178 -0
- maxframe/tests/test_udf.py +61 -0
- maxframe/tests/test_utils.py +627 -0
- maxframe/tests/utils.py +245 -0
- maxframe/typing_.py +42 -0
- maxframe/udf.py +435 -0
- maxframe/utils.py +1774 -0
- maxframe-2.4.0rc1.dist-info/METADATA +109 -0
- maxframe-2.4.0rc1.dist-info/RECORD +1122 -0
- maxframe-2.4.0rc1.dist-info/WHEEL +5 -0
- maxframe-2.4.0rc1.dist-info/top_level.txt +3 -0
- maxframe_client/__init__.py +16 -0
- maxframe_client/clients/__init__.py +13 -0
- maxframe_client/clients/framedriver.py +137 -0
- maxframe_client/conftest.py +15 -0
- maxframe_client/fetcher.py +411 -0
- maxframe_client/session/__init__.py +22 -0
- maxframe_client/session/consts.py +39 -0
- maxframe_client/session/graph.py +125 -0
- maxframe_client/session/odps.py +813 -0
- maxframe_client/session/task.py +329 -0
- maxframe_client/session/tests/__init__.py +13 -0
- maxframe_client/session/tests/test_task.py +115 -0
- maxframe_client/tests/__init__.py +13 -0
- maxframe_client/tests/test_fetcher.py +215 -0
- maxframe_client/tests/test_session.py +409 -0
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
# Copyright 1999-2025 Alibaba Group Holding Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import abc
|
|
16
|
+
import asyncio
|
|
17
|
+
import copy
|
|
18
|
+
import logging
|
|
19
|
+
import time
|
|
20
|
+
import weakref
|
|
21
|
+
from collections import deque
|
|
22
|
+
from numbers import Integral
|
|
23
|
+
from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Union
|
|
24
|
+
from urllib.parse import urlparse
|
|
25
|
+
|
|
26
|
+
import numpy as np
|
|
27
|
+
import pandas as pd
|
|
28
|
+
from odps import ODPS
|
|
29
|
+
from odps import options as odps_options
|
|
30
|
+
from odps.config import option_context as odps_option_context
|
|
31
|
+
from odps.console import in_ipython_frontend
|
|
32
|
+
|
|
33
|
+
from maxframe.codegen import CodeGenResult
|
|
34
|
+
from maxframe.codegen.spe import SPECodeGenerator
|
|
35
|
+
from maxframe.config import options
|
|
36
|
+
from maxframe.core import Entity, TileableGraph, build_fetch, enter_mode
|
|
37
|
+
from maxframe.core.operator import Fetch, estimate_tileable_execution_size
|
|
38
|
+
from maxframe.dataframe import read_odps_table
|
|
39
|
+
from maxframe.dataframe.core import DATAFRAME_TYPE, INDEX_TYPE, SERIES_TYPE
|
|
40
|
+
from maxframe.dataframe.datasource import PandasDataSourceOperator
|
|
41
|
+
from maxframe.dataframe.datasource.read_odps_table import DataFrameReadODPSTable
|
|
42
|
+
from maxframe.errors import (
|
|
43
|
+
MaxFrameError,
|
|
44
|
+
NoTaskServerResponseError,
|
|
45
|
+
SessionAlreadyClosedError,
|
|
46
|
+
TileableNotExecutedError,
|
|
47
|
+
)
|
|
48
|
+
from maxframe.io.objects import get_object_io_handler
|
|
49
|
+
from maxframe.io.odpsio import (
|
|
50
|
+
ODPSTableIO,
|
|
51
|
+
ODPSVolumeWriter,
|
|
52
|
+
pandas_to_arrow,
|
|
53
|
+
pandas_to_odps_schema,
|
|
54
|
+
)
|
|
55
|
+
from maxframe.protocol import (
|
|
56
|
+
ConstantResultInfo,
|
|
57
|
+
DagInfo,
|
|
58
|
+
ExecutionStatus,
|
|
59
|
+
ODPSTableResultInfo,
|
|
60
|
+
ODPSVolumeResultInfo,
|
|
61
|
+
ResultInfo,
|
|
62
|
+
SessionInfo,
|
|
63
|
+
)
|
|
64
|
+
from maxframe.session import (
|
|
65
|
+
AbstractSession,
|
|
66
|
+
ExecutionInfo,
|
|
67
|
+
IsolatedAsyncSession,
|
|
68
|
+
Profiling,
|
|
69
|
+
Progress,
|
|
70
|
+
)
|
|
71
|
+
from maxframe.sperunner import SPEDagRunner
|
|
72
|
+
from maxframe.tensor.datasource import ArrayDataSource
|
|
73
|
+
from maxframe.typing_ import TileableType
|
|
74
|
+
from maxframe.utils import (
|
|
75
|
+
ToThreadMixin,
|
|
76
|
+
build_session_volume_name,
|
|
77
|
+
build_temp_table_name,
|
|
78
|
+
estimate_pandas_size,
|
|
79
|
+
get_default_table_properties,
|
|
80
|
+
no_default,
|
|
81
|
+
str_to_bool,
|
|
82
|
+
sync_pyodps_options,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
from ..clients.framedriver import FrameDriverClient
|
|
86
|
+
from ..fetcher import get_fetcher_cls
|
|
87
|
+
from .consts import RESTFUL_SESSION_INSECURE_SCHEME, RESTFUL_SESSION_SECURE_SCHEME
|
|
88
|
+
from .graph import gen_submit_tileable_graph
|
|
89
|
+
|
|
90
|
+
logger = logging.getLogger(__name__)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class MaxFrameServiceCaller(metaclass=abc.ABCMeta):
|
|
94
|
+
def get_settings_to_upload(self) -> Dict[str, Any]:
|
|
95
|
+
odps_entry = getattr(self, "_odps_entry", None)
|
|
96
|
+
entry_quota_name = getattr(odps_entry, "quota_name", None)
|
|
97
|
+
|
|
98
|
+
sql_settings = (odps_options.sql.settings or {}).copy()
|
|
99
|
+
sql_settings.update(options.sql.settings or {})
|
|
100
|
+
quota_name = (
|
|
101
|
+
options.session.quota_name
|
|
102
|
+
or entry_quota_name
|
|
103
|
+
or getattr(odps_options, "quota_name", None)
|
|
104
|
+
)
|
|
105
|
+
quota_settings = {
|
|
106
|
+
sql_settings.get("odps.task.wlm.quota", None),
|
|
107
|
+
options.spe.task.settings.get("odps.task.wlm.quota", None),
|
|
108
|
+
options.pythonpack.task.settings.get("odps.task.wlm.quota", None),
|
|
109
|
+
options.dpe.task.settings.get("odps.task.wlm.quota", None),
|
|
110
|
+
quota_name,
|
|
111
|
+
}.difference([None])
|
|
112
|
+
if len(quota_settings) >= 2:
|
|
113
|
+
raise ValueError(
|
|
114
|
+
"Quota settings are conflicting: %s" % ", ".join(sorted(quota_settings))
|
|
115
|
+
)
|
|
116
|
+
elif len(quota_settings) == 1:
|
|
117
|
+
quota_name = quota_settings.pop()
|
|
118
|
+
lifecycle = options.session.table_lifecycle or odps_options.lifecycle
|
|
119
|
+
temp_lifecycle = (
|
|
120
|
+
options.session.temp_table_lifecycle or odps_options.temp_lifecycle
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
enable_schema = options.session.enable_schema
|
|
124
|
+
default_schema = options.session.default_schema
|
|
125
|
+
if hasattr(self, "_odps_entry"):
|
|
126
|
+
default_schema = default_schema or self._odps_entry.schema
|
|
127
|
+
|
|
128
|
+
# use flags in sql settings
|
|
129
|
+
if sql_settings.get("odps.default.schema"):
|
|
130
|
+
default_schema = sql_settings["odps.default.schema"]
|
|
131
|
+
if str_to_bool(
|
|
132
|
+
sql_settings.get("odps.namespace.schema") or "false"
|
|
133
|
+
) or str_to_bool(
|
|
134
|
+
sql_settings.get("odps.sql.allow.namespace.schema") or "false"
|
|
135
|
+
):
|
|
136
|
+
enable_schema = True
|
|
137
|
+
|
|
138
|
+
mf_settings = dict(options.to_dict(remote_only=True).items())
|
|
139
|
+
mf_settings["sql.settings"] = sql_settings
|
|
140
|
+
mf_settings["session.table_lifecycle"] = lifecycle
|
|
141
|
+
mf_settings["session.temp_table_lifecycle"] = temp_lifecycle
|
|
142
|
+
mf_settings["session.quota_name"] = quota_name
|
|
143
|
+
if enable_schema is not None:
|
|
144
|
+
mf_settings["session.enable_schema"] = enable_schema
|
|
145
|
+
if options.session.enable_high_availability is None:
|
|
146
|
+
mf_settings["session.enable_high_availability"] = not in_ipython_frontend()
|
|
147
|
+
mf_settings["session.default_schema"] = default_schema or "default"
|
|
148
|
+
return mf_settings
|
|
149
|
+
|
|
150
|
+
@abc.abstractmethod
|
|
151
|
+
def create_session(self) -> SessionInfo:
|
|
152
|
+
raise NotImplementedError
|
|
153
|
+
|
|
154
|
+
@abc.abstractmethod
|
|
155
|
+
def delete_session(self) -> None:
|
|
156
|
+
raise NotImplementedError
|
|
157
|
+
|
|
158
|
+
@abc.abstractmethod
|
|
159
|
+
def submit_dag(
|
|
160
|
+
self,
|
|
161
|
+
dag: TileableGraph,
|
|
162
|
+
managed_input_infos: Dict[str, ResultInfo],
|
|
163
|
+
new_settings: Dict[str, Any] = None,
|
|
164
|
+
) -> DagInfo:
|
|
165
|
+
raise NotImplementedError
|
|
166
|
+
|
|
167
|
+
@abc.abstractmethod
|
|
168
|
+
def get_dag_info(self, dag_id: str) -> DagInfo:
|
|
169
|
+
raise NotImplementedError
|
|
170
|
+
|
|
171
|
+
@abc.abstractmethod
|
|
172
|
+
def cancel_dag(self, dag_id: str) -> DagInfo:
|
|
173
|
+
raise NotImplementedError
|
|
174
|
+
|
|
175
|
+
@abc.abstractmethod
|
|
176
|
+
def decref(self, tileable_keys: List[str]) -> None:
|
|
177
|
+
raise NotImplementedError
|
|
178
|
+
|
|
179
|
+
def get_logview_address(self, dag_id=None, hours=None) -> Optional[str]:
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class LocalSPEDagRunner(SPEDagRunner):
|
|
184
|
+
def __init__(
|
|
185
|
+
self,
|
|
186
|
+
session_id: str,
|
|
187
|
+
subdag_id: str,
|
|
188
|
+
subdag: TileableGraph,
|
|
189
|
+
generated: CodeGenResult,
|
|
190
|
+
settings: Dict[str, Any],
|
|
191
|
+
odps_entry: Optional[ODPS] = None,
|
|
192
|
+
tileable_to_info: Mapping[TileableType, ResultInfo] = None,
|
|
193
|
+
data_tileable_getter: Optional[
|
|
194
|
+
Callable[[TileableType], Tuple[TileableType, Any]]
|
|
195
|
+
] = None,
|
|
196
|
+
loop: asyncio.AbstractEventLoop = None,
|
|
197
|
+
):
|
|
198
|
+
super().__init__(session_id, subdag_id, subdag, generated, settings)
|
|
199
|
+
self._odps = self._odps or odps_entry
|
|
200
|
+
self._tileable_key_to_info = {
|
|
201
|
+
t.key: v for t, v in ({} or tileable_to_info).items()
|
|
202
|
+
}
|
|
203
|
+
self._data_tileable_getter = data_tileable_getter or (lambda x: (x, None))
|
|
204
|
+
self._loop = loop
|
|
205
|
+
|
|
206
|
+
def fetch_data_by_tileable(self, t: TileableType) -> Any:
|
|
207
|
+
tileable, index = self._data_tileable_getter(t)
|
|
208
|
+
result_info = self._tileable_key_to_info[tileable.key]
|
|
209
|
+
fetcher = get_fetcher_cls(result_info.result_type)(self._odps)
|
|
210
|
+
return asyncio.run_coroutine_threadsafe(
|
|
211
|
+
fetcher.fetch(t, result_info, index), self._loop
|
|
212
|
+
).result()
|
|
213
|
+
|
|
214
|
+
def store_data(self, key: str, value: Any) -> ResultInfo:
|
|
215
|
+
return ConstantResultInfo(data=value)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class MaxFrameSession(ToThreadMixin, IsolatedAsyncSession):
|
|
219
|
+
_odps_entry: Optional[ODPS]
|
|
220
|
+
_tileable_to_infos: Mapping[TileableType, ResultInfo]
|
|
221
|
+
|
|
222
|
+
@classmethod
|
|
223
|
+
async def init(
|
|
224
|
+
cls,
|
|
225
|
+
address: str,
|
|
226
|
+
session_id: Optional[str] = None,
|
|
227
|
+
backend: str = None,
|
|
228
|
+
odps_entry: Optional[ODPS] = None,
|
|
229
|
+
timeout: Optional[float] = None,
|
|
230
|
+
**kwargs,
|
|
231
|
+
) -> "AbstractSession":
|
|
232
|
+
session_obj = cls(
|
|
233
|
+
address, session_id, odps_entry=odps_entry, timeout=timeout, **kwargs
|
|
234
|
+
)
|
|
235
|
+
await session_obj._init(address)
|
|
236
|
+
return session_obj
|
|
237
|
+
|
|
238
|
+
def __init__(
|
|
239
|
+
self,
|
|
240
|
+
address: str,
|
|
241
|
+
session_id: str,
|
|
242
|
+
odps_entry: Optional[ODPS] = None,
|
|
243
|
+
timeout: Optional[float] = None,
|
|
244
|
+
**kwargs,
|
|
245
|
+
):
|
|
246
|
+
super().__init__(address, session_id)
|
|
247
|
+
self.timeout = timeout
|
|
248
|
+
self._odps_entry = odps_entry or ODPS.from_global() or ODPS.from_environments()
|
|
249
|
+
self._tileable_to_infos = weakref.WeakKeyDictionary()
|
|
250
|
+
|
|
251
|
+
self._caller = self._create_caller(odps_entry, address, **kwargs)
|
|
252
|
+
self._last_settings = None
|
|
253
|
+
self._pull_interval = 1 if in_ipython_frontend() else 3
|
|
254
|
+
self._replace_internal_host = kwargs.get("replace_internal_host", True)
|
|
255
|
+
|
|
256
|
+
@classmethod
|
|
257
|
+
def _create_caller(
|
|
258
|
+
cls, odps_entry: ODPS, address: str, **kwargs
|
|
259
|
+
) -> MaxFrameServiceCaller:
|
|
260
|
+
raise NotImplementedError
|
|
261
|
+
|
|
262
|
+
async def _init(self, _address: str):
|
|
263
|
+
session_info = await self.ensure_async_call(self._caller.create_session)
|
|
264
|
+
self._last_settings = copy.deepcopy(self._caller.get_settings_to_upload())
|
|
265
|
+
self._session_id = session_info.session_id
|
|
266
|
+
await self._show_logview_address()
|
|
267
|
+
|
|
268
|
+
def _upload_and_get_table_read_tileable(
|
|
269
|
+
self, t: TileableType, data: Any
|
|
270
|
+
) -> Optional[TileableType]:
|
|
271
|
+
table_schema, table_meta = pandas_to_odps_schema(t, unknown_as_string=True)
|
|
272
|
+
if self._odps_entry.exist_table(table_meta.table_name):
|
|
273
|
+
self._odps_entry.delete_table(
|
|
274
|
+
table_meta.table_name, hints=options.sql.settings
|
|
275
|
+
)
|
|
276
|
+
table_name = build_temp_table_name(self.session_id, t.key)
|
|
277
|
+
schema = (
|
|
278
|
+
self._last_settings.get("session.default_schema", None)
|
|
279
|
+
if self._last_settings.get("session.enable_schema", False)
|
|
280
|
+
else None
|
|
281
|
+
)
|
|
282
|
+
table_obj = self._odps_entry.create_table(
|
|
283
|
+
table_name,
|
|
284
|
+
table_schema,
|
|
285
|
+
schema=schema,
|
|
286
|
+
lifecycle=options.session.temp_table_lifecycle,
|
|
287
|
+
hints=options.sql.settings,
|
|
288
|
+
if_not_exists=True,
|
|
289
|
+
table_properties=options.session.temp_table_properties
|
|
290
|
+
or get_default_table_properties(),
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
batch_size = options.session.upload_batch_size
|
|
294
|
+
|
|
295
|
+
if len(data):
|
|
296
|
+
table_client = ODPSTableIO(self._odps_entry)
|
|
297
|
+
with table_client.open_writer(table_obj.full_table_name) as writer:
|
|
298
|
+
for batch_start in range(0, len(data), batch_size):
|
|
299
|
+
if isinstance(data, pd.Index):
|
|
300
|
+
batch = data[batch_start : batch_start + batch_size]
|
|
301
|
+
else:
|
|
302
|
+
batch = data.iloc[batch_start : batch_start + batch_size]
|
|
303
|
+
arrow_batch, _ = pandas_to_arrow(batch)
|
|
304
|
+
writer.write(arrow_batch)
|
|
305
|
+
|
|
306
|
+
read_tileable = read_odps_table(
|
|
307
|
+
table_obj.full_table_name,
|
|
308
|
+
columns=table_meta.table_column_names,
|
|
309
|
+
index_col=table_meta.table_index_column_names,
|
|
310
|
+
output_type=table_meta.type,
|
|
311
|
+
)
|
|
312
|
+
if isinstance(read_tileable, DATAFRAME_TYPE):
|
|
313
|
+
if list(read_tileable.dtypes.index) != list(t.dtypes.index):
|
|
314
|
+
read_tileable.columns = list(t.dtypes.index)
|
|
315
|
+
if any(t.index_value.to_pandas().names) or any(t.dtypes.index.names):
|
|
316
|
+
read_tileable = read_tileable.rename_axis(
|
|
317
|
+
columns=list(t.dtypes.index.names),
|
|
318
|
+
index=list(t.index_value.to_pandas().names),
|
|
319
|
+
)
|
|
320
|
+
elif isinstance(read_tileable, SERIES_TYPE):
|
|
321
|
+
if read_tileable.name != t.name:
|
|
322
|
+
read_tileable.name = t.name
|
|
323
|
+
else: # INDEX_TYPE
|
|
324
|
+
if list(read_tileable.names) != list(t.names):
|
|
325
|
+
read_tileable.rename(t.names, inplace=True)
|
|
326
|
+
read_tileable._key = t.key
|
|
327
|
+
read_tileable.params = t.params
|
|
328
|
+
return read_tileable.data
|
|
329
|
+
|
|
330
|
+
def _upload_and_get_vol_read_tileable(
|
|
331
|
+
self, t: TileableType, data: Any
|
|
332
|
+
) -> Optional[TileableType]:
|
|
333
|
+
vol_name = build_session_volume_name(self.session_id)
|
|
334
|
+
writer = ODPSVolumeWriter(
|
|
335
|
+
self._odps_entry,
|
|
336
|
+
vol_name,
|
|
337
|
+
t.key,
|
|
338
|
+
replace_internal_host=self._replace_internal_host,
|
|
339
|
+
)
|
|
340
|
+
io_handler = get_object_io_handler(t)
|
|
341
|
+
io_handler().write_object(writer, t, data)
|
|
342
|
+
return build_fetch(t).data
|
|
343
|
+
|
|
344
|
+
def _get_local_data(self, t: TileableType) -> Any:
|
|
345
|
+
if isinstance(t.op, (ArrayDataSource, PandasDataSourceOperator)):
|
|
346
|
+
# scenario 1: tensor or DataFrame input
|
|
347
|
+
if t.inputs:
|
|
348
|
+
return no_default
|
|
349
|
+
return t.op.get_data()
|
|
350
|
+
if isinstance(t.op, Fetch):
|
|
351
|
+
# scenario 2: local data
|
|
352
|
+
key_to_tileables = {t.key: t for t in self._tileable_to_infos.keys()}
|
|
353
|
+
if t.key not in key_to_tileables:
|
|
354
|
+
return no_default
|
|
355
|
+
src_info = self._tileable_to_infos[key_to_tileables[t.key]]
|
|
356
|
+
if not isinstance(src_info, ConstantResultInfo):
|
|
357
|
+
return no_default
|
|
358
|
+
return src_info.data
|
|
359
|
+
return no_default
|
|
360
|
+
|
|
361
|
+
def _upload_and_get_read_tileable(self, t: TileableType) -> Optional[TileableType]:
|
|
362
|
+
local_data = self._get_local_data(t)
|
|
363
|
+
if local_data is no_default:
|
|
364
|
+
return
|
|
365
|
+
with sync_pyodps_options():
|
|
366
|
+
if isinstance(t, DATAFRAME_TYPE + SERIES_TYPE + INDEX_TYPE):
|
|
367
|
+
return self._upload_and_get_table_read_tileable(t, local_data)
|
|
368
|
+
else:
|
|
369
|
+
return self._upload_and_get_vol_read_tileable(t, local_data)
|
|
370
|
+
|
|
371
|
+
@enter_mode(kernel=True, build=True)
|
|
372
|
+
def _scan_and_replace_local_sources(
|
|
373
|
+
self, graph: TileableGraph
|
|
374
|
+
) -> Dict[TileableType, TileableType]:
|
|
375
|
+
"""Replaces Pandas data sources with temp table sources in the graph"""
|
|
376
|
+
replacements = dict()
|
|
377
|
+
for t in graph:
|
|
378
|
+
replaced = self._upload_and_get_read_tileable(t)
|
|
379
|
+
if replaced is None:
|
|
380
|
+
continue
|
|
381
|
+
replacements[t] = replaced
|
|
382
|
+
|
|
383
|
+
for src, replaced in replacements.items():
|
|
384
|
+
successors = list(graph.successors(src))
|
|
385
|
+
graph.remove_node(src)
|
|
386
|
+
|
|
387
|
+
expand_queue = deque([replaced])
|
|
388
|
+
while expand_queue:
|
|
389
|
+
to_insert = expand_queue.popleft()
|
|
390
|
+
graph.add_node(to_insert)
|
|
391
|
+
for pred in to_insert.inputs or ():
|
|
392
|
+
expand_queue.append(pred)
|
|
393
|
+
graph.add_node(pred)
|
|
394
|
+
graph.add_edge(pred, to_insert)
|
|
395
|
+
|
|
396
|
+
for succ in successors:
|
|
397
|
+
graph.add_edge(replaced, succ)
|
|
398
|
+
succ.op.inputs = [replacements.get(t, t) for t in succ.inputs]
|
|
399
|
+
|
|
400
|
+
graph.results = [replacements.get(t, t) for t in graph.results]
|
|
401
|
+
return replacements
|
|
402
|
+
|
|
403
|
+
@enter_mode(kernel=True, build=True)
|
|
404
|
+
def _get_input_infos(self, tileables: List[TileableType]) -> Dict[str, ResultInfo]:
|
|
405
|
+
"""Generate ResultInfo structs from generated temp tables"""
|
|
406
|
+
vol_name = build_session_volume_name(self.session_id)
|
|
407
|
+
|
|
408
|
+
infos = dict()
|
|
409
|
+
for t in tileables:
|
|
410
|
+
key = t.key
|
|
411
|
+
if isinstance(t.op, DataFrameReadODPSTable):
|
|
412
|
+
infos[key] = ODPSTableResultInfo(full_table_name=t.op.table_name)
|
|
413
|
+
else:
|
|
414
|
+
if isinstance(t.op, Fetch):
|
|
415
|
+
infos[key] = ODPSVolumeResultInfo(
|
|
416
|
+
volume_name=vol_name, volume_path=t.key
|
|
417
|
+
)
|
|
418
|
+
elif t.inputs and isinstance(t.inputs[0].op, DataFrameReadODPSTable):
|
|
419
|
+
t = t.inputs[0]
|
|
420
|
+
infos[key] = ODPSTableResultInfo(full_table_name=t.op.table_name)
|
|
421
|
+
return infos
|
|
422
|
+
|
|
423
|
+
def _get_diff_settings(self) -> Dict[str, Any]:
|
|
424
|
+
new_settings = self._caller.get_settings_to_upload()
|
|
425
|
+
if not self._last_settings: # pragma: no cover
|
|
426
|
+
self._last_settings = copy.deepcopy(new_settings)
|
|
427
|
+
return new_settings
|
|
428
|
+
|
|
429
|
+
if self._last_settings.get("session.quota_name", None) != new_settings.get(
|
|
430
|
+
"session.quota_name", None
|
|
431
|
+
):
|
|
432
|
+
raise ValueError("Quota name cannot be changed after sessions are created")
|
|
433
|
+
|
|
434
|
+
update = dict()
|
|
435
|
+
for k in new_settings.keys():
|
|
436
|
+
old_item = self._last_settings.get(k)
|
|
437
|
+
new_item = new_settings.get(k)
|
|
438
|
+
try:
|
|
439
|
+
if old_item != new_item:
|
|
440
|
+
update[k] = new_item
|
|
441
|
+
except: # noqa: E722 # nosec # pylint: disable=bare-except
|
|
442
|
+
update[k] = new_item
|
|
443
|
+
self._last_settings = copy.deepcopy(new_settings)
|
|
444
|
+
return update
|
|
445
|
+
|
|
446
|
+
def _is_local_executable(self, tileable_graph: TileableGraph) -> bool:
|
|
447
|
+
from maxframe.codegen.spe.core import get_op_adapter
|
|
448
|
+
|
|
449
|
+
local_exec_size_limit = options.local_execution.size_limit
|
|
450
|
+
if not options.local_execution.enabled or not local_exec_size_limit:
|
|
451
|
+
return False
|
|
452
|
+
|
|
453
|
+
# make sure all ops registered in SPE
|
|
454
|
+
try:
|
|
455
|
+
for tileable in tileable_graph:
|
|
456
|
+
get_op_adapter(type(tileable.op))
|
|
457
|
+
except KeyError:
|
|
458
|
+
return False
|
|
459
|
+
|
|
460
|
+
fetch_sizes = dict()
|
|
461
|
+
for inp in tileable_graph.iter_indep():
|
|
462
|
+
if not isinstance(inp.op, Fetch):
|
|
463
|
+
continue
|
|
464
|
+
local_data = self._get_local_data(inp)
|
|
465
|
+
# todo add resolution of sizes of tensor data type here
|
|
466
|
+
if isinstance(local_data, (pd.DataFrame, pd.Series, pd.Index)):
|
|
467
|
+
fetch_sizes[inp.key] = estimate_pandas_size(local_data)
|
|
468
|
+
|
|
469
|
+
est_exec_size = estimate_tileable_execution_size(
|
|
470
|
+
tileable_graph, fetch_sizes=fetch_sizes
|
|
471
|
+
)
|
|
472
|
+
return local_exec_size_limit and est_exec_size < local_exec_size_limit
|
|
473
|
+
|
|
474
|
+
async def execute(self, *tileables, **kwargs) -> ExecutionInfo:
|
|
475
|
+
tileables = [
|
|
476
|
+
tileable.data if isinstance(tileable, Entity) else tileable
|
|
477
|
+
for tileable in tileables
|
|
478
|
+
]
|
|
479
|
+
tileable_to_copied = dict()
|
|
480
|
+
tileable_graph, to_execute_tileables = gen_submit_tileable_graph(
|
|
481
|
+
self, tileables, tileable_to_copied
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
if self._is_local_executable(tileable_graph):
|
|
485
|
+
return await self._execute_locally(tileable_graph, to_execute_tileables)
|
|
486
|
+
else:
|
|
487
|
+
return await self._execute_in_service(
|
|
488
|
+
tileable_graph, to_execute_tileables, tileable_to_copied
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
async def _execute_in_service(
|
|
492
|
+
self,
|
|
493
|
+
tileable_graph: TileableGraph,
|
|
494
|
+
to_execute_tileables: List[TileableType],
|
|
495
|
+
tileable_to_copied: Dict[TileableType, TileableType],
|
|
496
|
+
) -> ExecutionInfo:
|
|
497
|
+
source_replacements = self._scan_and_replace_local_sources(tileable_graph)
|
|
498
|
+
|
|
499
|
+
# we need to manage uploaded data sources with refcounting mechanism
|
|
500
|
+
# as nodes in tileable_graph are copied, we need to use original nodes
|
|
501
|
+
copied_to_tileable = {v: k for k, v in tileable_to_copied.items()}
|
|
502
|
+
for replaced_src in source_replacements.keys():
|
|
503
|
+
copied_to_tileable[replaced_src]._attach_session(self)
|
|
504
|
+
|
|
505
|
+
replaced_infos = self._get_input_infos(list(source_replacements.values()))
|
|
506
|
+
dag_info = await self.ensure_async_call(
|
|
507
|
+
self._caller.submit_dag,
|
|
508
|
+
tileable_graph,
|
|
509
|
+
replaced_infos,
|
|
510
|
+
self._get_diff_settings(),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
await self._show_logview_address(dag_info.dag_id)
|
|
514
|
+
|
|
515
|
+
progress = Progress()
|
|
516
|
+
profiling = Profiling()
|
|
517
|
+
aio_task = asyncio.create_task(
|
|
518
|
+
self._run_remotely_in_background(dag_info, to_execute_tileables, progress)
|
|
519
|
+
)
|
|
520
|
+
return ExecutionInfo(
|
|
521
|
+
aio_task,
|
|
522
|
+
progress,
|
|
523
|
+
profiling,
|
|
524
|
+
asyncio.get_running_loop(),
|
|
525
|
+
to_execute_tileables,
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
async def _run_remotely_in_background(
|
|
529
|
+
self, dag_info: DagInfo, tileables: List, progress: Progress
|
|
530
|
+
):
|
|
531
|
+
start_time = time.time()
|
|
532
|
+
session_id = dag_info.session_id
|
|
533
|
+
dag_id = dag_info.dag_id
|
|
534
|
+
server_no_response_time = None
|
|
535
|
+
with enter_mode(build=True, kernel=True):
|
|
536
|
+
key_to_tileables = {t.key: t for t in tileables}
|
|
537
|
+
timeout_val = 0.1
|
|
538
|
+
try:
|
|
539
|
+
while True:
|
|
540
|
+
elapsed_time = time.time() - start_time
|
|
541
|
+
next_timeout_val = min(timeout_val * 2, self._pull_interval)
|
|
542
|
+
timeout_val = (
|
|
543
|
+
min(self.timeout - elapsed_time, next_timeout_val)
|
|
544
|
+
if self.timeout
|
|
545
|
+
else next_timeout_val
|
|
546
|
+
)
|
|
547
|
+
if timeout_val <= 0:
|
|
548
|
+
raise TimeoutError("Running DAG timed out")
|
|
549
|
+
|
|
550
|
+
try:
|
|
551
|
+
dag_info: DagInfo = await self.ensure_async_call(
|
|
552
|
+
self._caller.get_dag_info, dag_id
|
|
553
|
+
)
|
|
554
|
+
server_no_response_time = None
|
|
555
|
+
except (NoTaskServerResponseError, SessionAlreadyClosedError) as ex:
|
|
556
|
+
# when we receive SessionAlreadyClosedError after NoTaskServerResponseError
|
|
557
|
+
# is received, it is possible that task server is restarted and
|
|
558
|
+
# SessionAlreadyClosedError might be flaky. Otherwise, the error
|
|
559
|
+
# should be raised.
|
|
560
|
+
if (
|
|
561
|
+
isinstance(ex, SessionAlreadyClosedError)
|
|
562
|
+
and not server_no_response_time
|
|
563
|
+
):
|
|
564
|
+
raise
|
|
565
|
+
server_no_response_time = server_no_response_time or time.time()
|
|
566
|
+
if (
|
|
567
|
+
time.time() - server_no_response_time
|
|
568
|
+
> options.client.task_restart_timeout
|
|
569
|
+
):
|
|
570
|
+
raise MaxFrameError(
|
|
571
|
+
"Failed to get valid response from service. "
|
|
572
|
+
f"Session {self._session_id}."
|
|
573
|
+
) from None
|
|
574
|
+
await asyncio.sleep(timeout_val)
|
|
575
|
+
continue
|
|
576
|
+
|
|
577
|
+
if dag_info is None:
|
|
578
|
+
raise SystemError(
|
|
579
|
+
f"Cannot find DAG with ID {dag_id} in session {session_id}"
|
|
580
|
+
)
|
|
581
|
+
progress.value = dag_info.progress
|
|
582
|
+
if dag_info.status != ExecutionStatus.RUNNING:
|
|
583
|
+
break
|
|
584
|
+
await asyncio.sleep(timeout_val)
|
|
585
|
+
except asyncio.CancelledError:
|
|
586
|
+
dag_info = await self.ensure_async_call(self._caller.cancel_dag, dag_id)
|
|
587
|
+
if dag_info.status != ExecutionStatus.CANCELLED: # pragma: no cover
|
|
588
|
+
raise
|
|
589
|
+
finally:
|
|
590
|
+
if dag_info.status == ExecutionStatus.SUCCEEDED:
|
|
591
|
+
progress.value = 1.0
|
|
592
|
+
elif dag_info.status == ExecutionStatus.FAILED:
|
|
593
|
+
dag_info.error_info.reraise()
|
|
594
|
+
|
|
595
|
+
if dag_info.status in (ExecutionStatus.RUNNING, ExecutionStatus.CANCELLED):
|
|
596
|
+
return
|
|
597
|
+
|
|
598
|
+
for key, result_info in dag_info.tileable_to_result_infos.items():
|
|
599
|
+
t = key_to_tileables[key]
|
|
600
|
+
fetcher = get_fetcher_cls(result_info.result_type)(self._odps_entry)
|
|
601
|
+
await fetcher.update_tileable_meta(t, result_info)
|
|
602
|
+
self._tileable_to_infos[t] = result_info
|
|
603
|
+
|
|
604
|
+
async def _execute_locally(
|
|
605
|
+
self,
|
|
606
|
+
tileable_graph: TileableGraph,
|
|
607
|
+
to_execute_tileables: List[TileableType],
|
|
608
|
+
):
|
|
609
|
+
cur_loop = asyncio.get_running_loop()
|
|
610
|
+
|
|
611
|
+
def run_sync(subdag_id):
|
|
612
|
+
codegen = SPECodeGenerator(self.session_id, subdag_id)
|
|
613
|
+
generated_code = codegen.generate(tileable_graph)
|
|
614
|
+
|
|
615
|
+
runner = LocalSPEDagRunner(
|
|
616
|
+
self._session_id,
|
|
617
|
+
subdag_id,
|
|
618
|
+
tileable_graph,
|
|
619
|
+
generated_code,
|
|
620
|
+
settings={},
|
|
621
|
+
odps_entry=self._odps_entry,
|
|
622
|
+
tileable_to_info=self._tileable_to_infos,
|
|
623
|
+
loop=cur_loop,
|
|
624
|
+
)
|
|
625
|
+
with odps_option_context():
|
|
626
|
+
self._odps_entry.to_global()
|
|
627
|
+
key_to_info = runner.run()
|
|
628
|
+
for tileable in to_execute_tileables:
|
|
629
|
+
self._tileable_to_infos[tileable] = key_to_info[tileable.key]
|
|
630
|
+
|
|
631
|
+
mock_subdag_id = f"subdag_local_{int(time.time())}"
|
|
632
|
+
progress = Progress()
|
|
633
|
+
profiling = Profiling()
|
|
634
|
+
aio_task = asyncio.create_task(self.to_thread(run_sync, mock_subdag_id))
|
|
635
|
+
return ExecutionInfo(
|
|
636
|
+
aio_task,
|
|
637
|
+
progress,
|
|
638
|
+
profiling,
|
|
639
|
+
asyncio.get_running_loop(),
|
|
640
|
+
to_execute_tileables,
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
def _get_data_tileable_and_indexes(
|
|
644
|
+
self, tileable: TileableType
|
|
645
|
+
) -> Tuple[TileableType, List[Union[slice, Integral]]]:
|
|
646
|
+
from maxframe.dataframe.indexing.iloc import (
|
|
647
|
+
DataFrameIlocGetItem,
|
|
648
|
+
SeriesIlocGetItem,
|
|
649
|
+
)
|
|
650
|
+
from maxframe.tensor.indexing import TensorIndex
|
|
651
|
+
|
|
652
|
+
slice_op_types = TensorIndex, DataFrameIlocGetItem, SeriesIlocGetItem
|
|
653
|
+
|
|
654
|
+
if isinstance(tileable, Entity):
|
|
655
|
+
tileable = tileable.data
|
|
656
|
+
|
|
657
|
+
indexes = None
|
|
658
|
+
while tileable not in self._tileable_to_infos:
|
|
659
|
+
# if tileable's op is slice, try to check input
|
|
660
|
+
if isinstance(tileable.op, slice_op_types):
|
|
661
|
+
indexes = tileable.op.indexes
|
|
662
|
+
tileable = tileable.inputs[0]
|
|
663
|
+
if not all(isinstance(index, (slice, Integral)) for index in indexes):
|
|
664
|
+
raise ValueError("Only support fetch data slices")
|
|
665
|
+
else:
|
|
666
|
+
raise TileableNotExecutedError(
|
|
667
|
+
f"Cannot fetch unexecuted tileable: {tileable!r}"
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
return tileable, indexes
|
|
671
|
+
|
|
672
|
+
async def fetch(self, *tileables, **kwargs) -> list:
|
|
673
|
+
results = []
|
|
674
|
+
tileables = [
|
|
675
|
+
tileable.data if isinstance(tileable, Entity) else tileable
|
|
676
|
+
for tileable in tileables
|
|
677
|
+
]
|
|
678
|
+
with enter_mode(build=True):
|
|
679
|
+
for tileable in tileables:
|
|
680
|
+
data_tileable, indexes = self._get_data_tileable_and_indexes(tileable)
|
|
681
|
+
info = self._tileable_to_infos[data_tileable]
|
|
682
|
+
fetcher = get_fetcher_cls(info.result_type)(self._odps_entry)
|
|
683
|
+
results.append(await fetcher.fetch(data_tileable, info, indexes))
|
|
684
|
+
return results
|
|
685
|
+
|
|
686
|
+
async def decref(self, *tileable_keys):
|
|
687
|
+
return await self.ensure_async_call(self._caller.decref, list(tileable_keys))
|
|
688
|
+
|
|
689
|
+
async def destroy(self):
|
|
690
|
+
await self.ensure_async_call(self._caller.delete_session)
|
|
691
|
+
await super().destroy()
|
|
692
|
+
|
|
693
|
+
async def _get_ref_counts(self) -> Dict[str, int]:
|
|
694
|
+
pass
|
|
695
|
+
|
|
696
|
+
async def fetch_tileable_op_logs(
|
|
697
|
+
self,
|
|
698
|
+
tileable_op_key: str,
|
|
699
|
+
offsets: Union[Dict[str, List[int]], str, int],
|
|
700
|
+
sizes: Union[Dict[str, List[int]], str, int],
|
|
701
|
+
) -> Dict:
|
|
702
|
+
pass
|
|
703
|
+
|
|
704
|
+
async def get_total_n_cpu(self):
|
|
705
|
+
pass
|
|
706
|
+
|
|
707
|
+
async def get_cluster_versions(self) -> List[str]:
|
|
708
|
+
raise NotImplementedError
|
|
709
|
+
|
|
710
|
+
async def get_web_endpoint(self) -> Optional[str]:
|
|
711
|
+
raise NotImplementedError
|
|
712
|
+
|
|
713
|
+
async def create_mutable_tensor(
|
|
714
|
+
self,
|
|
715
|
+
shape: tuple,
|
|
716
|
+
dtype: Union[np.dtype, str],
|
|
717
|
+
name: str = None,
|
|
718
|
+
default_value: Union[int, float] = 0,
|
|
719
|
+
chunk_size: Union[int, Tuple] = None,
|
|
720
|
+
):
|
|
721
|
+
raise NotImplementedError
|
|
722
|
+
|
|
723
|
+
async def get_mutable_tensor(self, name: str):
|
|
724
|
+
raise NotImplementedError
|
|
725
|
+
|
|
726
|
+
async def get_logview_address(self, hours=None) -> Optional[str]:
|
|
727
|
+
return await self.get_dag_logview_address(None, hours)
|
|
728
|
+
|
|
729
|
+
async def get_dag_logview_address(self, dag_id=None, hours=None) -> Optional[str]:
|
|
730
|
+
return await self.ensure_async_call(
|
|
731
|
+
self._caller.get_logview_address, dag_id, hours
|
|
732
|
+
)
|
|
733
|
+
|
|
734
|
+
async def _show_logview_address(self, dag_id=None, hours=None):
|
|
735
|
+
identity = f"Session ID: {self._session_id}"
|
|
736
|
+
if dag_id:
|
|
737
|
+
identity += f", DAG ID: {dag_id}"
|
|
738
|
+
|
|
739
|
+
logview_addr = await self.get_dag_logview_address(dag_id, hours)
|
|
740
|
+
if logview_addr:
|
|
741
|
+
logger.info("%s, Logview: %s", identity, logview_addr)
|
|
742
|
+
else:
|
|
743
|
+
logger.info("%s, Logview address does not exist", identity)
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
class MaxFrameRestCaller(MaxFrameServiceCaller):
|
|
747
|
+
_client: FrameDriverClient
|
|
748
|
+
_session_id: Optional[str]
|
|
749
|
+
|
|
750
|
+
def __init__(self, odps_entry: ODPS, client: FrameDriverClient):
|
|
751
|
+
self._odps_entry = odps_entry
|
|
752
|
+
self._client = client
|
|
753
|
+
self._session_id = None
|
|
754
|
+
|
|
755
|
+
async def create_session(self) -> SessionInfo:
|
|
756
|
+
info = await self._client.create_session(self.get_settings_to_upload())
|
|
757
|
+
self._session_id = info.session_id
|
|
758
|
+
return info
|
|
759
|
+
|
|
760
|
+
async def delete_session(self) -> None:
|
|
761
|
+
await self._client.delete_session(self._session_id)
|
|
762
|
+
|
|
763
|
+
async def submit_dag(
|
|
764
|
+
self,
|
|
765
|
+
dag: TileableGraph,
|
|
766
|
+
managed_input_infos: Dict[str, ResultInfo] = None,
|
|
767
|
+
new_settings: Dict[str, Any] = None,
|
|
768
|
+
) -> DagInfo:
|
|
769
|
+
return await self._client.submit_dag(
|
|
770
|
+
self._session_id, dag, managed_input_infos, new_settings=new_settings
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
async def get_dag_info(self, dag_id: str) -> DagInfo:
|
|
774
|
+
return await self._client.get_dag_info(self._session_id, dag_id)
|
|
775
|
+
|
|
776
|
+
async def cancel_dag(self, dag_id: str) -> DagInfo:
|
|
777
|
+
return await self._client.cancel_dag(self._session_id, dag_id)
|
|
778
|
+
|
|
779
|
+
async def decref(self, tileable_keys: List[str]) -> None:
|
|
780
|
+
return await self._client.decref(self._session_id, tileable_keys)
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
class MaxFrameRestSession(MaxFrameSession):
|
|
784
|
+
schemes = [RESTFUL_SESSION_INSECURE_SCHEME, RESTFUL_SESSION_SECURE_SCHEME]
|
|
785
|
+
|
|
786
|
+
def __init__(
|
|
787
|
+
self,
|
|
788
|
+
address: str,
|
|
789
|
+
session_id: str,
|
|
790
|
+
odps_entry: Optional[ODPS] = None,
|
|
791
|
+
timeout: Optional[float] = None,
|
|
792
|
+
new: bool = True,
|
|
793
|
+
**kwargs,
|
|
794
|
+
):
|
|
795
|
+
parsed_endpoint = urlparse(address)
|
|
796
|
+
scheme = (
|
|
797
|
+
"http"
|
|
798
|
+
if parsed_endpoint.scheme == RESTFUL_SESSION_INSECURE_SCHEME
|
|
799
|
+
else "https"
|
|
800
|
+
)
|
|
801
|
+
real_endpoint = address.replace(f"{parsed_endpoint.scheme}://", f"{scheme}://")
|
|
802
|
+
|
|
803
|
+
super().__init__(
|
|
804
|
+
real_endpoint, session_id, odps_entry=odps_entry, timeout=timeout, **kwargs
|
|
805
|
+
)
|
|
806
|
+
|
|
807
|
+
@classmethod
|
|
808
|
+
def _create_caller(cls, odps_entry: ODPS, address: str, **kwargs):
|
|
809
|
+
return MaxFrameRestCaller(odps_entry, FrameDriverClient(address))
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
def register_session_schemes(overwrite: bool = False):
|
|
813
|
+
MaxFrameRestSession.register_schemes(overwrite=overwrite)
|