Skip to content
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

Process-specific rule syntax #5419

Closed
stuhood opened this issue Feb 2, 2018 · 2 comments
Closed

Process-specific rule syntax #5419

stuhood opened this issue Feb 2, 2018 · 2 comments

Comments

@stuhood
Copy link
Member

stuhood commented Feb 2, 2018

As discussed with @illicitonion (and previously on #4289), we will likely want to make some process-specific syntax for rules, since they are guaranteed to need to wrap inputs and outputs (which would otherwise just be Snapshots and Snapshots, or ExecuteProcessRequests and ExecuteProcessResults) in order to disambiguate them from other process executions.

An expanded version of the syntax that we came up with was:

@process(ClasspathEntry, [Select(Javac), SelectProjection(Snapshot, SourcesField, 'source_field', Target)])
def javac(binary, sources_snapshot):
  out_dir = "doesnt_matter"
  process_request = SnapshottedProcessRequest(args=(binary.name,
                                                    '-d', out_dir)+
                                                    tuple(f.path for f in sources_snapshot.files),
                                              snapshots=(binary.snapshot, sources_snapshot),
                                              directories_to_create=(out_dir.path,))
  process_result = yield process_request
  if process_result.exit_code:
    raise ...
  return ClasspathEntry(process_result.snapshot.re_root(outdir))

I expect that either as-part-of, or immediately-after @ity's current PR, we will want to do something like this. In the meantime though, continuing to have input_conversion and output_conversion functions would likely be ok:

@staticmethod
def create(product_type, binary_type, input_selectors, input_conversion, output_conversion):
"""TODO: Not clear that `binary_type` needs to be separate from the input selectors."""
# Select the concatenation of the snapshot directory, binary, and input selectors.
inputs = [Select(_Snapshots), Select(binary_type)] + list(input_selectors)
# Apply the input/output conversions to a top-level process-execution function which
# will receive all inputs, convert in, execute, and convert out.
func = functools.partial(_snapshotted_process,
input_conversion,
output_conversion)
func.__name__ = '{}_and_then_snapshotted_process_and_then_{}'.format(
input_conversion.__name__, output_conversion.__name__
)
# Return a task triple that executes the function to produce the product type.
return TaskRule(product_type, inputs, func)

@stuhood
Copy link
Member Author

stuhood commented Feb 12, 2018

This is a higher priority now, but is blocked on @ity's rust-isolated-process ticket. cc @illicitonion

@stuhood
Copy link
Member Author

stuhood commented Apr 14, 2018

Resolved via #5580.

@stuhood stuhood closed this as completed Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant