Exemplo n.º 1
0
def load_fishing_gear_codes(fishing_gear_codes):
    load(
        fishing_gear_codes,
        table_name="fishing_gear_codes",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )
Exemplo n.º 2
0
def load_infractions(infractions):
    load(
        infractions,
        table_name="infractions",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )
Exemplo n.º 3
0
def load_species(species: pd.DataFrame):

    load(
        species,
        table_name="species",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )
Exemplo n.º 4
0
def load_controllers(controllers):

    load(
        controllers,
        table_name="controllers",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )
Exemplo n.º 5
0
def load_controls(controls):
    load(
        controls,
        table_name="controls",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        pg_array_columns=["infraction_ids"],
        jsonb_columns=["gear_controls"],
        delete_before_insert=True,
    )
Exemplo n.º 6
0
def load_current_segments(vessels_segments):  # pragma: no cover
    logger = prefect.context.get("logger")
    load(
        vessels_segments,
        table_name="current_segments",
        schema="public",
        db_name="monitorfish_remote",
        logger=logger,
        delete_before_insert=True,
        pg_array_columns=["segments"],
        handle_array_conversion_errors=True,
        value_on_array_conversion_error="{}",
        jsonb_columns=["gear_onboard", "species_onboard"],
    )
Exemplo n.º 7
0
def load_last_positions(last_positions):

    load(
        last_positions,
        table_name="last_positions",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
        pg_array_columns=["segments"],
        handle_array_conversion_errors=True,
        value_on_array_conversion_error="{}",
        jsonb_columns=["gear_onboard", "species_onboard"],
    )
Exemplo n.º 8
0
def load_segments(segments):
    load(
        segments,
        table_name="fleet_segments",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
        pg_array_columns=[
            "dirm",
            "gears",
            "fao_areas",
            "target_species",
            "bycatch_species",
            "flag_states",
        ],
    )
Exemplo n.º 9
0
def load_species_groups(species_groups, species_codes_groups):
    load(
        species_groups,
        table_name="species_groups",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )

    load(
        species_codes_groups,
        table_name="species_codes_groups",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
    )
Exemplo n.º 10
0
def load_vessels(all_vessels):
    all_vessels = all_vessels.astype({
        "imo":
        str,
        "cfr":
        str,
        "external_immatriculation":
        str,
        "mmsi":
        str,
        "ircs":
        str,
        "vessel_name":
        str,
        "flag_state":
        str,
        "width":
        float,
        "length":
        float,
        "district":
        str,
        "district_code":
        str,
        "gauge":
        float,
        "registry_port":
        str,
        "power":
        float,
        "vessel_type":
        str,
        "sailing_category":
        str,
        "sailing_type":
        str,
        "proprietor_name":
        str,
        "operator_name":
        str,
        "nav_licence_expiration_date":
        "datetime64[ns]",
    })

    all_vessels["width"] = np.asarray(all_vessels["width"])

    load(
        all_vessels,
        table_name="vessels",
        schema="public",
        db_name="monitorfish_remote",
        logger=prefect.context.get("logger"),
        delete_before_insert=True,
        pg_array_columns=[
            "declared_fishing_gears",
            "operator_phones",
            "operator_emails",
            "proprietor_phones",
            "proprietor_emails",
            "vessel_phones",
            "vessel_emails",
        ],
    )