3
3
4
4
import * as t from "../types.js" ;
5
5
import { runtimes } from "../wit.js" ;
6
- import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js" ;
6
+ import {
7
+ DependencyMeta ,
8
+ Effect ,
9
+ } from "../gen/interfaces/metatype-typegraph-runtimes.js" ;
7
10
import { Materializer , Runtime } from "./mod.js" ;
8
11
import { fx } from "../index.js" ;
9
12
import { getFileHash } from "../utils/file_utils.js" ;
@@ -22,10 +25,16 @@ interface DefMat extends Materializer {
22
25
interface PythonImport {
23
26
name : string ;
24
27
module : string ;
28
+ deps : Array < string > ;
25
29
secrets ?: Array < string > ;
26
30
effect ?: Effect ;
27
31
}
28
32
33
+ // interface DependencyMeta {
34
+ // path: string;
35
+ // hash: string;
36
+ // }
37
+
29
38
interface ImportMat extends Materializer {
30
39
module : string ;
31
40
name : string ;
@@ -91,7 +100,7 @@ export class PythonRuntime extends Runtime {
91
100
> (
92
101
inp : I ,
93
102
out : O ,
94
- { name, module, effect = fx . read ( ) , secrets = [ ] } : PythonImport ,
103
+ { name, module, deps = [ ] , effect = fx . read ( ) , secrets = [ ] } : PythonImport ,
95
104
) : Promise < t . Func < I , O , ImportMat > > {
96
105
const base = {
97
106
runtime : this . _id ,
@@ -100,10 +109,22 @@ export class PythonRuntime extends Runtime {
100
109
101
110
const artifactHash = await getFileHash ( module ) ;
102
111
112
+ // generate dep meta
113
+ const depMetas : DependencyMeta [ ] = [ ] ;
114
+ for ( const dep of deps ) {
115
+ const depHash = await getFileHash ( dep ) ;
116
+ const depMeta : DependencyMeta = {
117
+ path : dep ,
118
+ depHash : depHash ,
119
+ } ;
120
+ depMetas . push ( depMeta ) ;
121
+ }
122
+
103
123
const matId = runtimes . fromPythonModule ( base , {
104
124
artifact : module ,
105
125
runtime : this . _id ,
106
126
artifactHash : artifactHash ,
127
+ deps : depMetas ,
107
128
} ) ;
108
129
109
130
const pyModMatId = runtimes . fromPythonImport ( base , {
0 commit comments