rokadepiyush49-rgb commented on issue #18597:
URL: https://github.com/apache/beam/issues/18597#issuecomment-6565210316

   I'd like to take a small, backward-compatible first step on this, and wanted 
to check the shape first.
   
   Today `MetricResults.query(filter)` is overridden by four runners 
(`DirectMetrics`, `FnApiMetrics`, `PortableMetrics`, `DataflowMetrics`), all 
taking a `MetricsFilter`. Adding keyword arguments to `query()` itself would 
mean changing all four signatures. A smaller option is a keyword helper on the 
base class that builds the `MetricsFilter` and calls `self.query(...)`, so 
existing code and runner implementations don't change. For example (name to be 
decided):
   
   ```python
   result.metrics().query_by(namespace="wordcount", name="empty_lines")
   ```
   
   Module-level aliases for the `Metrics` static methods could be added the 
same way. The "aggregate by default" idea changes what `query()` returns, so 
I'd leave that for a separate discussion.
   
   Does a base-class helper sound acceptable, and is there a preferred name for 
it?
   
   ```mermaid
   flowchart TD
       subgraph P1["1. Before coding"]
           A1["Post the comment to twiecki and ricardoV94"] --> A2{"Approach 
accepted?"}
           A2 -- yes --> A3["Branch fix/7519-local-multiprocessing-import from 
main<br/>PyMC does not assign issues"]
       end
       subgraph P2["2. Implement"]
           B1["sampling/mcmc.py:<br/>move the import into the TYPE_CHECKING 
block"] --> B2["sampling/parallel.py:<br/>TYPE_CHECKING import for annotations"]
           B2 --> B3["parallel.py: local imports in 
_initialize_multiprocessing_context,<br/>ProcessAdapter, ParallelSampler, 
_cpu_count"]
           B3 --> B4["smc/parallel.py: add from __future__ import 
annotations,<br/>local imports where Pipe and connection.wait are used"]
           B4 --> B5["grep pymc/ for any remaining<br/>module-level 
multiprocessing use"]
       end
       subgraph P3["3. Test"]
           C1["New test: a subprocess sets<br/>sys.modules multiprocessing to 
None, then imports pymc"] --> C2["pytest 
tests/sampling/test_parallel.py,<br/>tests/sampling/test_mcmc.py, tests/smc"]
           C2 --> C3["Sample once with cores=2<br/>to exercise the real process 
path"]
           C3 --> C4["pre-commit run on the changed files"]
       end
       subgraph P4["4. Pull request"]
           D1["gh pr create --repo pymc-devs/pymc<br/>body: Closes 7519"] --> 
D2["Say which AI tools you used<br/>in the PR description"]
           D2 --> D3["Leave existing tests untouched,<br/>the review point that 
stalled PR 7736"]
       end
       A3 --> B1
       B5 --> C1
       C4 --> D1
   ```


-- 
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]

Reply via email to