Skip to content
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
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
- name: Compile Xmipp will all dependencies in branch ${{ github.head_ref }} (if such branch exists, default is devel)
env:
BRANCH_NAME: ${{ github.head_ref }}
SEND_INSTALLATION_STATISTICS: 'OFF'
run: |
echo -e "XMIPP_LINK_TO_SCIPION=OFF\nSEND_INSTALLATION_STATISTICS=OFF" > xmipp.conf
./xmipp all -b $BRANCH_NAME --keep-output || (cat compilation.log && false)

- name: Cat
run: cat xmipp.conf
19 changes: 11 additions & 8 deletions installer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ def sendApiPOST(retCode: int=0):
url = url[0]
conn = http.client.HTTPSConnection(url, timeout=2, context=ssl._create_unverified_context()) # Unverified context because url does not have an ssl certificate

# Send the POST request
conn.request("POST", path, params, headers)

# Get response from server
conn.getresponse()

# Close the connection
conn.close()
try:
# Send the POST request
conn.request("POST", path, params, headers)

# Get response from server
conn.getresponse()

# Close the connection
conn.close()
except Exception as e:
pass

####################### UTILS FUNCTIONS #######################
def getOSReleaseName() -> str:
Expand Down
13 changes: 8 additions & 5 deletions installer/constants/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from .main import INSTALL_PATH

# Variable names
__SEND_INSTALLATION_STATISTICS = 'SEND_INSTALLATION_STATISTICS'
SEND_INSTALLATION_STATISTICS = 'SEND_INSTALLATION_STATISTICS'
__SEND_INSTALLATION_STATISTICS_ENV = 'SEND_INSTALLATION_STATISTICS'
CMAKE = 'CMAKE'
CC = 'CMAKE_C_COMPILER'
CXX = 'CMAKE_CXX_COMPILER'
Expand Down Expand Up @@ -64,7 +65,7 @@
COMPILATION_FLAGS = 'flags'
CONFIG_VARIABLES = {
TOGGLES: [
__SEND_INSTALLATION_STATISTICS, CUDA, MPI, MATLAB, LINK_SCIPION, __BUILD_TESTING, __SKIP_RPATH
__SEND_INSTALLATION_STATISTICS_ENV, CUDA, MPI, MATLAB, LINK_SCIPION, __BUILD_TESTING, __SKIP_RPATH
],
LOCATIONS: [
CMAKE, CC, CXX, CMAKE_INSTALL_PREFIX, __PREFIX_PATH, __MPI_HOME,
Expand Down Expand Up @@ -99,13 +100,15 @@ def __getCudaCompiler() -> Optional[str]:
nvcc = os.path.join(nvcc, __NVCC_EXE)

return nvcc


def __getSendStatistics():
return os.environ.get(__SEND_INSTALLATION_STATISTICS_ENV, ON)


ON = 'ON'
OFF = 'OFF'
CONFIG_DEFAULT_VALUES = {
__SEND_INSTALLATION_STATISTICS: ON,
__SEND_INSTALLATION_STATISTICS_ENV: __getSendStatistics(),
CMAKE: None,
CUDA: ON,
MPI: ON,
Expand All @@ -131,4 +134,4 @@ def __getCudaCompiler() -> Optional[str]:
}

# Do not pass this variables to CMake, only for installer logic
INTERNAL_LOGIC_VARS = [__SEND_INSTALLATION_STATISTICS, CMAKE]
INTERNAL_LOGIC_VARS = [__SEND_INSTALLATION_STATISTICS_ENV, CMAKE]
28 changes: 16 additions & 12 deletions xmipp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from installer.constants import (MODE_ALL, MODE_COMPILE_AND_INSTALL, MODE_CONFIG
PARAM_JOBS, PARAM_BRANCH, PARAM_GIT_COMMAND, PARAM_TEST_PRO, PARAM_TEST_PRO, PARAM_TEST_FUNC, PARAM_MODEL_PATH,
PARAM_MODELS_DIRECTORY, PARAM_KEEP_OUTPUT, PARAM_SHOW_TESTS, PARAM_TEST_NAME, PARAM_UPDATE,
PARAM_OVERWRITE, BUILD_PATH, INSTALL_PATH, BUILD_TYPE, SOURCES_PATH, XMIPP_SOURCES, XMIPP,
LOG_FILE, CMAKE_ERROR, MODE_GET_SOURCES, VERSION_FILE, PARAMS, LONG_VERSION, SHORT_VERSION)
LOG_FILE, CMAKE_ERROR, MODE_GET_SOURCES, VERSION_FILE, PARAMS, LONG_VERSION, SHORT_VERSION, SEND_INSTALLATION_STATISTICS)
from installer.utils import runStreamingJob, runJob
from installer.parser import ModeHelpFormatter, GeneralHelpFormatter, ErrorHandlerArgumentParser, getParamNames
from installer.config import readConfig, writeConfig
Expand Down Expand Up @@ -122,22 +122,25 @@ def modeCompileAndInstall(args: argparse.Namespace, configDict: Dict={}):
logger.startLogFile(LOG_FILE)
configDict = readConfig(CONFIG_FILE)
if not getCMake(configDict):
handleRetCode(CMAKE_ERROR, predefinedErrorCode=CMAKE_ERROR)
apiPost = True if configDict.get(SEND_INSTALLATION_STATISTICS) == 'ON' else False
handleRetCode(CMAKE_ERROR, predefinedErrorCode=CMAKE_ERROR, sendAPI=apiPost)

# Compile with CMake
cmakeExecutable = getCMake(configDict)
logger(getSectionMessage("Compiling with CMake"), forceConsoleOutput=True)
retCode = runStreamingJob(f"{cmakeExecutable} --build {BUILD_PATH} --config {BUILD_TYPE} -j {args.jobs}",
showOutput=True, substitute=True)
handleRetCode(retCode, predefinedErrorCode=CMAKE_COMPILE_ERROR)
apiPost = True if configDict.get(
SEND_INSTALLATION_STATISTICS) == 'ON' else False
handleRetCode(retCode, predefinedErrorCode=CMAKE_COMPILE_ERROR, sendAPI=apiPost)

# Install with CMake
logger(getSectionMessage("Installing with CMake"), forceConsoleOutput=True)
retCode = runStreamingJob(f"{cmakeExecutable} --install {BUILD_PATH} --config {BUILD_TYPE}",
showOutput=True, substitute=True)
handleRetCode(retCode, predefinedErrorCode=CMAKE_INSTALL_ERROR)
handleRetCode(retCode, predefinedErrorCode=CMAKE_INSTALL_ERROR, sendAPI=apiPost)

def modeConfigBuild(configDict: Dict={}):
def modeConfigBuild(configDict: Dict={}, sendAPIPost: bool=False):
"""
### Configures the project using CMake.

Expand All @@ -153,13 +156,13 @@ def modeConfigBuild(configDict: Dict={}):
# Check if CMake exists
cmakeExecutable = getCMake(configDict)
if not getCMake(configDict):
handleRetCode(CMAKE_ERROR, predefinedErrorCode=CMAKE_ERROR)
handleRetCode(CMAKE_ERROR, predefinedErrorCode=CMAKE_ERROR, sendAPI=sendAPIPost)

logger(getSectionMessage("Configuring with CMake"), forceConsoleOutput=True)
configureCmd = f"{cmakeExecutable} -S . -B {BUILD_PATH} -D CMAKE_BUILD_TYPE={BUILD_TYPE}"
configureCmd += f" {getCMakeVarsStr(configDict)}"
retCode = runStreamingJob(configureCmd, showOutput=True, substitute=True)
handleRetCode(retCode, predefinedErrorCode=CMAKE_CONFIGURE_ERROR)
handleRetCode(retCode, predefinedErrorCode=CMAKE_CONFIGURE_ERROR, sendAPI=sendAPIPost)

def modeConfig(overwrite: bool=False) -> Dict:
"""
Expand Down Expand Up @@ -232,7 +235,6 @@ def modeTest(args: argparse.Namespace):
logger("Running all tests--------------------------------------", forceConsoleOutput=True)
runTests(PARAMS[PARAM_TEST_PRO][LONG_VERSION])
elif args.allFuncs:
print(args.allPrograms)
runTests(PARAMS[PARAM_TEST_FUNC][LONG_VERSION])

elif args.testName:
Expand Down Expand Up @@ -265,7 +267,7 @@ def modeAll(args: argparse.Namespace):
modeGetSources(args)

# Configure with CMake
modeConfigBuild(configDict=configDict)
modeConfigBuild(configDict=configDict, sendAPIPost=True)

# Compile and install with CMake
modeCompileAndInstall(args, configDict=configDict)
Expand All @@ -282,8 +284,8 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
if args.mode == MODE_ADD_MODEL:
modeAddModel(args)
elif args.mode == MODE_ALL:
modeAll(args)
sendAPI = True
modeAll(args)
elif args.mode == MODE_CLEAN_ALL:
modeCleanAll()
elif args.mode == MODE_CLEAN_BIN:
Expand All @@ -292,8 +294,8 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
modeCompileAndInstall(args)
sendAPI = True
elif args.mode == MODE_CONFIG_BUILD:
modeConfigBuild()
sendAPI = True
modeConfigBuild()
elif args.mode == MODE_CONFIG:
modeConfig(overwrite=args.overwrite)
elif args.mode == MODE_GET_MODELS:
Expand All @@ -312,7 +314,9 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
exitXmipp(retCode=1)

# Send API message
if sendAPI and os.path.exists(VERSION_FILE):
apiPost = True if readConfig(CONFIG_FILE).get(
SEND_INSTALLATION_STATISTICS) == 'ON' else False
if sendAPI and apiPost and os.path.exists(VERSION_FILE):
sendApiPOST()

# Print success message for specific modes
Expand Down