-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add first draft of the offline mode with 1.0 * pep8 * improve offline cli and refactor the way to launch spark applications * pep8
- Loading branch information
Showing
16 changed files
with
478 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
37 changes: 37 additions & 0 deletions
37
fink_fat/command_line/cli_main/offline_fitroid/launch_roid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if __name__ == "__main__": | ||
import os | ||
import sys | ||
from fink_fat.others.utils import init_logging | ||
from fink_fat.command_line.utils_cli import init_cli | ||
import fink_fat.others.launch_spark as spark | ||
|
||
logger = init_logging() | ||
|
||
year, month, day = sys.argv[1], sys.argv[2], sys.argv[3] | ||
path_offline = sys.argv[4] | ||
path_config = sys.argv[5] | ||
verbose = sys.argv[6] | ||
|
||
config, output_path = init_cli({"--config": path_config}) | ||
|
||
application = os.path.join( | ||
path_offline, | ||
"run_roid.py", | ||
) | ||
|
||
application += " " + year | ||
application += " " + month | ||
application += " " + day | ||
application += " " + path_config | ||
|
||
spark_submit = spark.build_spark_submit(config) | ||
spark_app = spark.spark_submit_application(spark_submit, application) | ||
process = spark.run_spark_submit(spark_app, verbose) | ||
|
||
if process.returncode != 0: | ||
logger = init_logging() | ||
logger.error(f""" | ||
Offline launch roid spark_submit exited with a non-zero return code: {process.returncode} | ||
""") | ||
logger.info(process.stderr) | ||
logger.info(process.stdout) |
49 changes: 49 additions & 0 deletions
49
fink_fat/command_line/cli_main/offline_fitroid/offline_fitroid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import datetime | ||
import os | ||
import subprocess | ||
from fink_fat.others.utils import LoggerNewLine | ||
import fink_fat | ||
import configparser | ||
import pathlib | ||
|
||
from fink_fat.others.utils import init_logging | ||
|
||
|
||
def offline_fitroid( | ||
config: configparser.ConfigParser, | ||
path_config: str, | ||
start_date: datetime, | ||
end_date: datetime, | ||
logger: LoggerNewLine, | ||
verbose: bool, | ||
): | ||
if verbose: | ||
logger.info( | ||
f""" | ||
--- START FITROID OFFLINE --- | ||
start date: {start_date} | ||
end date: {end_date} | ||
""" | ||
) | ||
logger.newline() | ||
|
||
ff_path = os.path.dirname(fink_fat.__file__) | ||
offline_path = os.path.join(ff_path, "command_line", "cli_main", "offline_fitroid") | ||
|
||
log_path = config["OFFLINE"]["log_path"] | ||
if not os.path.isdir(log_path): | ||
pathlib.Path(log_path).mkdir(parents=True) | ||
|
||
proc = subprocess.run( | ||
os.path.join( | ||
offline_path, | ||
f"run_offline_fitroid.sh {str(start_date)} {str(end_date)} {offline_path} {path_config} {log_path} {verbose}", | ||
), | ||
shell=True, | ||
) | ||
|
||
if proc.returncode != 0: | ||
logger = init_logging() | ||
logger.info(proc.stderr) | ||
logger.info(proc.stdout) | ||
return |
Oops, something went wrong.