Skip to content

Commit

Permalink
Update TFMD proto artifact handling by build (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones authored Aug 18, 2023
1 parent 4b90330 commit 112f5fe
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ lazy val protobuf = project
description := "Magnolia add-on for Google Protocol Buffer"
)

val unpackMetadata = taskKey[Seq[File]]("Unpack tensorflow metadata proto files.")

lazy val tensorflow = project
.in(file("tensorflow"))
.dependsOn(
Expand All @@ -482,18 +480,17 @@ lazy val tensorflow = project
"org.tensorflow" % "tensorflow-core-api" % tensorflowVersion % Provided
),
// tensorflow metadata protos are not packaged into a jar. Manually extract them as external
unpackMetadata := {
IO.unzipURL(
new URL(
s"https://github.com/tensorflow/metadata/archive/refs/tags/v$tensorflowMetadataVersion.zip"
),
target.value,
"**/*.proto"
Compile / PB.protoSources += target.value / s"metadata-$tensorflowMetadataVersion",
Compile / PB.unpackDependencies := {
val tfMetadata = new URL(
s"https://github.com/tensorflow/metadata/archive/refs/tags/v$tensorflowMetadataVersion.zip"
)
IO.move(target.value / s"metadata-$tensorflowMetadataVersion", PB.externalSourcePath.value)
IO.listFiles(PB.externalSourcePath.value / s"metadata-$tensorflowMetadataVersion")
val protoFiles = IO.unzipURL(tfMetadata, target.value, _.endsWith(".proto"))
val root = target.value / s"metadata-$tensorflowMetadataVersion"
val metadataDep = ProtocPlugin.UnpackedDependency(protoFiles.toSeq, Seq.empty)
val deps = (Compile / PB.unpackDependencies).value
new ProtocPlugin.UnpackedDependencies(deps.mappedFiles ++ Map(root -> metadataDep))
},
Compile / PB.generate := (Compile / PB.generate).dependsOn(unpackMetadata).value,
Compile / packageBin / mappings ~= {
_.filterNot { case (_, n) => n.startsWith("org/tensorflow") }
},
Expand Down

0 comments on commit 112f5fe

Please sign in to comment.