tf.compat.v1.flags.mark_flag_as_required
Stay organized with collections
Save and categorize content based on your preferences.
Ensures that flag is not None during program execution.
tf.compat.v1.flags.mark_flag_as_required(
flag_name, flag_values=_flagvalues.FLAGS
)
Registers a flag validator, which will follow usual validator rules.
Important note: validator will pass for any non-None value, such as False,
0 (zero), '' (empty string) and so on.
It is recommended to call this method like this:
if name == 'main':
flags.mark_flag_as_required('your_flag_name')
app.run()
Because validation happens at app.run() we want to ensure required-ness
is enforced at that time. You generally do not want to force users who import
your code to have additional required flags for their own binaries or tests.
Args |
flag_name
|
str, name of the flag
|
flag_values
|
flags.FlagValues, optional FlagValues instance where the flag
is defined.
|
Raises |
AttributeError
|
Raised when flag_name is not registered as a valid flag
name.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.compat.v1.flags.mark_flag_as_required\n\n\u003cbr /\u003e\n\nEnsures that flag is not None during program execution.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.app.flags.mark_flag_as_required`](/api_docs/python/tf/compat/v1/flags/mark_flag_as_required)\n\n\u003cbr /\u003e\n\n tf.compat.v1.flags.mark_flag_as_required(\n flag_name, flag_values=_flagvalues.FLAGS\n )\n\nRegisters a flag validator, which will follow usual validator rules.\nImportant note: validator will pass for any non-None value, such as False,\n0 (zero), '' (empty string) and so on.\n\nIt is recommended to call this method like this:\n\nif **name** == '**main**':\nflags.mark_flag_as_required('your_flag_name')\napp.run()\n\nBecause validation happens at app.run() we want to ensure required-ness\nis enforced at that time. You generally do not want to force users who import\nyour code to have additional required flags for their own binaries or tests.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|---------------------------------------------------------------------------|\n| `flag_name` | str, name of the flag |\n| `flag_values` | flags.FlagValues, optional FlagValues instance where the flag is defined. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------------|---------------------------------------------------------------|\n| `AttributeError` | Raised when flag_name is not registered as a valid flag name. |\n\n\u003cbr /\u003e"]]