Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop logic for non-installed use case #1311

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 8 additions & 31 deletions cms/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,37 +162,14 @@ def __init__(self):
self.max_jobs_per_user = 10
self.pdf_printing_allowed = False

# Installed or from source?
# We declare we are running from installed if the program was
# NOT invoked through some python flavor, and the file is in
# the prefix (or real_prefix to accommodate virtualenvs).
bin_path = os.path.join(os.getcwd(), sys.argv[0])
bin_name = os.path.basename(bin_path)
bin_is_python = bin_name in ["ipython", "python", "python3"]
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
hasattr(sys, 'real_prefix')
and bin_path.startswith(sys.real_prefix))
self.installed = bin_in_installed_path and not bin_is_python

if self.installed:
self.log_dir = os.path.join("/", "var", "local", "log", "cms")
self.cache_dir = os.path.join("/", "var", "local", "cache", "cms")
self.data_dir = os.path.join("/", "var", "local", "lib", "cms")
self.run_dir = os.path.join("/", "var", "local", "run", "cms")
paths = [os.path.join("/", "usr", "local", "etc", "cms.conf"),
os.path.join("/", "etc", "cms.conf")]
else:
self.log_dir = "log"
self.cache_dir = "cache"
self.data_dir = "lib"
self.run_dir = "run"
paths = [os.path.join(".", "config", "cms.conf")]
if '__file__' in globals():
paths += [os.path.abspath(os.path.join(
os.path.dirname(__file__),
'..', 'config', 'cms.conf'))]
paths += [os.path.join("/", "usr", "local", "etc", "cms.conf"),
os.path.join("/", "etc", "cms.conf")]
self.log_dir = os.path.join("/", "var", "local", "log", "cms")
self.cache_dir = os.path.join("/", "var", "local", "cache", "cms")
self.data_dir = os.path.join("/", "var", "local", "lib", "cms")
self.run_dir = os.path.join("/", "var", "local", "run", "cms")
paths = [
os.path.join("/", "usr", "local", "etc", "cms.conf"),
os.path.join("/", "etc", "cms.conf"),
]

# Allow user to override config file path using environment
# variable 'CMS_CONFIG'.
Expand Down
5 changes: 0 additions & 5 deletions cms/service/ResourceService.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ def _restart_services(self):
logger.info("Restarting (%s, %s)...",
service.name, service.shard)
command = os.path.join(BIN_PATH, "cms%s" % service.name)
if not config.installed:
command = os.path.join(
".",
"scripts",
"cms%s" % service.name)
args = [command, "%d" % service.shard]
if self.contest_id is not None:
args += ["-c", str(self.contest_id)]
Expand Down
3 changes: 0 additions & 3 deletions cmscontrib/loaders/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ def get_task(self, get_statement=True):
os.path.dirname(checker_src), "checker")
testlib_path = "/usr/local/include/cms"
testlib_include = os.path.join(testlib_path, "testlib.h")
if not config.installed:
testlib_path = os.path.join(os.path.dirname(__file__),
"polygon")
code = subprocess.call(["g++", "-x", "c++", "-O2", "-static",
"-DCMS", "-I", testlib_path,
"-include", testlib_include,
Expand Down
31 changes: 6 additions & 25 deletions cmsranking/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,13 @@
# Buffers
self.buffer_size = 100 # Needs to be strictly positive.

# File system.
# TODO: move to cmscommon as it is used both here and in cms/conf.py
bin_path = os.path.join(os.getcwd(), sys.argv[0])
bin_name = os.path.basename(bin_path)
bin_is_python = bin_name in ["ipython", "python", "python3"]
bin_in_installed_path = bin_path.startswith(sys.prefix) or (
hasattr(sys, 'real_prefix')
and bin_path.startswith(sys.real_prefix))
self.installed = bin_in_installed_path and not bin_is_python

self.web_dir = pkg_resources.resource_filename("cmsranking", "static")
if self.installed:
self.log_dir = os.path.join("/", "var", "local", "log",
"cms", "ranking")
self.lib_dir = os.path.join("/", "var", "local", "lib",
"cms", "ranking")
self.conf_paths = [os.path.join("/", "usr", "local", "etc",
"cms.ranking.conf"),
os.path.join("/", "etc", "cms.ranking.conf")]
else:
self.log_dir = os.path.join("log", "ranking")
self.lib_dir = os.path.join("lib", "ranking")
self.conf_paths = [os.path.join(".", "config", "cms.ranking.conf"),
os.path.join("/", "usr", "local", "etc",
"cms.ranking.conf"),
os.path.join("/", "etc", "cms.ranking.conf")]
self.log_dir = os.path.join("/", "var", "local", "log", "cms", "ranking")
self.lib_dir = os.path.join("/", "var", "local", "lib", "cms", "ranking")
self.conf_paths = [

Check warning on line 63 in cmsranking/Config.py

View check run for this annotation

Codecov / codecov/patch

cmsranking/Config.py#L61-L63

Added lines #L61 - L63 were not covered by tests
os.path.join("/", "usr", "local", "etc", "cms.ranking.conf"),
os.path.join("/", "etc", "cms.ranking.conf"),
]

# Allow users to override config file path using environment
# variable 'CMS_RANKING_CONFIG'.
Expand Down