Skip to content

Commit

Permalink
Add examples telemetry (huggingface#17552)
Browse files Browse the repository at this point in the history
* Add examples telemetry

* Alternative approach

* Add to all other examples

* Add to templates as well

* Put framework separately

* Same for TensorFlow
  • Loading branch information
sgugger authored and elusenji committed Jun 12, 2022
1 parent ed3ccaa commit 3c8bb28
Show file tree
Hide file tree
Showing 53 changed files with 299 additions and 57 deletions.
6 changes: 5 additions & 1 deletion examples/flax/image-captioning/run_image_captioning_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
HfArgumentParser,
is_tensorboard_available,
)
from transformers.utils import get_full_repo_name, is_offline_mode
from transformers.utils import get_full_repo_name, is_offline_mode, send_example_telemetry


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -388,6 +388,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_image_captioning", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/language-modeling/run_clm_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
set_seed,
)
from transformers.testing_utils import CaptureLogger
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -328,6 +328,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_clm", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/language-modeling/run_mlm_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
is_tensorboard_available,
set_seed,
)
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry


MODEL_CONFIG_CLASSES = list(FLAX_MODEL_FOR_MASKED_LM_MAPPING.keys())
Expand Down Expand Up @@ -365,6 +365,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_mlm", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/language-modeling/run_t5_mlm_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
set_seed,
)
from transformers.models.t5.modeling_flax_t5 import shift_tokens_right
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry


MODEL_CONFIG_CLASSES = list(FLAX_MODEL_FOR_MASKED_LM_MAPPING.keys())
Expand Down Expand Up @@ -498,6 +498,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_t5_mlm", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/question-answering/run_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
PreTrainedTokenizerFast,
is_tensorboard_available,
)
from transformers.utils import check_min_version, get_full_repo_name
from transformers.utils import check_min_version, get_full_repo_name, send_example_telemetry
from utils_qa import postprocess_qa_predictions


Expand Down Expand Up @@ -424,6 +424,10 @@ def main():
model_args, data_args, training_args = parser.parse_json_file(json_file=os.path.abspath(sys.argv[1]))
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_qa", model_args, data_args, framework="flax")
# endregion

# region Logging
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/summarization/run_summarization_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
HfArgumentParser,
is_tensorboard_available,
)
from transformers.utils import get_full_repo_name, is_offline_mode
from transformers.utils import get_full_repo_name, is_offline_mode, send_example_telemetry


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -399,6 +399,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_summarization", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/text-classification/run_flax_glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
TrainingArguments,
is_tensorboard_available,
)
from transformers.utils import check_min_version, get_full_repo_name
from transformers.utils import check_min_version, get_full_repo_name, send_example_telemetry


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -308,6 +308,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_glue", model_args, data_args, framework="flax")

# Make one log on every process with the configuration for debugging.
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/token-classification/run_flax_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
HfArgumentParser,
is_tensorboard_available,
)
from transformers.utils import check_min_version, get_full_repo_name
from transformers.utils import check_min_version, get_full_repo_name, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -366,6 +366,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_ner", model_args, data_args, framework="flax")

# Make one log on every process with the configuration for debugging.
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/flax/vision/run_image_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
is_tensorboard_available,
set_seed,
)
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -256,6 +256,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_image_classification", model_args, data_args, framework="flax")

if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
set_seed,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -197,6 +197,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_audio_classification", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/contrastive-image-text/run_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
set_seed,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -233,6 +233,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_clip", model_args, data_args)

# 2. Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
TrainingArguments,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -175,6 +175,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_image_classification", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
SchedulerType,
get_scheduler,
)
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -201,6 +201,10 @@ def parse_args():
def main():
args = parse_args()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_image_classification_no_trainer", args)

# Initialize the accelerator. We will let the accelerator handle device placement for us in this example.
# If we're using tracking, we also need to initialize it here and it will by default pick up all supported trackers
# in the environment
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/image-pretraining/run_mae.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ViTMAEForPreTraining,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -175,6 +175,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_mae", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/image-pretraining/run_mim.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
TrainingArguments,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -239,6 +239,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_mim", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)
from transformers.testing_utils import CaptureLogger
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -214,6 +214,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_clm", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/language-modeling/run_clm_no_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
default_data_collator,
get_scheduler,
)
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -239,6 +239,10 @@ def parse_args():
def main():
args = parse_args()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_clm_no_trainer", args)

# Initialize the accelerator. We will let the accelerator handle device placement for us in this example.
# If we're using tracking, we also need to initialize it here and it will by default pick up all supported trackers
# in the environment
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/language-modeling/run_mlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
set_seed,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -224,6 +224,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_mlm", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/language-modeling/run_mlm_no_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
SchedulerType,
get_scheduler,
)
from transformers.utils import get_full_repo_name
from transformers.utils import get_full_repo_name, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -248,6 +248,10 @@ def parse_args():
def main():
args = parse_args()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_mlm_no_trainer", args)

# Initialize the accelerator. We will let the accelerator handle device placement for us in this example.
# If we're using tracking, we also need to initialize it here and it will by default pick up all supported trackers
# in the environment
Expand Down
6 changes: 5 additions & 1 deletion examples/pytorch/language-modeling/run_plm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
set_seed,
)
from transformers.trainer_utils import get_last_checkpoint
from transformers.utils import check_min_version
from transformers.utils import check_min_version, send_example_telemetry
from transformers.utils.versions import require_version


Expand Down Expand Up @@ -220,6 +220,10 @@ def main():
else:
model_args, data_args, training_args = parser.parse_args_into_dataclasses()

# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
# information sent is the one passed as arguments along with your Python/PyTorch versions.
send_example_telemetry("run_plm", model_args, data_args)

# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
Expand Down
Loading

0 comments on commit 3c8bb28

Please sign in to comment.