Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
c037dcc
add a deprefix helper and some unit tests
MoralCode May 8, 2026
d62214b
refactor into a better prefix extraction helper
MoralCode May 8, 2026
4a3d431
add first pass SystemEnv
MoralCode May 8, 2026
61a564f
allow different prefixes to be passed in for testing purposes
MoralCode May 8, 2026
e8cc02f
update deprecation message
MoralCode May 8, 2026
b2f99ca
basic functionality unit tests
MoralCode May 8, 2026
7a737fc
handle cases with no known prefix to avoid breaking stuff
MoralCode May 8, 2026
f6109aa
factor out bool fetching class to deduplicate logic
MoralCode May 8, 2026
67ddbfd
Test to make sure we can potentially migrate the AUGUR_ vars in the c…
MoralCode May 8, 2026
ddb0ef5
replace all references to os.getenv with new class
MoralCode May 8, 2026
5b04de6
deprecate older Environment class that is buried in the module tree
MoralCode May 8, 2026
827dfb9
get_bool docstring
MoralCode May 8, 2026
1963d35
basic setter
MoralCode May 8, 2026
9650906
replace references to os.environ[] with new class
MoralCode May 8, 2026
dc16079
remove some redundant wrapping code
MoralCode May 8, 2026
1bb1de2
replace references to os.environ.get
MoralCode May 8, 2026
f5b5019
Swap out only usage of deprecated Environment class
MoralCode May 8, 2026
202465c
Remove no-longer-used Environment class in API
MoralCode May 8, 2026
da765da
Refactor extract_prefix
MoralCode May 29, 2026
b3e92a2
refactor get_bool
MoralCode May 29, 2026
21a34f1
fix ~ path expansion in default scorecard value
MoralCode May 29, 2026
8945ef8
replace a bunch of env var names the application accesses
MoralCode May 20, 2026
27fd27e
update env var names in RST docs
MoralCode May 20, 2026
bef5639
update vars in example env
MoralCode May 27, 2026
6fd7ee0
update variable names in docker compose
MoralCode May 27, 2026
0aa0d8a
hard change env var prefix for CLI commands
MoralCode May 29, 2026
110f42b
attempt to add transitional variables for the specific existing place…
MoralCode May 29, 2026
f3ff5a3
factor tests into a class
MoralCode May 29, 2026
75345cb
import SystemEnv into celery_app
MoralCode May 29, 2026
bcff419
move test next to the actual known good config tests
MoralCode May 29, 2026
3351859
add more detailed failure reasons to get_bool tests
MoralCode May 29, 2026
3585e50
split environment tests into two classes
MoralCode May 29, 2026
19984f2
apply homedir resolution fix to SCC path as well
MoralCode May 29, 2026
c2b6215
fix docs underline lengths
MoralCode May 29, 2026
97d443c
remove unused imports
MoralCode May 29, 2026
e949c77
use SystemEnv for fetching database variable
MoralCode May 29, 2026
0b46bfb
update error messages surrounding DB access to refer to the new variable
MoralCode Jun 2, 2026
0b3aa2b
allow SystemEnv to set a default value
MoralCode Jun 9, 2026
4a30c75
create a stub of a helper function to check and init the schema
MoralCode Jun 2, 2026
4cf94bb
add stub for making sure the schema is updated
MoralCode Jun 2, 2026
71e74b7
move some entrypoint behavior into a variable collection helper
MoralCode Jun 2, 2026
009e092
Automatically populate gitlab data with nonfunctional values if they …
MoralCode Jun 2, 2026
c9924ec
move docker deploy variable to the dockerfile/composefile
MoralCode Jun 2, 2026
32033a0
provide default facade repo directory
MoralCode Jun 2, 2026
5fc3ecc
ensure facade repo directory is resolveable/absolute
MoralCode Jun 2, 2026
4747b8c
ensure facade repo directory has a trailing slash
MoralCode Jun 2, 2026
1d2910b
oops
MoralCode Jun 2, 2026
ba802c2
handle swapping localhosts for redis connection string too
MoralCode Jun 2, 2026
7e5fc18
entrypoint is now empty
MoralCode Jun 2, 2026
e4c13ef
provide excessive user feedback with verbose logging
MoralCode Jun 2, 2026
f7f7cb7
port over the facade config file handling into python
MoralCode Jun 2, 2026
ac5a57d
refactor config merging into a separate function so it could be reuse…
MoralCode Jun 2, 2026
a8280c2
config script no longer needed
MoralCode Jun 2, 2026
553f8a6
enable the basic schema update subshell for now
MoralCode Jun 5, 2026
62a8a16
add a platform information function
MoralCode Jun 5, 2026
85acff2
include new environment file in linted files list
MoralCode Jun 8, 2026
de12791
add function to detect and warn if files are present at the previous …
MoralCode Jun 8, 2026
52f8fe6
move remaining command in init into the docker init directive
MoralCode Jun 8, 2026
ce25502
remove old dockerfile entrypoint and init script infrastructure
MoralCode Jun 8, 2026
fcde27a
revert keyman orchestrator back to regular environment variables
MoralCode Jun 8, 2026
f3fe0e0
logger.verbose -> logger.debug
MoralCode Jun 8, 2026
aa02bda
ensure logger is correctly passed and all functions are imported
MoralCode Jun 9, 2026
a555f43
use logger to output version information
MoralCode Jun 9, 2026
1ff171f
open facade directory file in write mode
MoralCode Jun 9, 2026
faca04e
fix config bug with new startup process
MoralCode Jun 9, 2026
bcad37c
improve robustness of logger against missing log directories in config
MoralCode Jun 9, 2026
1f59f00
include logs directory environment variable in default compose
MoralCode Jun 9, 2026
e4ff788
correct translation error in git config command
MoralCode Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions collectoss/api/gunicorn_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from collectoss.application.db.lib import get_value
from collectoss.application.db import dispose_database_engine
from collectoss.application.environment import SystemEnv

logger = logging.getLogger(__name__)

Expand All @@ -20,8 +21,8 @@
workers = multiprocessing.cpu_count() * 2 + 1
umask = 0o007
reload = True

is_dev = os.getenv("AUGUR_DEV", 'False').lower() in ('true', '1', 't', 'y', 'yes')
# this satisfies the type checker
is_dev = SystemEnv.get_bool("AUGUR_DEV", False)

if is_dev:

Expand All @@ -40,7 +41,8 @@
# set the log location for gunicorn
logs_directory = get_value('Logging', 'logs_directory')

is_docker = os.getenv("AUGUR_DOCKER_DEPLOY", 'False').lower() in ('true', '1', 't', 'y', 'yes')
# this syntax satisfies the type checker
is_docker = SystemEnv.get_bool("AUGUR_DOCKER_DEPLOY", False)
accesslog = f"{logs_directory}/gunicorn.log"
errorlog = f"{logs_directory}/gunicorn.log"

Expand Down
10 changes: 6 additions & 4 deletions collectoss/api/routes/auggie.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import requests
import slack

from collectoss.application.environment import SystemEnv

from ..server import app


Expand Down Expand Up @@ -252,7 +254,7 @@ def get_auggie_user():
# return Response(response=response, status=200, mimetype="application/json")
## From Method
profile_name = 'collectoss'
if os.environ.get('AUGUR_IS_PROD'):
if SystemEnv.get('COLLECTOSS_IS_PROD'):
profile_name = 'default'
client = boto3.Session(region_name='us-east-1', profile_name=profile_name).client('dynamodb')
response = client.get_item(
Expand All @@ -278,7 +280,7 @@ def update_auggie_user_tracking():
# return Response(response=response, status=200, mimetype="application/json")
## From Method
profile_name = 'collectoss'
if os.environ.get('AUGUR_IS_PROD'):
if SystemEnv.get('COLLECTOSS_IS_PROD'):
profile_name = 'default'
client = boto3.Session(region_name='us-east-1', profile_name=profile_name).client('dynamodb')
response = client.update_item(
Expand Down Expand Up @@ -326,7 +328,7 @@ def slack_login():
print("slack_login")

r = requests.get(
url=f'https://slack.com/api/oauth.v2.access?code={body["code"]}&client_id={os.environ["AUGGIE_CLIENT_ID"]}&client_secret={os.environ["AUGGIE_CLIENT_SECRET"]}&redirect_uri=http%3A%2F%2Flocalhost%3A8080')
url=f'https://slack.com/api/oauth.v2.access?code={body["code"]}&client_id={SystemEnv.get("AUGGIE_CLIENT_ID")}&client_secret={SystemEnv.get("AUGGIE_CLIENT_SECRET")}&redirect_uri=http%3A%2F%2Flocalhost%3A8080')
data = r.json()

if (data["ok"]):
Expand All @@ -340,7 +342,7 @@ def slack_login():
email = user_response["user"]["email"]

profile_name = 'collectoss'
if os.environ.get('AUGUR_IS_PROD'):
if SystemEnv.get('COLLECTOSS_IS_PROD'):
profile_name = 'default'
print("Making Boto3 Session")
client = boto3.Session(region_name='us-east-1',
Expand Down
5 changes: 3 additions & 2 deletions collectoss/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from collectoss.application.logs import SystemLogger
from collectoss.application.db.session import DatabaseSession
from collectoss.application.config import SystemConfig
from collectoss.application.environment import SystemEnv
from collectoss.application.db.engine import get_database_string, create_database_engine
from collectoss.application.db.models import Repo, Issue, PullRequest, Message, PullRequestReview, Commit, IssueAssignee, PullRequestAssignee, PullRequestCommit, PullRequestFile, Contributor, IssueLabel, PullRequestLabel, ContributorsAlias, Release, ClientApplication

Expand Down Expand Up @@ -300,8 +301,8 @@ def create_cache_manager() -> CacheManager:
cache_config = {
'cache.type': 'file',
# Allow setting cache directories via environment variables
'cache.data_dir': Path(env.setdefault("CACHE_DATADIR", 'runtime/cache/')),
'cache.lock_dir': Path(env.setdefault("CACHE_LOCKDIR", 'runtime/cache/')),
'cache.data_dir': Path(SystemEnv.set_default("CACHE_DATADIR", 'runtime/cache/')),
'cache.lock_dir': Path(SystemEnv.set_default("CACHE_LOCKDIR", 'runtime/cache/')),
}

if not os.path.exists(cache_config['cache.data_dir']):
Expand Down
7 changes: 2 additions & 5 deletions collectoss/api/view/init.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os
from pathlib import Path
from .server import Environment
from collectoss.application.logs import SystemLogger
import secrets, yaml

env = Environment()
from collectoss.application.environment import SystemEnv

# load configuration files and initialize globals
configFile = Path(env.setdefault("CONFIG_LOCATION", "config.yml"))
configFile = Path(SystemEnv.get("CONFIG_LOCATION") or "config.yml")

settings = {}

Expand Down
52 changes: 0 additions & 52 deletions collectoss/api/view/server/Environment.py

This file was deleted.

3 changes: 1 addition & 2 deletions collectoss/api/view/server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .LoginException import LoginException
from .Environment import Environment
from .LoginException import LoginException
8 changes: 5 additions & 3 deletions collectoss/application/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

from collectoss.application.db.engine import DatabaseEngine
from collectoss.application.db import get_engine, dispose_database_engine
from sqlalchemy.exc import OperationalError
from sqlalchemy.exc import OperationalError
from collectoss.application.environment import SystemEnv



def check_connectivity(urls=["http://chaoss.community", "http://github.com", "http://gitlab.com"], timeout=10.0):
Expand Down Expand Up @@ -65,11 +67,11 @@ def new_func(ctx, *args, **kwargs):
return ctx.invoke(function_db_connection, *args, **kwargs)
except OperationalError as e:

db_environment_var = os.getenv("AUGUR_DB")
db_environment_var = SystemEnv.get("COLLECTOSS_DB")

# determine the location to print in error string
if db_environment_var:
location = f"the AUGUR_DB environment variable\nAUGUR_DB={os.getenv('AUGUR_DB')}"
location = f"the COLLECTOSS_DB environment variable\nCOLLECTOSS_DB={SystemEnv.get('COLLECTOSS_DB')}"
else:
with open("db.config.json", 'r') as f:
db_config = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion collectoss/application/cli/_multicommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path
# import collectoss.application

CONTEXT_SETTINGS = dict(auto_envvar_prefix='AUGUR')
CONTEXT_SETTINGS = dict(auto_envvar_prefix='COLLECTOSS')

class CLIMultiCommand(click.MultiCommand):
def __commands_folder(self):
Expand Down
8 changes: 5 additions & 3 deletions collectoss/application/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from collectoss.application.cli import test_connection, test_db_connection, with_database, DatabaseContext
from collectoss.application.cli._cli_util import _broadcast_signal_to_processes, raise_open_file_limit, clear_redis_caches, clear_rabbitmq_messages
from collectoss.application.db.lib import get_value
from collectoss.application.environment import SystemEnv


logger = SystemLogger("collectoss", reset_logfiles=False).get_logger()

Expand All @@ -36,7 +38,7 @@ def start(ctx, development, port):
"""Start CollectOSS's backend server."""

try:
if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1":
if SystemEnv.get('COLLECTOSS_DOCKER_DEPLOY') != "1":
raise_open_file_limit(100000)
except Exception as e:
logger.error(
Expand All @@ -46,7 +48,7 @@ def start(ctx, development, port):
raise e

if development:
os.environ["AUGUR_DEV"] = "1"
SystemEnv.set("AUGUR_DEV", "1")
logger.info("Starting in development mode")

try:
Expand Down Expand Up @@ -142,7 +144,7 @@ def get_api_processes():
def is_api_process(process):

command = ''.join(process.info['cmdline'][:]).lower()
if os.getenv('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in command:
if SystemEnv.get('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in command:

if process.pid != os.getpid():

Expand Down
39 changes: 28 additions & 11 deletions collectoss/application/cli/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import requests
from redis.exceptions import ConnectionError as RedisConnectionError

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused ConnectionError imported from redis.exceptions as RedisConnectionError (unused-import)


from collectoss.application.environment import SystemEnv
from collectoss.tasks.start_tasks import collection_monitor, create_collection_status_records
from collectoss.tasks.git.facade_tasks import clone_repos
from collectoss.tasks.github.contributors import process_contributors
Expand All @@ -29,9 +30,10 @@
from collectoss.application.cli import test_connection, test_db_connection, with_database, DatabaseContext
import sqlalchemy as s

from collectoss.util.startup import check_init_schema, check_update_schema, collect_env_variables, print_platform_information, setup_facade_directory, warn_import_repos, merge_config
from keyman.KeyClient import KeyClient, KeyPublisher

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused KeyClient imported from keyman.KeyClient (unused-import)


reset_logs = os.getenv("AUGUR_RESET_LOGS", 'True').lower() in ('true', '1', 't', 'y', 'yes')
reset_logs = SystemEnv.get_bool("AUGUR_RESET_LOGS", True)

logger = SystemLogger("collectoss", reset_logfiles=reset_logs).get_logger()

Expand Down Expand Up @@ -60,8 +62,23 @@ def start(ctx, disable_collection, development, pidfile, port):
signal.signal(signal.SIGTERM, manager.shutdown_signal_handler)
signal.signal(signal.SIGINT, manager.shutdown_signal_handler)


collect_env_variables(logger)


check_init_schema()
check_update_schema()

setup_facade_directory(logger)

merge_config(ctx.obj.engine, logger)

warn_import_repos(logger)

print_platform_information(logger)

try:
if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1":
if SystemEnv.get('COLLECTOSS_DOCKER_DEPLOY') != "1":
raise_open_file_limit(100000)
except Exception as e:
logger.error(
Expand All @@ -71,10 +88,10 @@ def start(ctx, disable_collection, development, pidfile, port):
raise e

if development:
os.environ["AUGUR_DEV"] = "1"
SystemEnv.set("AUGUR_DEV", "1")
logger.info("Starting in development mode")

os.environ["AUGUR_PIDFILE"] = pidfile
SystemEnv.set("AUGUR_PIDFILE", pidfile)

try:
gunicorn_location = os.getcwd() + "/collectoss/api/gunicorn_conf.py"
Expand All @@ -86,10 +103,10 @@ def start(ctx, disable_collection, development, pidfile, port):
if not port:
port = get_value("Server", "port")

os.environ["AUGUR_PORT"] = str(port)
SystemEnv.set("AUGUR_PORT", str(port))

if disable_collection:
os.environ["AUGUR_DISABLE_COLLECTION"] = "1"
SystemEnv.set("AUGUR_DISABLE_COLLECTION", "1")

core_worker_count = get_value("Celery", 'core_worker_count')
secondary_worker_count = get_value("Celery", 'secondary_worker_count')
Expand Down Expand Up @@ -130,7 +147,7 @@ def start(ctx, disable_collection, development, pidfile, port):
processes = start_celery_worker_processes((core_worker_count, secondary_worker_count, facade_worker_count), disable_collection)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'processes' from outer scope (line 412) (redefined-outer-name)

manager.processes = processes

celery_beat_schedule_db = os.getenv("CELERYBEAT_SCHEDULE_DB", "celerybeat-schedule.db")
celery_beat_schedule_db = SystemEnv.get("CELERYBEAT_SCHEDULE_DB", "celerybeat-schedule.db")
if os.path.exists(celery_beat_schedule_db):
logger.info("Deleting old task schedule")
os.remove(celery_beat_schedule_db)
Expand All @@ -144,7 +161,7 @@ def start(ctx, disable_collection, development, pidfile, port):
manager.keypub = keypub

if not disable_collection:
if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1":
if SystemEnv.get('COLLECTOSS_DOCKER_DEPLOY') != "1":
orchestrator = subprocess.Popen("python keyman/Orchestrator.py".split())

# Wait for orchestrator startup
Expand Down Expand Up @@ -355,10 +372,10 @@ def export_env(config):
Exports your GitHub key and database credentials
"""

export_file = open(os.getenv('AUGUR_EXPORT_FILE', 'collectoss_export_env.sh'), 'w+')
export_file = open(SystemEnv.get('COLLECTOSS_EXPORT_FILE') or 'collectoss_export_env.sh', 'w+')
export_file.write('#!/bin/bash')
export_file.write('\n')
env_file = open(os.getenv('AUGUR_ENV_FILE', 'docker_env.txt'), 'w+')
env_file = open(SystemEnv.get('COLLECTOSS_ENV_FILE') or 'docker_env.txt', 'w+')

for env_var in config.get_env_config().items():
if "LOG" not in env_var[0]:
Expand Down Expand Up @@ -403,7 +420,7 @@ def get_backend_processes():
for process in psutil.process_iter(['cmdline', 'name', 'environ']):
if process.info['cmdline'] is not None and process.info['environ'] is not None:
try:
if os.getenv('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in ''.join(process.info['cmdline'][:]).lower():
if SystemEnv.get('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in ''.join(process.info['cmdline'][:]).lower():
if process.pid != os.getpid():
process_list.append(process)
except (KeyError, FileNotFoundError):
Expand Down
7 changes: 4 additions & 3 deletions collectoss/application/cli/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import traceback
import sqlalchemy as s

from collectoss.application.environment import SystemEnv
from collectoss.tasks.start_tasks import collection_monitor, create_collection_status_records
from collectoss.tasks.git.facade_tasks import clone_repos
from collectoss.tasks.github.util.github_api_key_handler import GithubApiKeyHandler
Expand Down Expand Up @@ -45,7 +46,7 @@ def start(ctx, development):
"""Start CollectOSS's backend server."""

try:
if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1":
if SystemEnv.get('COLLECTOSS_DOCKER_DEPLOY') != "1":
raise_open_file_limit(100000)
except Exception as e:
logger.error(
Expand Down Expand Up @@ -75,7 +76,7 @@ def start(ctx, development):
keypub.publish(key, "gitlab_rest")

if development:
os.environ["AUGUR_DEV"] = "1"
SystemEnv.set("AUGUR_DEV", "1")
logger.info("Starting in development mode")

core_worker_count = get_value("Celery", 'core_worker_count')
Expand Down Expand Up @@ -237,7 +238,7 @@ def get_collection_processes():
def is_collection_process(process):

command = ''.join(process.info['cmdline'][:]).lower()
if os.getenv('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in command:
if SystemEnv.get('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in command:
if process.pid != os.getpid():

if "collectossbackendcollection" in command or "celery_app.celery_appbeat" in command:
Expand Down
Loading
Loading