ortools.sat.colab.flags
Collection of helpers to manage absl flags in colab.
1#!/usr/bin/env python3 2# Copyright 2010-2025 Google LLC 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Collection of helpers to manage absl flags in colab.""" 16 17 18class NotebookStringFlag: 19 """Stub for absl flag to be used within a jupyter notebook.""" 20 21 def __init__(self, name: str, value: str, doc: str): 22 self.__name = name 23 self.__value = value 24 self.__doc__ = doc 25 26 @property 27 def value(self) -> str: 28 """Returns the value passed at creation.""" 29 return self.__value 30 31 @property 32 def name(self) -> str: 33 """Returns the name of the parameter.""" 34 return self.__name 35 36 37def define_string(name: str, value: str, doc: str): 38 return NotebookStringFlag(name, value, doc) 39 40 41class NotebookIntFlag: 42 """Stub for absl flag to be used within a jupyter notebook.""" 43 44 def __init__(self, name: str, value: int, doc: str): 45 self.__name = name 46 self.__value = value 47 self.__doc__ = doc 48 49 @property 50 def value(self) -> int: 51 """Returns the value passed at creation.""" 52 return self.__value 53 54 @property 55 def name(self) -> str: 56 """Returns the name of the parameter.""" 57 return self.__name 58 59 60def define_integer(name: str, value: int, doc: str): 61 return NotebookIntFlag(name, value, doc) 62 63 64class NotebookFloatFlag: 65 """Stub for absl flag to be used within a jupyter notebook.""" 66 67 def __init__(self, name: str, value: float, doc: str): 68 self.__name = name 69 self.__value = value 70 self.__doc__ = doc 71 72 @property 73 def value(self) -> float: 74 """Returns the value passed at creation.""" 75 return self.__value 76 77 @property 78 def name(self) -> str: 79 """Returns the name of the parameter.""" 80 return self.__name 81 82 83def define_float(name: str, value: bool, doc: str): 84 return NotebookFloatFlag(name, value, doc) 85 86 87class NotebookBoolFlag: 88 """Stub for absl flag to be used within a jupyter notebook.""" 89 90 def __init__(self, name: str, value: bool, doc: str): 91 self.__name = name 92 self.__value = value 93 self.__doc__ = doc 94 95 @property 96 def value(self) -> bool: 97 """Returns the value passed at creation.""" 98 return self.__value 99 100 @property 101 def name(self) -> str: 102 """Returns the name of the parameter.""" 103 return self.__name 104 105 106def define_bool(name: str, value: bool, doc: str): 107 return NotebookBoolFlag(name, value, doc)
class
NotebookStringFlag:
19class NotebookStringFlag: 20 """Stub for absl flag to be used within a jupyter notebook.""" 21 22 def __init__(self, name: str, value: str, doc: str): 23 self.__name = name 24 self.__value = value 25 self.__doc__ = doc 26 27 @property 28 def value(self) -> str: 29 """Returns the value passed at creation.""" 30 return self.__value 31 32 @property 33 def name(self) -> str: 34 """Returns the name of the parameter.""" 35 return self.__name
Stub for absl flag to be used within a jupyter notebook.
def
define_string(name: str, value: str, doc: str):
class
NotebookIntFlag:
42class NotebookIntFlag: 43 """Stub for absl flag to be used within a jupyter notebook.""" 44 45 def __init__(self, name: str, value: int, doc: str): 46 self.__name = name 47 self.__value = value 48 self.__doc__ = doc 49 50 @property 51 def value(self) -> int: 52 """Returns the value passed at creation.""" 53 return self.__value 54 55 @property 56 def name(self) -> str: 57 """Returns the name of the parameter.""" 58 return self.__name
Stub for absl flag to be used within a jupyter notebook.
def
define_integer(name: str, value: int, doc: str):
class
NotebookFloatFlag:
65class NotebookFloatFlag: 66 """Stub for absl flag to be used within a jupyter notebook.""" 67 68 def __init__(self, name: str, value: float, doc: str): 69 self.__name = name 70 self.__value = value 71 self.__doc__ = doc 72 73 @property 74 def value(self) -> float: 75 """Returns the value passed at creation.""" 76 return self.__value 77 78 @property 79 def name(self) -> str: 80 """Returns the name of the parameter.""" 81 return self.__name
Stub for absl flag to be used within a jupyter notebook.
def
define_float(name: str, value: bool, doc: str):
class
NotebookBoolFlag:
88class NotebookBoolFlag: 89 """Stub for absl flag to be used within a jupyter notebook.""" 90 91 def __init__(self, name: str, value: bool, doc: str): 92 self.__name = name 93 self.__value = value 94 self.__doc__ = doc 95 96 @property 97 def value(self) -> bool: 98 """Returns the value passed at creation.""" 99 return self.__value 100 101 @property 102 def name(self) -> str: 103 """Returns the name of the parameter.""" 104 return self.__name
Stub for absl flag to be used within a jupyter notebook.
def
define_bool(name: str, value: bool, doc: str):