is `pants.reporting.json_reporting.JsonReporter` s...
# development
f
is
pants.reporting.json_reporting.JsonReporter
still relevant?
h
I think we still use it for some things? Asher and Greg have the best handle on this.
h
that feels like code that pertained to the v1 reporting infrastructure, but I am not 100% sure there is nothing in pants today that relies on it
f
context: was wondering if I had to update that code for adding counters to work units
sounds like no?
h
Honestly, I’m not sure, but I don’t think so. @polite-garden-50641 I think I wanted to delete the JSON reporter code in the past but you explained it’s still partially used?
p
no. it is no longer used/relevant, the work units you see passed thru it are not the ones you are looking for. those are v1 engine work units. the v2 work units stuff is implemented in rust.
💯 1
f
ack. which is sent via
handle_workunits
on registered Subsystems, got it
👍 1
p
those things can probably be removed from run tracker. we still use some things from it, but mostly around
run_information()
, ,
cumulative_timings
,
pantsd_stats
,
v2_goals_rule_names
get_options_to_record()
h
we should delete the json reporter code if we are sure that nothing depends on it
2
👍 1
f
relatedly, I have a Subsystem that trivially implements Subsystem with handle_workunits but trying to invoke Pants with it results in:
Copy code
17:45:43.74 [ERROR] expected string or bytes-like object
Traceback (most recent call last):
  File "/Users/tdyas/TC/pants/src/python/pants/bin/daemon_pants_runner.py", line 148, in single_daemonized_run
    return runner.run(start_time)
  File "/Users/tdyas/TC/pants/src/python/pants/bin/local_pants_runner.py", line 257, in run
    callbacks = Subsystem.get_streaming_workunit_callbacks(streaming_handlers)
  File "/Users/tdyas/TC/pants/src/python/pants/option/subsystem.py", line 248, in get_streaming_workunit_callbacks
    subsystem = subsystem_class.global_instance()
  File "/Users/tdyas/TC/pants/src/python/pants/option/subsystem.py", line 157, in global_instance
    return cls._instance_for_scope(cls.options_scope)  # type: ignore[arg-type]  # MyPy is treating cls.options_scope as a Callable, rather than `str`
  File "/Users/tdyas/TC/pants/src/python/pants/option/subsystem.py", line 182, in _instance_for_scope
    cls._scoped_instances[key] = cls(scope, cls._options.for_scope(scope))
  File "/Users/tdyas/TC/pants/src/python/pants/util/memo.py", line 123, in memoize
    result = func(*args, **kwargs)
  File "/Users/tdyas/TC/pants/src/python/pants/option/options.py", line 420, in for_scope
    values_builder = self.for_scope(enclosing_scope(scope)).to_builder()
  File "/Users/tdyas/TC/pants/src/python/pants/option/parser_hierarchy.py", line 26, in enclosing_scope
    _validate_full_scope(scope)
  File "/Users/tdyas/TC/pants/src/python/pants/option/parser_hierarchy.py", line 20, in _validate_full_scope
    if _empty_scope_component_re.search(scope):
TypeError: expected string or bytes-like object
I have
options_scope
returning
"metrics"
h
It subclasses
Subsystem
, right? You also will want to register it with the engine, either by using it as a parameter to a rule, or by registering
SubsystemRule(MySubsystem)
and ensuring that gets put in a
register.py
Alternatively, you can include it in in
global_subsystems.py
. We’re trying to move away from that file, but it probably belongs there for now
f
There needs to be a better error message though. I listed the Subsystem as a streaming workunit handler. It would have been better for Pants to print out a useful error like “unregistered Subsystem: [name]”
h
Agreed. A plugin author was confused that they had to register
SubsystemRule
If you have a moment, opening an issue would be helpful
👍 1
p