maxframe 2.0.0b2__cp38-cp38-macosx_10_9_universal2.whl → 2.3.0rc1__cp38-cp38-macosx_10_9_universal2.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/__init__.py +1 -0
- maxframe/_utils.cpython-38-darwin.so +0 -0
- maxframe/_utils.pyx +14 -1
- maxframe/codegen/core.py +9 -8
- maxframe/codegen/spe/core.py +1 -1
- maxframe/codegen/spe/dataframe/__init__.py +1 -0
- maxframe/codegen/spe/dataframe/accessors/base.py +18 -0
- maxframe/codegen/spe/dataframe/accessors/dict_.py +25 -130
- maxframe/codegen/spe/dataframe/accessors/list_.py +12 -48
- maxframe/codegen/spe/dataframe/accessors/struct_.py +28 -0
- maxframe/codegen/spe/dataframe/arithmetic.py +7 -2
- maxframe/codegen/spe/dataframe/groupby.py +88 -0
- maxframe/codegen/spe/dataframe/indexing.py +99 -4
- maxframe/codegen/spe/dataframe/merge.py +38 -1
- maxframe/codegen/spe/dataframe/misc.py +11 -33
- maxframe/codegen/spe/dataframe/reduction.py +32 -9
- maxframe/codegen/spe/dataframe/reshape.py +46 -0
- maxframe/codegen/spe/dataframe/sort.py +39 -18
- maxframe/codegen/spe/dataframe/tests/accessors/test_dict.py +9 -15
- maxframe/codegen/spe/dataframe/tests/accessors/test_list.py +4 -7
- maxframe/codegen/spe/dataframe/tests/accessors/test_struct.py +75 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_iloc.py +20 -1
- maxframe/codegen/spe/dataframe/tests/indexing/test_loc.py +35 -0
- maxframe/codegen/spe/dataframe/tests/misc/test_misc.py +0 -32
- maxframe/codegen/spe/dataframe/tests/test_groupby.py +81 -18
- maxframe/codegen/spe/dataframe/tests/test_merge.py +27 -1
- maxframe/codegen/spe/dataframe/tests/test_reduction.py +13 -0
- maxframe/codegen/spe/dataframe/tests/test_reshape.py +79 -0
- maxframe/codegen/spe/dataframe/tests/test_sort.py +20 -0
- maxframe/codegen/spe/dataframe/tseries.py +9 -0
- maxframe/codegen/spe/learn/contrib/lightgbm.py +4 -3
- maxframe/codegen/spe/learn/contrib/tests/test_xgboost.py +2 -1
- maxframe/codegen/spe/learn/metrics/__init__.py +1 -1
- maxframe/codegen/spe/learn/metrics/_ranking.py +76 -0
- maxframe/codegen/spe/learn/metrics/pairwise.py +51 -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/tensor/__init__.py +3 -0
- maxframe/codegen/spe/tensor/datasource.py +1 -0
- maxframe/codegen/spe/tensor/fft.py +74 -0
- maxframe/codegen/spe/tensor/linalg.py +29 -2
- maxframe/codegen/spe/tensor/misc.py +79 -25
- maxframe/codegen/spe/tensor/spatial.py +45 -0
- maxframe/codegen/spe/tensor/statistics.py +44 -0
- maxframe/codegen/spe/tensor/tests/test_fft.py +64 -0
- maxframe/codegen/spe/tensor/tests/test_linalg.py +15 -1
- maxframe/codegen/spe/tensor/tests/test_misc.py +52 -2
- maxframe/codegen/spe/tensor/tests/test_spatial.py +33 -0
- maxframe/codegen/spe/tensor/tests/test_statistics.py +15 -1
- maxframe/codegen/spe/tests/test_spe_codegen.py +6 -12
- maxframe/codegen/spe/utils.py +2 -0
- maxframe/config/config.py +73 -9
- maxframe/config/tests/test_validators.py +13 -1
- maxframe/config/validators.py +49 -0
- maxframe/conftest.py +54 -17
- maxframe/core/accessor.py +2 -2
- maxframe/core/base.py +2 -1
- maxframe/core/entity/core.py +5 -0
- maxframe/core/entity/tileables.py +3 -1
- maxframe/core/graph/core.cpython-38-darwin.so +0 -0
- maxframe/core/graph/entity.py +8 -3
- maxframe/core/mode.py +6 -1
- maxframe/core/operator/base.py +9 -2
- maxframe/core/operator/core.py +10 -2
- maxframe/core/operator/utils.py +13 -0
- maxframe/dataframe/__init__.py +12 -5
- maxframe/dataframe/accessors/__init__.py +1 -1
- maxframe/dataframe/accessors/compat.py +45 -0
- maxframe/dataframe/accessors/datetime_/__init__.py +4 -1
- maxframe/dataframe/accessors/dict_/contains.py +7 -16
- maxframe/dataframe/accessors/dict_/core.py +48 -0
- maxframe/dataframe/accessors/dict_/getitem.py +17 -21
- maxframe/dataframe/accessors/dict_/length.py +7 -16
- maxframe/dataframe/accessors/dict_/remove.py +6 -18
- maxframe/dataframe/accessors/dict_/setitem.py +8 -18
- maxframe/dataframe/accessors/dict_/tests/test_dict_accessor.py +62 -22
- maxframe/dataframe/accessors/list_/__init__.py +2 -2
- maxframe/dataframe/accessors/list_/core.py +48 -0
- maxframe/dataframe/accessors/list_/getitem.py +12 -19
- maxframe/dataframe/accessors/list_/length.py +7 -16
- maxframe/dataframe/accessors/list_/tests/test_list_accessor.py +11 -9
- maxframe/dataframe/accessors/string_/__init__.py +4 -1
- maxframe/dataframe/accessors/struct_/__init__.py +37 -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 +18 -4
- maxframe/dataframe/arithmetic/between.py +106 -0
- maxframe/dataframe/arithmetic/dot.py +237 -0
- maxframe/dataframe/arithmetic/maximum.py +33 -0
- maxframe/dataframe/arithmetic/minimum.py +33 -0
- maxframe/dataframe/arithmetic/{around.py → round.py} +11 -7
- maxframe/dataframe/core.py +161 -224
- maxframe/dataframe/datasource/__init__.py +18 -0
- maxframe/dataframe/datasource/core.py +6 -0
- maxframe/dataframe/datasource/direct.py +57 -0
- maxframe/dataframe/datasource/from_dict.py +124 -0
- maxframe/dataframe/datasource/from_index.py +1 -1
- maxframe/dataframe/datasource/from_records.py +77 -0
- maxframe/dataframe/datasource/from_tensor.py +109 -41
- maxframe/dataframe/datasource/read_csv.py +21 -14
- maxframe/dataframe/datasource/read_odps_query.py +29 -6
- maxframe/dataframe/datasource/read_odps_table.py +32 -10
- maxframe/dataframe/datasource/read_parquet.py +38 -39
- maxframe/dataframe/datasource/tests/test_datasource.py +37 -0
- maxframe/dataframe/datastore/__init__.py +11 -1
- maxframe/dataframe/datastore/direct.py +268 -0
- maxframe/dataframe/datastore/to_csv.py +29 -41
- maxframe/dataframe/datastore/to_odps.py +36 -4
- maxframe/dataframe/extensions/__init__.py +20 -4
- maxframe/dataframe/extensions/apply_chunk.py +32 -6
- 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 +2 -1
- maxframe/dataframe/extensions/map_reduce.py +263 -0
- maxframe/dataframe/extensions/rebalance.py +62 -0
- maxframe/dataframe/extensions/tests/test_apply_chunk.py +9 -2
- maxframe/dataframe/extensions/tests/test_extensions.py +54 -0
- maxframe/dataframe/extensions/tests/test_map_reduce.py +135 -0
- maxframe/dataframe/groupby/__init__.py +17 -2
- maxframe/dataframe/groupby/aggregation.py +86 -49
- maxframe/dataframe/groupby/apply.py +1 -1
- maxframe/dataframe/groupby/apply_chunk.py +19 -5
- maxframe/dataframe/groupby/core.py +116 -16
- maxframe/dataframe/groupby/cum.py +4 -25
- maxframe/dataframe/groupby/expanding.py +264 -0
- maxframe/dataframe/groupby/fill.py +1 -1
- maxframe/dataframe/groupby/getitem.py +12 -5
- maxframe/dataframe/groupby/head.py +11 -1
- maxframe/dataframe/groupby/rank.py +136 -0
- maxframe/dataframe/groupby/rolling.py +206 -0
- maxframe/dataframe/groupby/shift.py +114 -0
- maxframe/dataframe/groupby/tests/test_groupby.py +0 -5
- maxframe/dataframe/indexing/__init__.py +22 -2
- 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/iat.py +45 -0
- maxframe/dataframe/indexing/iloc.py +152 -12
- maxframe/dataframe/indexing/insert.py +46 -18
- maxframe/dataframe/indexing/loc.py +287 -7
- maxframe/dataframe/indexing/reindex.py +14 -5
- maxframe/dataframe/indexing/rename.py +6 -0
- maxframe/dataframe/indexing/rename_axis.py +2 -2
- maxframe/dataframe/indexing/reorder_levels.py +143 -0
- maxframe/dataframe/indexing/reset_index.py +33 -6
- maxframe/dataframe/indexing/sample.py +8 -0
- maxframe/dataframe/indexing/setitem.py +3 -3
- maxframe/dataframe/indexing/swaplevel.py +185 -0
- maxframe/dataframe/indexing/take.py +99 -0
- maxframe/dataframe/indexing/truncate.py +140 -0
- maxframe/dataframe/indexing/where.py +0 -11
- maxframe/dataframe/indexing/xs.py +148 -0
- maxframe/dataframe/merge/__init__.py +15 -1
- maxframe/dataframe/merge/append.py +97 -98
- 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 +183 -0
- maxframe/dataframe/merge/update.py +271 -0
- maxframe/dataframe/misc/__init__.py +28 -11
- maxframe/dataframe/misc/_duplicate.py +10 -4
- maxframe/dataframe/misc/apply.py +1 -1
- maxframe/dataframe/misc/check_unique.py +82 -0
- maxframe/dataframe/misc/clip.py +145 -0
- maxframe/dataframe/misc/describe.py +175 -9
- maxframe/dataframe/misc/drop.py +31 -0
- maxframe/dataframe/misc/drop_duplicates.py +2 -2
- maxframe/dataframe/misc/duplicated.py +2 -2
- maxframe/dataframe/misc/get_dummies.py +5 -1
- maxframe/dataframe/misc/infer_dtypes.py +251 -0
- maxframe/dataframe/misc/isin.py +2 -2
- maxframe/dataframe/misc/map.py +125 -18
- maxframe/dataframe/misc/repeat.py +159 -0
- maxframe/dataframe/misc/tests/test_misc.py +48 -3
- maxframe/dataframe/misc/to_numeric.py +3 -0
- maxframe/dataframe/misc/transform.py +12 -5
- maxframe/dataframe/misc/transpose.py +13 -1
- maxframe/dataframe/misc/valid_index.py +115 -0
- maxframe/dataframe/misc/value_counts.py +38 -4
- maxframe/dataframe/missing/checkna.py +14 -6
- maxframe/dataframe/missing/dropna.py +5 -0
- maxframe/dataframe/missing/fillna.py +1 -1
- maxframe/dataframe/missing/replace.py +7 -4
- maxframe/dataframe/reduction/__init__.py +35 -16
- maxframe/dataframe/reduction/aggregation.py +43 -14
- maxframe/dataframe/reduction/all.py +2 -2
- maxframe/dataframe/reduction/any.py +2 -2
- maxframe/dataframe/reduction/argmax.py +103 -0
- maxframe/dataframe/reduction/argmin.py +103 -0
- maxframe/dataframe/reduction/core.py +80 -24
- maxframe/dataframe/reduction/count.py +13 -9
- maxframe/dataframe/reduction/cov.py +166 -0
- maxframe/dataframe/reduction/cummax.py +2 -2
- maxframe/dataframe/reduction/cummin.py +2 -2
- maxframe/dataframe/reduction/cumprod.py +2 -2
- maxframe/dataframe/reduction/cumsum.py +2 -2
- maxframe/dataframe/reduction/custom_reduction.py +2 -2
- maxframe/dataframe/reduction/idxmax.py +185 -0
- maxframe/dataframe/reduction/idxmin.py +185 -0
- maxframe/dataframe/reduction/kurtosis.py +37 -30
- maxframe/dataframe/reduction/max.py +2 -2
- maxframe/dataframe/reduction/mean.py +9 -7
- maxframe/dataframe/reduction/median.py +2 -2
- maxframe/dataframe/reduction/min.py +2 -2
- maxframe/dataframe/reduction/mode.py +144 -0
- maxframe/dataframe/reduction/nunique.py +19 -11
- maxframe/dataframe/reduction/prod.py +18 -13
- maxframe/dataframe/reduction/reduction_size.py +2 -2
- maxframe/dataframe/reduction/sem.py +13 -9
- maxframe/dataframe/reduction/skew.py +31 -27
- maxframe/dataframe/reduction/str_concat.py +10 -7
- maxframe/dataframe/reduction/sum.py +18 -14
- maxframe/dataframe/reduction/tests/test_reduction.py +12 -0
- maxframe/dataframe/reduction/unique.py +20 -3
- maxframe/dataframe/reduction/var.py +16 -12
- maxframe/dataframe/reshape/__init__.py +38 -0
- maxframe/dataframe/{misc → reshape}/pivot.py +1 -0
- maxframe/dataframe/{misc → reshape}/pivot_table.py +1 -0
- maxframe/dataframe/reshape/unstack.py +114 -0
- maxframe/dataframe/sort/__init__.py +16 -1
- maxframe/dataframe/sort/argsort.py +68 -0
- maxframe/dataframe/sort/core.py +2 -1
- maxframe/dataframe/sort/nlargest.py +238 -0
- maxframe/dataframe/sort/nsmallest.py +228 -0
- maxframe/dataframe/sort/rank.py +147 -0
- maxframe/dataframe/statistics/__init__.py +3 -3
- maxframe/dataframe/statistics/corr.py +1 -0
- maxframe/dataframe/statistics/quantile.py +2 -2
- maxframe/dataframe/tests/test_typing.py +104 -0
- maxframe/dataframe/tests/test_utils.py +66 -2
- maxframe/dataframe/tseries/__init__.py +19 -0
- maxframe/dataframe/tseries/at_time.py +61 -0
- maxframe/dataframe/tseries/between_time.py +122 -0
- maxframe/dataframe/typing_.py +185 -0
- maxframe/dataframe/utils.py +125 -52
- maxframe/dataframe/window/aggregation.py +8 -4
- maxframe/dataframe/window/core.py +14 -1
- maxframe/dataframe/window/ewm.py +1 -3
- maxframe/dataframe/window/expanding.py +37 -35
- maxframe/dataframe/window/rolling.py +49 -39
- maxframe/dataframe/window/tests/test_expanding.py +1 -7
- maxframe/dataframe/window/tests/test_rolling.py +1 -1
- maxframe/env.py +7 -4
- maxframe/errors.py +2 -2
- maxframe/io/odpsio/schema.py +9 -3
- maxframe/io/odpsio/tableio.py +7 -2
- maxframe/io/odpsio/tests/test_schema.py +198 -83
- maxframe/learn/__init__.py +10 -2
- maxframe/learn/cluster/__init__.py +15 -0
- maxframe/learn/cluster/_kmeans.py +782 -0
- maxframe/learn/contrib/llm/core.py +18 -7
- 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 +1 -0
- maxframe/learn/contrib/llm/models/dashscope.py +12 -6
- maxframe/learn/contrib/llm/models/managed.py +76 -11
- maxframe/learn/contrib/llm/models/openai.py +72 -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 +348 -42
- maxframe/learn/contrib/models.py +4 -1
- maxframe/learn/contrib/xgboost/classifier.py +2 -0
- maxframe/learn/contrib/xgboost/core.py +113 -4
- maxframe/learn/contrib/xgboost/predict.py +4 -2
- maxframe/learn/contrib/xgboost/regressor.py +5 -0
- maxframe/learn/contrib/xgboost/train.py +7 -2
- maxframe/learn/core.py +66 -0
- maxframe/learn/linear_model/_base.py +58 -1
- maxframe/learn/linear_model/_lin_reg.py +1 -1
- maxframe/learn/metrics/__init__.py +6 -0
- maxframe/learn/metrics/_classification.py +145 -0
- maxframe/learn/metrics/_ranking.py +477 -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/preprocessing/_data/min_max_scaler.py +34 -23
- maxframe/learn/preprocessing/_data/standard_scaler.py +34 -25
- maxframe/learn/utils/__init__.py +2 -1
- maxframe/learn/utils/checks.py +1 -2
- maxframe/learn/utils/core.py +59 -0
- maxframe/learn/utils/extmath.py +79 -9
- maxframe/learn/utils/odpsio.py +262 -0
- maxframe/learn/utils/validation.py +2 -2
- maxframe/lib/compat.py +40 -0
- maxframe/lib/dtypes_extension/__init__.py +16 -1
- maxframe/lib/dtypes_extension/_fake_arrow_dtype.py +604 -0
- maxframe/lib/dtypes_extension/blob.py +304 -0
- maxframe/lib/dtypes_extension/dtypes.py +40 -0
- maxframe/lib/dtypes_extension/tests/test_blob.py +88 -0
- maxframe/lib/dtypes_extension/tests/test_dtypes.py +16 -1
- maxframe/lib/dtypes_extension/tests/test_fake_arrow_dtype.py +75 -0
- maxframe/lib/filesystem/_oss_lib/common.py +124 -50
- maxframe/lib/filesystem/_oss_lib/glob.py +1 -1
- maxframe/lib/filesystem/_oss_lib/handle.py +21 -25
- maxframe/lib/filesystem/base.py +1 -1
- maxframe/lib/filesystem/core.py +1 -1
- maxframe/lib/filesystem/oss.py +115 -46
- maxframe/lib/filesystem/tests/test_oss.py +74 -36
- maxframe/lib/mmh3.cpython-38-darwin.so +0 -0
- maxframe/lib/wrapped_pickle.py +10 -0
- maxframe/opcodes.py +41 -15
- maxframe/protocol.py +12 -0
- maxframe/remote/core.py +4 -0
- maxframe/serialization/__init__.py +11 -2
- maxframe/serialization/arrow.py +38 -13
- maxframe/serialization/blob.py +32 -0
- maxframe/serialization/core.cpython-38-darwin.so +0 -0
- maxframe/serialization/core.pyx +39 -1
- maxframe/serialization/exception.py +2 -4
- maxframe/serialization/numpy.py +11 -0
- maxframe/serialization/pandas.py +46 -9
- maxframe/serialization/serializables/core.py +2 -2
- maxframe/serialization/tests/test_serial.py +31 -4
- maxframe/tensor/__init__.py +38 -8
- maxframe/tensor/arithmetic/__init__.py +19 -10
- maxframe/tensor/arithmetic/core.py +2 -2
- maxframe/tensor/arithmetic/iscomplexobj.py +53 -0
- maxframe/tensor/arithmetic/tests/test_arithmetic.py +6 -9
- maxframe/tensor/core.py +6 -2
- maxframe/tensor/datasource/tests/test_datasource.py +2 -1
- maxframe/tensor/extensions/__init__.py +2 -0
- maxframe/tensor/extensions/apply_chunk.py +3 -3
- maxframe/tensor/extensions/rebalance.py +65 -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/fill_diagonal.py +1 -7
- maxframe/tensor/linalg/__init__.py +7 -0
- maxframe/tensor/linalg/_einsumfunc.py +1025 -0
- maxframe/tensor/linalg/cholesky.py +117 -0
- maxframe/tensor/linalg/einsum.py +339 -0
- maxframe/tensor/linalg/lstsq.py +100 -0
- maxframe/tensor/linalg/matrix_norm.py +75 -0
- maxframe/tensor/linalg/norm.py +249 -0
- maxframe/tensor/linalg/solve.py +72 -0
- maxframe/tensor/linalg/solve_triangular.py +2 -2
- maxframe/tensor/linalg/vector_norm.py +113 -0
- maxframe/tensor/misc/__init__.py +24 -1
- maxframe/tensor/misc/argwhere.py +72 -0
- maxframe/tensor/misc/array_split.py +46 -0
- maxframe/tensor/misc/broadcast_arrays.py +57 -0
- maxframe/tensor/misc/copyto.py +130 -0
- maxframe/tensor/misc/delete.py +104 -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/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/insert.py +139 -0
- maxframe/tensor/misc/moveaxis.py +83 -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/shape.py +89 -0
- maxframe/tensor/misc/split.py +190 -0
- maxframe/tensor/misc/tile.py +109 -0
- maxframe/tensor/misc/vsplit.py +74 -0
- maxframe/tensor/reduction/array_equal.py +2 -1
- maxframe/tensor/sort/__init__.py +2 -0
- maxframe/tensor/sort/argpartition.py +98 -0
- maxframe/tensor/sort/partition.py +228 -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 +159 -21
- maxframe/tensor/special/airy.py +55 -0
- maxframe/tensor/special/bessel.py +199 -0
- maxframe/tensor/special/core.py +65 -4
- 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 +21 -0
- maxframe/tensor/statistics/__init__.py +6 -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/ptp.py +89 -0
- maxframe/tensor/utils.py +3 -3
- maxframe/tests/test_udf.py +61 -0
- maxframe/tests/test_utils.py +51 -6
- maxframe/tests/utils.py +0 -2
- maxframe/typing_.py +2 -0
- maxframe/udf.py +130 -9
- maxframe/utils.py +254 -27
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/METADATA +3 -3
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/RECORD +442 -264
- maxframe_client/fetcher.py +35 -4
- maxframe_client/session/odps.py +7 -2
- maxframe_client/session/task.py +8 -1
- maxframe_client/tests/test_fetcher.py +76 -3
- maxframe_client/tests/test_session.py +28 -1
- maxframe/dataframe/arrays.py +0 -864
- /maxframe/dataframe/{misc → reshape}/melt.py +0 -0
- /maxframe/dataframe/{misc → reshape}/stack.py +0 -0
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/WHEEL +0 -0
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/top_level.txt +0 -0
maxframe/utils.py
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import asyncio.events
|
|
16
16
|
import concurrent.futures
|
|
17
|
+
import contextlib
|
|
17
18
|
import contextvars
|
|
18
19
|
import copy
|
|
19
20
|
import dataclasses
|
|
@@ -25,6 +26,7 @@ import inspect
|
|
|
25
26
|
import io
|
|
26
27
|
import itertools
|
|
27
28
|
import logging
|
|
29
|
+
import math
|
|
28
30
|
import numbers
|
|
29
31
|
import os
|
|
30
32
|
import pkgutil
|
|
@@ -32,10 +34,12 @@ import random
|
|
|
32
34
|
import re
|
|
33
35
|
import struct
|
|
34
36
|
import sys
|
|
37
|
+
import tempfile
|
|
35
38
|
import threading
|
|
36
39
|
import time
|
|
37
40
|
import tokenize as pytokenize
|
|
38
41
|
import types
|
|
42
|
+
import warnings
|
|
39
43
|
import weakref
|
|
40
44
|
import zlib
|
|
41
45
|
from collections.abc import Hashable, Mapping
|
|
@@ -45,6 +49,7 @@ from typing import (
|
|
|
45
49
|
Awaitable,
|
|
46
50
|
Callable,
|
|
47
51
|
Dict,
|
|
52
|
+
Generator,
|
|
48
53
|
Iterable,
|
|
49
54
|
List,
|
|
50
55
|
Optional,
|
|
@@ -76,6 +81,7 @@ from ._utils import ( # noqa: F401 # pylint: disable=unused-import
|
|
|
76
81
|
tokenize,
|
|
77
82
|
tokenize_int,
|
|
78
83
|
)
|
|
84
|
+
from .lib.dtypes_extension import ArrowDtype
|
|
79
85
|
from .lib.version import parse as parse_version
|
|
80
86
|
from .typing_ import TileableType, TimeoutType
|
|
81
87
|
|
|
@@ -200,13 +206,28 @@ def on_serialize_nsplits(value: Tuple[Tuple[int]]):
|
|
|
200
206
|
return tuple(new_nsplits)
|
|
201
207
|
|
|
202
208
|
|
|
203
|
-
def has_unknown_shape(
|
|
209
|
+
def has_unknown_shape(
|
|
210
|
+
*tiled_tileables: TileableType, axis: Union[None, int, List[int]] = None
|
|
211
|
+
) -> bool:
|
|
212
|
+
if isinstance(axis, int):
|
|
213
|
+
axis = [axis]
|
|
214
|
+
|
|
204
215
|
for tileable in tiled_tileables:
|
|
205
216
|
if getattr(tileable, "shape", None) is None:
|
|
206
217
|
continue
|
|
207
|
-
|
|
218
|
+
|
|
219
|
+
shape_iter = (
|
|
220
|
+
tileable.shape if axis is None else (tileable.shape[idx] for idx in axis)
|
|
221
|
+
)
|
|
222
|
+
if any(pd.isnull(s) for s in shape_iter):
|
|
208
223
|
return True
|
|
209
|
-
|
|
224
|
+
|
|
225
|
+
nsplits_iter = (
|
|
226
|
+
tileable.nsplits
|
|
227
|
+
if axis is None
|
|
228
|
+
else (tileable.nsplits[idx] for idx in axis)
|
|
229
|
+
)
|
|
230
|
+
if any(pd.isnull(s) for s in itertools.chain(*nsplits_iter)):
|
|
210
231
|
return True
|
|
211
232
|
return False
|
|
212
233
|
|
|
@@ -277,7 +298,10 @@ def make_dtype(dtype: Union[np.dtype, pd.api.extensions.ExtensionDtype]):
|
|
|
277
298
|
elif dtype is pd.Timedelta or dtype is datetime.timedelta:
|
|
278
299
|
return np.dtype("timedelta64[ns]")
|
|
279
300
|
else:
|
|
280
|
-
|
|
301
|
+
try:
|
|
302
|
+
return pd.api.types.pandas_dtype(dtype)
|
|
303
|
+
except TypeError:
|
|
304
|
+
return np.dtype("O")
|
|
281
305
|
|
|
282
306
|
|
|
283
307
|
def make_dtypes(
|
|
@@ -444,7 +468,10 @@ def create_sync_primitive(
|
|
|
444
468
|
return cls(loop=loop)
|
|
445
469
|
|
|
446
470
|
# From Python3.10 the loop parameter has been removed. We should work around here.
|
|
447
|
-
|
|
471
|
+
try:
|
|
472
|
+
old_loop = asyncio.get_event_loop()
|
|
473
|
+
except RuntimeError:
|
|
474
|
+
old_loop = None
|
|
448
475
|
try:
|
|
449
476
|
asyncio.set_event_loop(loop)
|
|
450
477
|
primitive = cls()
|
|
@@ -547,6 +574,20 @@ class ToThreadMixin:
|
|
|
547
574
|
return self.to_thread(func, *args, wait_on_cancel=wait_on_cancel, **kwargs)
|
|
548
575
|
|
|
549
576
|
|
|
577
|
+
class PatchableMixin:
|
|
578
|
+
"""Patch not None field to dest_obj"""
|
|
579
|
+
|
|
580
|
+
__slots__ = ()
|
|
581
|
+
|
|
582
|
+
_patchable_attrs = tuple()
|
|
583
|
+
|
|
584
|
+
def patch_to(self, dest_obj) -> None:
|
|
585
|
+
for attr in self._patchable_attrs:
|
|
586
|
+
val = getattr(self, attr, None)
|
|
587
|
+
if val is not None:
|
|
588
|
+
setattr(dest_obj, attr, val)
|
|
589
|
+
|
|
590
|
+
|
|
550
591
|
def config_odps_default_options():
|
|
551
592
|
from odps import options as odps_options
|
|
552
593
|
|
|
@@ -581,8 +622,6 @@ def estimate_pandas_size(
|
|
|
581
622
|
# MultiIndex's sample size can't be used to estimate
|
|
582
623
|
return sys.getsizeof(pd_obj)
|
|
583
624
|
|
|
584
|
-
from .dataframe.arrays import ArrowDtype
|
|
585
|
-
|
|
586
625
|
def _is_fast_dtype(dtype):
|
|
587
626
|
if isinstance(dtype, np.dtype):
|
|
588
627
|
return np.issubdtype(dtype, np.number)
|
|
@@ -712,7 +751,10 @@ def sbytes(x: Any) -> bytes:
|
|
|
712
751
|
elif isinstance(x, str):
|
|
713
752
|
return bytes(x, encoding="utf-8")
|
|
714
753
|
else:
|
|
715
|
-
|
|
754
|
+
try:
|
|
755
|
+
return bytes(x)
|
|
756
|
+
except TypeError:
|
|
757
|
+
return bytes(str(x), encoding="utf-8")
|
|
716
758
|
|
|
717
759
|
|
|
718
760
|
def is_full_slice(slc: Any) -> bool:
|
|
@@ -914,7 +956,7 @@ def stringify_path(path: Union[str, os.PathLike]) -> str:
|
|
|
914
956
|
raise TypeError("not a path-like object")
|
|
915
957
|
|
|
916
958
|
|
|
917
|
-
_memory_size_indices = {"": 0, "k": 1, "m": 2, "g": 3, "t": 4}
|
|
959
|
+
_memory_size_indices = {"": 0, "b": 0, "k": 1, "m": 2, "g": 3, "t": 4}
|
|
918
960
|
|
|
919
961
|
_size_pattern = re.compile(r"^([0-9.-]+)\s*([a-z]*)$")
|
|
920
962
|
|
|
@@ -1050,13 +1092,19 @@ def remove_suffix(value: str, suffix: str) -> Tuple[str, bool]:
|
|
|
1050
1092
|
return value, match
|
|
1051
1093
|
|
|
1052
1094
|
|
|
1053
|
-
def find_objects(
|
|
1095
|
+
def find_objects(
|
|
1096
|
+
nested: Union[List, Dict],
|
|
1097
|
+
types: Union[None, Type, Tuple[Type]] = None,
|
|
1098
|
+
checker: Callable[..., bool] = None,
|
|
1099
|
+
) -> List:
|
|
1054
1100
|
found = []
|
|
1055
1101
|
stack = [nested]
|
|
1056
1102
|
|
|
1057
1103
|
while len(stack) > 0:
|
|
1058
1104
|
it = stack.pop()
|
|
1059
|
-
if isinstance(it, types)
|
|
1105
|
+
if (types is not None and isinstance(it, types)) or (
|
|
1106
|
+
checker is not None and checker(it)
|
|
1107
|
+
):
|
|
1060
1108
|
found.append(it)
|
|
1061
1109
|
continue
|
|
1062
1110
|
|
|
@@ -1155,13 +1203,16 @@ if pa:
|
|
|
1155
1203
|
"float": pa.float32,
|
|
1156
1204
|
"double": pa.float64,
|
|
1157
1205
|
"decimal": pa.decimal128,
|
|
1206
|
+
# repr() of date32 and date64 has `day` or `ms`
|
|
1207
|
+
# which is not needed in constructors
|
|
1208
|
+
"date32": lambda *_: pa.date32(),
|
|
1209
|
+
"date64": lambda *_: pa.date64(),
|
|
1158
1210
|
}
|
|
1159
1211
|
_plain_arrow_types = """
|
|
1160
1212
|
null
|
|
1161
1213
|
int8 int16 int32 int64
|
|
1162
1214
|
uint8 uint16 uint32 uint64
|
|
1163
1215
|
float16 float32 float64
|
|
1164
|
-
date32 date64
|
|
1165
1216
|
decimal128 decimal256
|
|
1166
1217
|
string utf8 binary
|
|
1167
1218
|
time32 time64 duration timestamp
|
|
@@ -1184,7 +1235,7 @@ def arrow_type_from_str(type_str: str) -> pa.DataType:
|
|
|
1184
1235
|
token_iter = pytokenize.tokenize(io.BytesIO(type_str.encode()).readline)
|
|
1185
1236
|
value_stack, op_stack = [], []
|
|
1186
1237
|
|
|
1187
|
-
def _pop_make_type(with_args: bool = False, combined: bool = True)
|
|
1238
|
+
def _pop_make_type(with_args: bool = False, combined: bool = True):
|
|
1188
1239
|
"""
|
|
1189
1240
|
Pops tops of value stacks, creates a DataType instance and push back
|
|
1190
1241
|
|
|
@@ -1208,6 +1259,23 @@ def arrow_type_from_str(type_str: str) -> pa.DataType:
|
|
|
1208
1259
|
else: # pragma: no cover
|
|
1209
1260
|
value_stack.append(type_name)
|
|
1210
1261
|
|
|
1262
|
+
def _pop_make_struct_field():
|
|
1263
|
+
"""parameterized sub-types need to be represented as tuples"""
|
|
1264
|
+
nonlocal value_stack
|
|
1265
|
+
|
|
1266
|
+
op_stack.pop(-1)
|
|
1267
|
+
if isinstance(value_stack[-1], str) and value_stack[-1].lower() in (
|
|
1268
|
+
"null",
|
|
1269
|
+
"not null",
|
|
1270
|
+
):
|
|
1271
|
+
values = value_stack[-3:]
|
|
1272
|
+
value_stack = value_stack[:-3]
|
|
1273
|
+
values[-1] = values[-1] == "null"
|
|
1274
|
+
else:
|
|
1275
|
+
values = value_stack[-2:]
|
|
1276
|
+
value_stack = value_stack[:-2]
|
|
1277
|
+
value_stack.append(tuple(values))
|
|
1278
|
+
|
|
1211
1279
|
for token in token_iter:
|
|
1212
1280
|
if token.type == pytokenize.OP:
|
|
1213
1281
|
if token.string == ":":
|
|
@@ -1216,13 +1284,9 @@ def arrow_type_from_str(type_str: str) -> pa.DataType:
|
|
|
1216
1284
|
# gather previous sub-types
|
|
1217
1285
|
if op_stack[-1] in ("<", ":"):
|
|
1218
1286
|
_pop_make_type()
|
|
1219
|
-
|
|
1220
1287
|
if op_stack[-1] == ":":
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
values = value_stack[-2:]
|
|
1224
|
-
value_stack = value_stack[:-2]
|
|
1225
|
-
value_stack.append(tuple(values))
|
|
1288
|
+
_pop_make_struct_field()
|
|
1289
|
+
|
|
1226
1290
|
# put generated item into the parameter list
|
|
1227
1291
|
val = value_stack.pop(-1)
|
|
1228
1292
|
value_stack[-1].append(val)
|
|
@@ -1239,22 +1303,20 @@ def arrow_type_from_str(type_str: str) -> pa.DataType:
|
|
|
1239
1303
|
op_stack.pop(-1)
|
|
1240
1304
|
elif token.string == ">":
|
|
1241
1305
|
_pop_make_type()
|
|
1242
|
-
|
|
1243
1306
|
if op_stack[-1] == ":":
|
|
1244
|
-
|
|
1245
|
-
op_stack.pop(-1)
|
|
1246
|
-
values = value_stack[-2:]
|
|
1247
|
-
value_stack = value_stack[:-2]
|
|
1248
|
-
value_stack.append(tuple(values))
|
|
1307
|
+
_pop_make_struct_field()
|
|
1249
1308
|
|
|
1250
1309
|
# put generated item into the parameter list
|
|
1251
1310
|
val = value_stack.pop(-1)
|
|
1252
1311
|
value_stack[-1].append(val)
|
|
1253
1312
|
# make DataType (i.e., list / map / struct) given args
|
|
1254
|
-
_pop_make_type(True)
|
|
1313
|
+
_pop_make_type(with_args=True)
|
|
1255
1314
|
op_stack.pop(-1)
|
|
1256
1315
|
elif token.type == pytokenize.NAME:
|
|
1257
|
-
value_stack
|
|
1316
|
+
if value_stack and value_stack[-1] == "not":
|
|
1317
|
+
value_stack[-1] += " " + token.string
|
|
1318
|
+
else:
|
|
1319
|
+
value_stack.append(token.string)
|
|
1258
1320
|
elif token.type == pytokenize.NUMBER:
|
|
1259
1321
|
value_stack.append(int(token.string))
|
|
1260
1322
|
elif token.type == pytokenize.ENDMARKER:
|
|
@@ -1545,3 +1607,168 @@ def cache_tileables(*tileables):
|
|
|
1545
1607
|
for t in tileables:
|
|
1546
1608
|
if isinstance(t, ENTITY_TYPE):
|
|
1547
1609
|
t.cache = True
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
def ignore_warning(func: Callable):
|
|
1613
|
+
@functools.wraps(func)
|
|
1614
|
+
def inner(*args, **kwargs):
|
|
1615
|
+
with warnings.catch_warnings():
|
|
1616
|
+
warnings.simplefilter("ignore")
|
|
1617
|
+
return func(*args, **kwargs)
|
|
1618
|
+
|
|
1619
|
+
return inner
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
class ServiceLoggerAdapter(logging.LoggerAdapter):
|
|
1623
|
+
extra_key_mapping = {}
|
|
1624
|
+
|
|
1625
|
+
def process(self, msg, kwargs):
|
|
1626
|
+
merged_extra = (self.extra or {}).copy()
|
|
1627
|
+
merged_extra.update(kwargs)
|
|
1628
|
+
|
|
1629
|
+
prefix = " ".join(
|
|
1630
|
+
f"{self.extra_key_mapping.get(k) or k.capitalize()}={merged_extra[k]}"
|
|
1631
|
+
for k in merged_extra.keys()
|
|
1632
|
+
)
|
|
1633
|
+
msg = f"[{prefix}] {msg}"
|
|
1634
|
+
return msg, kwargs
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
@contextmanager
|
|
1638
|
+
def atomic_writer(filename, mode="w", **kwargs):
|
|
1639
|
+
"""
|
|
1640
|
+
Write to a file in an atomic way.
|
|
1641
|
+
"""
|
|
1642
|
+
temp_fd, temp_path = tempfile.mkstemp(dir=os.path.dirname(filename) or ".")
|
|
1643
|
+
os.chmod(temp_path, 0o644)
|
|
1644
|
+
os.close(temp_fd) # Close the file descriptor immediately and we reopen this later.
|
|
1645
|
+
|
|
1646
|
+
try:
|
|
1647
|
+
# Write to temp file.
|
|
1648
|
+
with open(temp_path, mode, **kwargs) as temp_file:
|
|
1649
|
+
yield temp_file
|
|
1650
|
+
|
|
1651
|
+
# Replace the original file with the temp file atomically.
|
|
1652
|
+
os.replace(temp_path, filename)
|
|
1653
|
+
finally:
|
|
1654
|
+
try:
|
|
1655
|
+
os.remove(temp_path)
|
|
1656
|
+
except OSError:
|
|
1657
|
+
pass
|
|
1658
|
+
|
|
1659
|
+
|
|
1660
|
+
def prevent_called_from_pandas(level=2):
|
|
1661
|
+
"""Prevent method from being called from pandas"""
|
|
1662
|
+
frame = sys._getframe(level)
|
|
1663
|
+
called_frame = sys._getframe(1)
|
|
1664
|
+
pd_pack_location = os.path.dirname(pd.__file__)
|
|
1665
|
+
if frame.f_code.co_filename.startswith(pd_pack_location):
|
|
1666
|
+
raise AttributeError(called_frame.f_code.co_name)
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
def combine_error_message_and_traceback(
|
|
1670
|
+
messages: List[str], tracebacks: List[List[str]]
|
|
1671
|
+
) -> str:
|
|
1672
|
+
tbs = []
|
|
1673
|
+
for msg, tb in zip(messages, tracebacks):
|
|
1674
|
+
tbs.append("".join([msg + "\n"] + tb))
|
|
1675
|
+
return "\nCaused by:\n".join(tbs)
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
def generate_unique_id(byte_len: int) -> Generator[str, None, None]:
|
|
1679
|
+
"""
|
|
1680
|
+
The ids are ensured to be unique in one generator.
|
|
1681
|
+
DO NOT use this generator in global scope or singleton class members,
|
|
1682
|
+
as it may not free the set.
|
|
1683
|
+
"""
|
|
1684
|
+
generated_ids = set()
|
|
1685
|
+
while True:
|
|
1686
|
+
new_id = new_random_id(byte_len).hex()
|
|
1687
|
+
if new_id not in generated_ids:
|
|
1688
|
+
generated_ids.add(new_id)
|
|
1689
|
+
yield new_id
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
def validate_and_adjust_resource_ratio(
|
|
1693
|
+
expect_resources: Dict[str, Any],
|
|
1694
|
+
max_memory_cpu_ratio: float = None,
|
|
1695
|
+
adjust: bool = False,
|
|
1696
|
+
) -> Tuple[Dict[str, Any], bool]:
|
|
1697
|
+
"""
|
|
1698
|
+
Validate and optionally adjust CPU:memory ratio to meet maximum requirements.
|
|
1699
|
+
|
|
1700
|
+
Args:
|
|
1701
|
+
expect_resources: Dictionary containing resource specifications
|
|
1702
|
+
max_memory_cpu_ratio: Maximum memory/cpu ratio (if None, will use config value)
|
|
1703
|
+
adjust: Whether to automatically adjust resources to meet ratio
|
|
1704
|
+
|
|
1705
|
+
Returns:
|
|
1706
|
+
Tuple of (adjusted_resources, was_adjusted)
|
|
1707
|
+
"""
|
|
1708
|
+
cpu = expect_resources.get("cpu") or 1
|
|
1709
|
+
memory = expect_resources.get("memory")
|
|
1710
|
+
|
|
1711
|
+
if cpu is None or memory is None or max_memory_cpu_ratio is None:
|
|
1712
|
+
return expect_resources, False
|
|
1713
|
+
|
|
1714
|
+
# Convert memory to GiB if it's a string
|
|
1715
|
+
cpu = max(cpu, 1)
|
|
1716
|
+
memory_gib = parse_size_to_megabytes(memory, default_number_unit="GiB") / 1024
|
|
1717
|
+
current_ratio = memory_gib / cpu
|
|
1718
|
+
|
|
1719
|
+
if current_ratio > max_memory_cpu_ratio:
|
|
1720
|
+
# Adjust CPU to meet maximum ratio, don't reduce resources
|
|
1721
|
+
recommended_cpu = math.ceil(memory_gib / max_memory_cpu_ratio)
|
|
1722
|
+
new_ratio = memory_gib / recommended_cpu
|
|
1723
|
+
if adjust:
|
|
1724
|
+
adjusted_resources = expect_resources.copy()
|
|
1725
|
+
adjusted_resources["cpu"] = recommended_cpu
|
|
1726
|
+
|
|
1727
|
+
warnings.warn(
|
|
1728
|
+
f"UDF resource auto-adjustment: Current UDF settings"
|
|
1729
|
+
f" (CPU: {cpu}, Memory: {memory_gib}Gib, Ratio: {current_ratio:.2f})"
|
|
1730
|
+
f" exceed maximum allowed ratio {max_memory_cpu_ratio:.1f}. "
|
|
1731
|
+
f"Automatically adjusted to (CPU: {recommended_cpu},"
|
|
1732
|
+
f" Memory: {memory_gib:.2f}:1Gib,"
|
|
1733
|
+
f" Ratio: {new_ratio:.2f}:1) to meet requirements."
|
|
1734
|
+
)
|
|
1735
|
+
return adjusted_resources, True
|
|
1736
|
+
else:
|
|
1737
|
+
warnings.warn(
|
|
1738
|
+
f"UDF resource ratio warning: Current UDF settings"
|
|
1739
|
+
f" (CPU: {cpu}, Memory: {memory_gib}Gib, Ratio: {current_ratio:.2f})"
|
|
1740
|
+
f" exceed maximum allowed ratio {max_memory_cpu_ratio:.1f}. "
|
|
1741
|
+
f"Consider adjusting CPU to at least {recommended_cpu}"
|
|
1742
|
+
f" (which would result in Ratio: {new_ratio:.2f}) to meet requirements."
|
|
1743
|
+
)
|
|
1744
|
+
|
|
1745
|
+
return expect_resources, False
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
def get_pd_option(option_name, default=no_default):
|
|
1749
|
+
"""Get pandas option. If not exist return `default`."""
|
|
1750
|
+
try:
|
|
1751
|
+
with warnings.catch_warnings():
|
|
1752
|
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
1753
|
+
return pd.get_option(option_name)
|
|
1754
|
+
except (KeyError, AttributeError):
|
|
1755
|
+
if default is no_default:
|
|
1756
|
+
raise
|
|
1757
|
+
return default
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
@contextlib.contextmanager
|
|
1761
|
+
def pd_option_context(*args):
|
|
1762
|
+
arg_kv = dict(zip(args[0::2], args[1::2]))
|
|
1763
|
+
new_args = []
|
|
1764
|
+
for k, v in arg_kv.items():
|
|
1765
|
+
try:
|
|
1766
|
+
get_pd_option(k)
|
|
1767
|
+
except (KeyError, AttributeError): # pragma: no cover
|
|
1768
|
+
continue
|
|
1769
|
+
new_args.extend([k, v])
|
|
1770
|
+
if not new_args: # pragma: no cover
|
|
1771
|
+
yield
|
|
1772
|
+
else:
|
|
1773
|
+
with pd.option_context(*new_args):
|
|
1774
|
+
yield
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: maxframe
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0rc1
|
|
4
4
|
Summary: MaxFrame operator-based data analyze framework
|
|
5
5
|
Requires-Dist: numpy<2.0.0,>=1.19.0
|
|
6
6
|
Requires-Dist: pandas>=1.0.0
|
|
@@ -19,6 +19,7 @@ Requires-Dist: pickle5; python_version < "3.8"
|
|
|
19
19
|
Provides-Extra: dev
|
|
20
20
|
Requires-Dist: black>=22.3.0; extra == "dev"
|
|
21
21
|
Requires-Dist: flake8>=5.0.4; extra == "dev"
|
|
22
|
+
Requires-Dist: flake8-type-checking>=1.0.3; extra == "dev"
|
|
22
23
|
Requires-Dist: pre-commit>=2.15.0; extra == "dev"
|
|
23
24
|
Requires-Dist: graphviz>=0.20.1; extra == "dev"
|
|
24
25
|
Provides-Extra: test
|
|
@@ -30,7 +31,7 @@ Requires-Dist: pytest-timeout>=2.1.0; extra == "test"
|
|
|
30
31
|
Requires-Dist: matplotlib>=2.0.0; extra == "test"
|
|
31
32
|
Requires-Dist: lightgbm<4.0.0,>=3.0.0; extra == "test"
|
|
32
33
|
Requires-Dist: scikit-learn>=1.0; extra == "test"
|
|
33
|
-
Requires-Dist: xgboost<
|
|
34
|
+
Requires-Dist: xgboost<2.1.0,>=1.6.2; extra == "test"
|
|
34
35
|
|
|
35
36
|
MaxCompute MaxFrame Client
|
|
36
37
|
==========================
|
|
@@ -105,4 +106,3 @@ License
|
|
|
105
106
|
|
|
106
107
|
Licensed under the `Apache License
|
|
107
108
|
2.0 <https://www.apache.org/licenses/LICENSE-2.0.html>`__.
|
|
108
|
-
|