Data Transport Internals¶
These functions generate TaskData from annotations, complete data paths, validate types, and check topology consistency.
astrum.data_transport.auto_generate_data_transports ¶
auto_generate_data_transports(task_orders: list[TaskOrder], task_func_map: dict[str, Callable | Awaitable]) -> list[TaskData]
Generate TaskData from Annotated/Ref function annotations.
源代码位于: src/astrum/data_transport.py
astrum.data_transport.resolve_task_data ¶
resolve_task_data(task_orders: list[TaskOrder], data_transports: list[TaskData], allow_no_dir_definition: bool = False, infer_via_ast: bool = False, silence_warnings: bool = False)
解析数据流并自动补依赖,同时校验引用关系与默认数据/自定义数据源的类型匹配。
注意:本函数会就地变异传入的对象——
task_orders:当DataItem.from_relation/to_relation引用了未声明 的依赖关系时,会自动把对应的TaskOrder追加到目标任务的dependencies。data_transports:会把推断出的来源/去向 task_id 自动写入对应TaskData的from_tasks/to_tasks。
应在 DAG 进入调度器之前调用一次,并据此结果决定是否阻断构建(致命逻辑错误
会抛 ValueError)。
Resolve data flow and automatically fill dependencies, while also validating reference relations and type matching for default data / custom data sources.
Note: this function mutates the passed-in objects in place:
task_orders: whenDataItem.from_relation/to_relationreferences an undeclared dependency relation, the correspondingTaskOrderis automatically appended to the target task'sdependencies.data_transports: inferred source/destination task_id values are automatically written into the correspondingTaskDataobject'sfrom_tasks/to_tasks.
It should be called once before the DAG enters the scheduler, and the result
should be used to decide whether to block construction. Fatal logical errors
raise ValueError.
源代码位于: src/astrum/data_transport.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | |
astrum.data_transport.autocast_data_transports_path ¶
autocast_data_transports_path(data_transports: list[TaskData], task_orders: list[TaskOrder]) -> list[TaskData]
源代码位于: src/astrum/data_transport.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
astrum.data_transport.final_check ¶
final_check(data_transports: list[TaskData], task_orders: list[TaskOrder], task_func_map: dict[str, Callable | Awaitable], *, skip_type_check: bool = False, infer_via_ast: bool = True, strict_topology: bool = False) -> list[str]
源代码位于: src/astrum/data_transport.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
astrum.data_transport.normalize_data_model ¶
normalize_data_model(data_model: Any, field_name: str = 'allow_data_model') -> Optional[DataModelType]
源代码位于: src/astrum/data_transport.py
astrum.data_transport.write_data
async
¶
源代码位于: src/astrum/data_transport.py
astrum.data_transport.unwrap_to_callable ¶
将 Callable 或 Awaitable (协程对象) 统一转为原始的 Callable 函数对象。
Convert a Callable or Awaitable (coroutine object) into the original Callable function object in a unified way.
源代码位于: src/astrum/data_transport.py
astrum.data_transport.check_from_function_type ¶
check_from_function_type(from_function: Any, allow_data_model: Optional[DataModelType], task_id: Optional[str], infer_via_ast: bool = True) -> None
检查 from_function 或其默认值的类型是否符合 allow_data_model 定义
Check whether the type of from_function or its default value conforms to the allow_data_model definition.
源代码位于: src/astrum/data_transport.py
astrum.data_transport.check_return_type_alignment ¶
check_return_type_alignment(from_function: Optional[Callable[..., Any]], allow_data_model: Optional[DataModelType], infer_via_ast: bool = True) -> bool
源代码位于: src/astrum/data_transport.py
astrum.data_transport.visualize_data_transport ¶
源代码位于: src/astrum/data_transport.py
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 | |
astrum.data_transport.DataRef ¶
Bases: BaseModel