robertwb commented on code in PR #29944: URL: https://github.com/apache/beam/pull/29944#discussion_r1454172313
########## sdks/typescript/test/localParDo.ts: ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { registerLocalParDo } from "../src/apache_beam/serialization"; +import * as beam from "../src/apache_beam"; +import { directRunner } from "../src/apache_beam/runners/direct_runner"; + +export const log = { + exportName: 'log', Review Comment: Across what domain? If it's globally, perhaps we should establish (if just by example) some kind of a name-spacing convention? (This is especially true when users want to invoke libraries and my not be aware of what DoFns, with their names, they may hold.) ########## sdks/typescript/src/apache_beam/transforms/localParDo.ts: ########## @@ -0,0 +1,285 @@ +/* Review Comment: +1. I was thinking it's just hard to see what's new with the file being copied rather than updated. ########## sdks/typescript/src/apache_beam/runners/runner.ts: ########## @@ -64,21 +64,22 @@ export class PipelineResult { * transforms, non-trivial windowing, etc. are used). */ export function createRunner(options: any = {}): Runner { - let runnerConstructor: (any) => Runner; if (options.runner === undefined || options.runner === "default") { - runnerConstructor = defaultRunner; - } else if (options.runner === "direct") { - runnerConstructor = require("./direct_runner").directRunner; - } else if (options.runner === "universal") { - runnerConstructor = require("./universal").universalRunner; - } else if (options.runner === "flink") { - runnerConstructor = require("./flink").flinkRunner; - } else if (options.runner === "dataflow") { - runnerConstructor = require("./dataflow").dataflowRunner; - } else { - throw new Error("Unknown runner: " + options.runner); + return defaultRunner(options); } - return runnerConstructor(options); + if (options.runner === "direct") { Review Comment: Probably just a matter of preference. I'm happy with whatever is most idiomatic for typescript, and am happy to defer to you on that. ########## sdks/typescript/test/localParDo.ts: ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { registerLocalParDo } from "../src/apache_beam/serialization"; +import * as beam from "../src/apache_beam"; +import { directRunner } from "../src/apache_beam/runners/direct_runner"; + +export const log = { + exportName: 'log', + process: function (lines) { + console.log(lines); + return lines + } +}; + +registerLocalParDo(log) Review Comment: OK, so this is just for DoFns that get called in the main (aka `process.argv[1]`) file? We'd still need serialization capabilities for functions defined elsewhere? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
