MCPcopy Index your code
hub / github.com/hunvreus/devpush / get_settings

Function get_settings

app/config.py:91–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90@lru_cache
91def get_settings():
92 settings = Settings()
93
94 # Set URL scheme based on environment
95 settings.url_scheme = "http" if settings.env == "development" else "https"
96
97 # CPU default/max normalization
98 if settings.default_cpus is not None and settings.default_cpus <= 0:
99 logger.warning("DEFAULT_CPUS must be > 0; ignoring and treating as unlimited.")
100 settings.default_cpus = None
101 if settings.max_cpus is not None and settings.max_cpus <= 0:
102 logger.warning("MAX_CPUS must be > 0; ignoring.")
103 settings.max_cpus = None
104 if settings.default_cpus is None and settings.max_cpus is not None:
105 logger.warning("MAX_CPUS is set but DEFAULT_CPUS is not; ignoring MAX_CPUS.")
106 settings.max_cpus = None
107 if settings.allow_custom_cpu:
108 default_cpus = settings.default_cpus
109 max_cpus = settings.max_cpus
110 if (
111 default_cpus is not None
112 and max_cpus is not None
113 and default_cpus > max_cpus
114 ):
115 logger.warning(
116 "DEFAULT_CPUS is greater than MAX_CPUS; clamping default to max."
117 )
118 settings.default_cpus = max_cpus
119
120 # Memory default/max normalization
121 if settings.default_memory_mb is not None and settings.default_memory_mb <= 0:
122 logger.warning(
123 "DEFAULT_MEMORY_MB must be > 0; ignoring and treating as unlimited."
124 )
125 settings.default_memory_mb = None
126 if settings.max_memory_mb is not None and settings.max_memory_mb <= 0:
127 logger.warning("MAX_MEMORY_MB must be > 0; ignoring.")
128 settings.max_memory_mb = None
129 if settings.default_memory_mb is None and settings.max_memory_mb is not None:
130 logger.warning(
131 "MAX_MEMORY_MB is set but DEFAULT_MEMORY_MB is not; ignoring MAX_MEMORY_MB."
132 )
133 settings.max_memory_mb = None
134 if settings.allow_custom_memory:
135 default_memory_mb = settings.default_memory_mb
136 max_memory_mb = settings.max_memory_mb
137 if (
138 default_memory_mb is not None
139 and max_memory_mb is not None
140 and default_memory_mb > max_memory_mb
141 ):
142 logger.warning(
143 "DEFAULT_MEMORY_MB is greater than MAX_MEMORY_MB; clamping default to max."
144 )
145 settings.default_memory_mb = max_memory_mb
146
147 # Directories/files normalization
148 if not settings.upload_dir:

Callers 15

db.pyFile · 0.90
get_github_serviceFunction · 0.90
get_github_oauth_clientFunction · 0.90
get_google_oauth_clientFunction · 0.90
get_redis_clientFunction · 0.90
dependencies.pyFile · 0.90
get_fernetFunction · 0.90
hostnameMethod · 0.90
urlMethod · 0.90
get_environment_urlMethod · 0.90
get_branch_hostnameMethod · 0.90

Calls 1

SettingsClass · 0.85

Tested by

no test coverage detected