Skip to content

Aspect-based scrooge implementation #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 28, 2018
Merged

Aspect-based scrooge implementation #524

merged 9 commits into from
Jun 28, 2018

Conversation

johnynek
Copy link
Contributor

@johnynek johnynek commented Jun 16, 2018

this fixes #510

It works, but there are a few issues currently:
.

  1. it appears aspects can only have string attr arguments, we have previously been using booleans for with_finagle. See the string requirement here: https://docs.bazel.build/versions/master/skylark/aspects.html#aspect-definition-1
    Public aspect attributes are of type string and are called parameters. Parameters must have avalues attribute specified on them. In this case we have a parameter called extension that is allowed to have '*', 'h', or 'cc' as a value.. I side stepped this by always enabling, but we can revisit by adding a flag on the thrift_library to enable or not if this becomes an issue.
  2. there is a weird double wrapping of ScroogeInfo and ScroogeAspectInfo. This is because aspects and the rules themselves cannot return the same provider type. We want to support depending on scrooges in a scrooge because this is how it was implemented before, and it would be nice to minimize migration pains.
  3. I can't handle the java flags for the same reason I can't handle with_finagle boolean: they were a list of strings, not a single string from a finite set. This one may be solvable if we use a toolchain to set the java flags, and it may be that the toolchain, which is yet another migration we have yet to finish.

I'd appreciate feedback at this point to raise any warning signs.

cc @ittaiz @ianoc

@johnynek
Copy link
Contributor Author

related to #170 #402

@johnynek johnynek changed the title WIP: aspect-based scrooge implementation Aspect-based scrooge implementation Jun 27, 2018
@johnynek
Copy link
Contributor Author

ptal @ianoc @ittaiz @andyscott

I will try a build of some internal stripe repos with this tomorrow.

It does change the semantics slightly, but it makes them more bazel-y I would argue. Also, I think all the current uses at Stripe will either work directly, or will error (but most will work).

@johnynek
Copy link
Contributor Author

note this is almost a net 0 change in lines: it enables us to remove extra_information and once we get #534 green, we can convert to totally modern providers, which will be nice to finally get there.

@andyscott
Copy link
Contributor

I read through and it looks good. What's the subtle semantic change? It's not apparent from a read through the diff.

Copy link
Contributor

@ittaiz ittaiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went over the non thrift.bzl and twitter_scrooge.bzl part (which is the small part) and it looks good. I'm sorry for not reviewing the whole of it but I'll defer to @ianoc since I'm pretty sure it will be much easier for him with the context. If you need me then I'll make the bandwitdh to thoroughly review

@ittaiz
Copy link
Contributor

ittaiz commented Jun 27, 2018

btw, the failures seem to be related to the fact that you're using syntax/constructs from 0.14 while we're running in travis with 0.13 (which explains why buildkite is green)

visibility = ["//visibility:public"],
)

java_import(
name = "barejar_java_import",
jars = ["bare-thrift.jar"],
jars = ["bare_jar_thrifts_scrooge.jar"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is thrifts_scrooge ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is the compiled scrooge code.

@@ -160,6 +165,9 @@ thrift_library = rule(
"absolute_prefix": attr.string(default = '', mandatory = False),
"absolute_prefixes": attr.string_list(),
# This is a list of JARs which only contain Thrift files
# these files will NOT be compiled as part of the current target,
# but the current thrifts do include these. It should also include
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are external_thrift_jar's right? there isn't a requirement that both the compiled + thrift are in the one jar i think? (you can think of the scenario the thrift is only in a jar with the thrift classifier for instance)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, I kept it segregated, but now we compile the jars. This allows you to do import style of remote items by using a target with only an external_jar. mixing them with the srcs ultimately seemed confusing to me since I don't think we want to rezip them into the output or apply the prefix rules to them. What do you think about this?

It has the side effect, I think, of making current uses just work, although slower if they include a giant jar over and over.

tools/bazel.rc Outdated
@@ -1,2 +1,2 @@
build --experimental_local_disk_cache
build --experimental_local_disk_cache_path=.bazel_cache
#build --experimental_local_disk_cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be committed? though after rebase should be gone

paths = path_content,
flags = worker_arg_pad + ':'.join([
'--with-finagle' if ctx.attr.with_finagle else '',
# '--with-finagle' if ctx.attr.with_finagle else '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code?

resource_jars = [],
labels = {},
in_scalacopts = [],
print_compile_time = False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR, but with stats files and other things, we should probably just remove this maybe to clean up/fewer options soon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. cc @andyscott do we have a ticket to remove this and make sure we can get the data from BEP logs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used for the stats file target? I believe originally this was just a println I added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is your println. The statsfile is always emitted I believe.

@ianoc-stripe
Copy link
Contributor

small questions and such, otherwise i think lgtm when green. Might be worth firing it through an internal build once you get it green?

@johnynek
Copy link
Contributor Author

with minor expected changes, this builds our giant thrift repo.

@johnynek
Copy link
Contributor Author

johnynek commented Jun 28, 2018

I am mostly building our largest scala repo, which has more complex usage of thrift is somewhat painful, but manageable (maybe 2 hours of modification).

The problem was:

  1. it didn't really matter if you made the deps correct on thrift_library. It was a dummy, so you could fix them in the scrooge_scala_library deps. That is currently not possible because we invoke one scrooge run per thrift_library
  2. we removed remote_jar and no wrapping I could see could put that behavior back. Basically, by the time you have a scrooge_scala_library it is too late to add deps. I could work around with scrooge_scala_import, but it was work.
  3. we often had thrift targets private, but public scrooge, but the way the rule worked, public scrooge made the thrift public too. That sucks. You had no way to just expose the compiled code, but not allow people to make thrifts that depend on your code, we now have that ability.

@ianoc-stripe
Copy link
Contributor

lgtm

@johnynek johnynek merged commit 72d8cd2 into master Jun 28, 2018
@ittaiz ittaiz deleted the oscar/scrooge_aspect branch July 1, 2018 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use aspects for scrooge / thrift support for scala.
5 participants