Esempio n. 1
0
def phase1(app_name):
    # Read the arguments
    args = parse_args()

    # Initialize Spark
    spark = SparkSession.builder.appName(app_name).getOrCreate()

    batting_team_data = get_batting_team_data(spark, args.year, args.min)
    data = batting_team_data.rdd.map(map_rc)
    dataframe = spark.createDataFrame(data, schema=["playerID", "RC", "RC27"])
    player_data = process_teams(spark, dataframe, args.attribute)
    write_phase(player_data, args.number, 1)
Esempio n. 2
0
def phase2(app_name):
    # Read the arguments
    args = parse_args()

    if args.year < 2017 or args.year > 2018:
        print("Year must be 2017 or 2018")
        return 1

    # Initialize Spark
    spark = SparkSession.builder.appName(app_name).getOrCreate()

    batting_team_data = get_batting_team_data(spark, args.year, args.min)
    data = batting_team_data.rdd.map(map_coefficients)
    dataframe = spark.createDataFrame(data, schema=["playerID", "RC", "RC27"])
    player_data = process_teams(spark, dataframe, args.attribute)
    write_phase(player_data, args.number, 2)
Esempio n. 3
0
def phase3(app_name):
    # Read the arguments
    args = parse_args()

    if args.year != 2018:
        print("Year must be 2018")
        return 1

    # Initialize Spark
    spark = SparkSession.builder.appName(app_name).getOrCreate()

    pitching_data = get_generated_pitching_data(spark, args.year, args.number)
    data = pitching_data.rdd.map(map_pitching_rc)
    dataframe = spark.createDataFrame(data, schema=["playerID", "RC", "RC27"])
    player_data = process_teams(spark, dataframe, args.attribute)
    write_phase(player_data, args.number, 3)
Esempio n. 4
0
def get_args():
    """
    Getting arguments from command and proceeding to log function

    Supports either:
    1) cities names list, iterated by comma
    2) file name (file located in root dir of the project)
    """
    full_cmd_arguments = sys.argv
    argument_list = full_cmd_arguments[1:]

    short_options = "hf:"
    long_options = ["help", "file="]

    try:
        cities_list = list()
        arguments, values = getopt.getopt(argument_list, short_options,
                                          long_options)

        if len(arguments) > 0:
            for current_argument, current_value in arguments:
                if current_argument in ("-h", "--help"):
                    print("Test task for Madgicx Company")
                    print(
                        "Gets cities names and returns short info about each")
                    print('Made by Russ Kovalchuk')
                    print('------------')
                    print(
                        'Use: \n '
                        'python madgicx_geo.py -f <file_path>\n'
                        ' python madgicx_geo.py <cities_names_iterated_with_commas>'
                    )
                elif current_argument in ("-f", "--file"):
                    print("Entering from file (%s)" % current_value)
                    cities_list = parse_file(current_value)
        else:
            cities_list = parse_args(argument_list)

        log_city_info(cities_list)

    except getopt.error as err:
        print(str(err))
        sys.exit(2)
Esempio n. 5
0
from common.utils import set_random_seed
from common.parse_args import parse_args


def main(args):

    module_name = importlib.import_module(args.alg_name)
    if args.test:
        module_name.test(args)
    else:
        module_name.train(args)


if __name__ == '__main__':
    args = parse_args()
    # for arg in vars(args):
    #     print('{}:{}'.format(arg, getattr(args, arg)))

    # Override args in test mode
    if args.test:
        args.use_wandb = False
        args.shuffle = False
        args.split_point = 'iterative'
        args.split_ratio = 0
        args.augment_trans = False
        args.augment_rotate = False
        args.random_remove = False
        args.augment_mirror = False
        # args.batch_size = 4
        args.save_voxels = True