mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fix benchmark's import module and remove its usage of tools.stats.scribe (#61808)
Summary:
There're a few convoluted logic here to fix the `benchmarks`'s import module for pytest.
- On one hand, if we want to use `tools.stats.scribe` from `benchmarks`, we will need to add `benchmarks/__init__.py`
- On the other hand, if we add `benchmarks/__init__.py`, it breaks how `pytest` is working on searching what is the system built `torch` instead of the local source module `../torch`
- That's why we are seeing errors like
```
ImportError while loading conftest '/var/lib/jenkins/workspace/benchmarks/fastrnns/conftest.py'.
benchmarks/fastrnns/__init__.py:1: in <module>
from .cells import * # noqa: F403
benchmarks/fastrnns/cells.py:1: in <module>
import torch
torch/__init__.py:29: in <module>
from .torch_version import __version__ as __version__
torch/torch_version.py:9: in <module>
from .version import __version__ as internal_version
E ModuleNotFoundError: No module named 'torch.version'
```
Instead, this PR changed the usage of `upload_scribe.py` back to its original form using HTTP request, and only circleci for now will continue the this path using the `python benchmarks/upload_scribe.py`, which is gated by `if [[ -z "${GITHUB_ACTIONS}" ]];`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61808
Reviewed By: seemethere
Differential Revision: D29750188
Pulled By: zhouzhuojie
fbshipit-source-id: 3b842b21978f2159001e9c6c1cdc96c5a0515f2e
This commit is contained in:
parent
9c3346c8aa
commit
ac5a40e068
|
|
@ -395,9 +395,9 @@ test_benchmarks() {
|
|||
pytest benchmarks/fastrnns/test_bench.py --benchmark-sort=Name --benchmark-json=${BENCHMARK_DATA}/fastrnns_profiling_te.json --fuser=te --executor=profiling
|
||||
# TODO: Enable these for GHA once we have credentials for forked pull requests
|
||||
if [[ -z "${GITHUB_ACTIONS}" ]]; then
|
||||
python -m benchmarks.upload_scribe --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_default.json
|
||||
python -m benchmarks.upload_scribe --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_legacy_old.json
|
||||
python -m benchmarks.upload_scribe --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_profiling_te.json
|
||||
python benchmarks/upload_scribe.py --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_default.json
|
||||
python benchmarks/upload_scribe.py --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_legacy_old.json
|
||||
python benchmarks/upload_scribe.py --pytest_bench_json ${BENCHMARK_DATA}/fastrnns_profiling_te.json
|
||||
fi
|
||||
assert_git_not_dirty
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import argparse
|
|||
import time
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
from tools.stats.scribe import send_to_scribe
|
||||
|
||||
|
||||
class ScribeUploader:
|
||||
|
|
@ -30,6 +30,7 @@ class ScribeUploader:
|
|||
elif field in self.schema['float']:
|
||||
message['float'][field] = float(value)
|
||||
else:
|
||||
|
||||
raise ValueError("Field {} is not currently used, "
|
||||
"be intentional about adding new fields".format(field))
|
||||
return message
|
||||
|
|
@ -43,7 +44,15 @@ class ScribeUploader:
|
|||
def upload(self, messages):
|
||||
if os.environ.get('SCRIBE_INTERN'):
|
||||
return self._upload_intern(messages)
|
||||
logs = json.dumps(
|
||||
access_token = os.environ.get("SCRIBE_GRAPHQL_ACCESS_TOKEN")
|
||||
if not access_token:
|
||||
raise ValueError("Can't find access token from environment variable")
|
||||
url = "https://graph.facebook.com/scribe_logs"
|
||||
r = requests.post(
|
||||
url,
|
||||
data={
|
||||
"access_token": access_token,
|
||||
"logs": json.dumps(
|
||||
[
|
||||
{
|
||||
"category": self.category,
|
||||
|
|
@ -52,10 +61,11 @@ class ScribeUploader:
|
|||
}
|
||||
for message in messages
|
||||
]
|
||||
),
|
||||
},
|
||||
)
|
||||
res = send_to_scribe(logs)
|
||||
print(res)
|
||||
|
||||
print(r.text)
|
||||
r.raise_for_status()
|
||||
|
||||
class PytorchBenchmarkUploader(ScribeUploader):
|
||||
def __init__(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user