How to use the vortexasdk.logger.get_logger function in vortexasdk

To help you get started, we’ve selected a few vortexasdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github V0RT3X4 / python-sdk / vortexasdk / endpoints / corporations_result.py View on Github external
from typing import List

import pandas as pd

from vortexasdk.api import Corporation
from vortexasdk.api.search_result import Result
from vortexasdk.logger import get_logger
from vortexasdk.result_conversions import create_dataframe, create_list

logger = get_logger(__name__)


class CorporationsResult(Result):
    """Container class that holds the result obtained from calling the `Vessels` endpoint."""

    def to_list(self) -> List[Corporation]:
        """Represent vessels as a list."""
        # noinspection PyTypeChecker
        return create_list(super().to_list(), Corporation)

    def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent corporations as a `pd.DataFrame`.

        # Arguments
            columns: The corporation features we want in the dataframe. Enter `columns='all'` to include all features.
github V0RT3X4 / python-sdk / vortexasdk / endpoints / attributes_result.py View on Github external
from typing import List

import pandas as pd

from vortexasdk.api import Attribute
from vortexasdk.api.search_result import Result
from vortexasdk.result_conversions import create_dataframe, create_list
from vortexasdk.logger import get_logger

logger = get_logger(__name__)


class AttributeResult(Result):
    """Container class that holds the result obtained from calling the `Attributes` endpoint."""

    def to_list(self) -> List[Attribute]:
        """Represent attributes as a list."""
        # noinspection PyTypeChecker
        return create_list(super().to_list(), Attribute)

    def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent attributes as a `pd.DataFrame`.

        # Arguments
            columns: The attributes features we want in the dataframe. Enter `columns='all'` to include all features.
github V0RT3X4 / python-sdk / vortexasdk / result_conversions.py View on Github external
from typing import Union, List

from vortexasdk.api.serdes import FromDictMixin
from vortexasdk.logger import get_logger

import pandas as pd

logger = get_logger(__name__)


def create_list(list_of_dicts, output_class: FromDictMixin) -> List:
    """Convert each list element into an instance of the output class."""
    logger.debug(f"Converting list of dictionaries to list of {output_class}")
    return [output_class.from_dict(d) for d in list_of_dicts]


def create_dataframe(
    columns: Union[None, List[str]],
    default_columns: List[str],
    data: List[dict],
    logger_description: str,
) -> pd.DataFrame:
    """
    :param columns: Columns to be used in the dataframe
github V0RT3X4 / python-sdk / vortexasdk / endpoints / vessel_movements_result.py View on Github external
import functools
import os
from multiprocessing.pool import Pool
from typing import List

import pandas as pd

from vortexasdk.api import VesselMovement
from vortexasdk.api.entity_flattening import (
    convert_vessel_movement_to_flat_dict,
)
from vortexasdk.api.search_result import Result
from vortexasdk.result_conversions import create_dataframe, create_list
from vortexasdk.logger import get_logger

logger = get_logger(__name__)


class VesselMovementsResult(Result):
    """
    Container class holdings search results returns from the vessel movements endpoint.

    This class has two methods, `to_list()`, and `to_df()`, allowing search results to be represented as a list of `VesselMovement`s,
     or as a `pd.DataFrame` , respectively.
    """

    def to_list(self) -> List[VesselMovement]:
        """Represent vessel movements as a list of `VesselMovementEntity`s."""
        # noinspection PyTypeChecker
        return create_list(super().to_list(), VesselMovement)

    def to_df(self, columns=None) -> pd.DataFrame:
github V0RT3X4 / python-sdk / vortexasdk / endpoints / geographies.py View on Github external
"""Geographies Endpoint."""
from typing import Dict, List, Union

from vortexasdk.logger import get_logger
from vortexasdk.api import ID
from vortexasdk.endpoints.endpoints import GEOGRAPHIES_REFERENCE
from vortexasdk.endpoints.geographies_result import GeographyResult
from vortexasdk.operations import Reference, Search
from vortexasdk.utils import convert_values_to_list

logger = get_logger(__name__)


class Geographies(Reference, Search):
    """Geographies endpoint."""

    def __init__(self):
        Reference.__init__(self, GEOGRAPHIES_REFERENCE)
        Search.__init__(self, GEOGRAPHIES_REFERENCE)

    def load_all(self) -> GeographyResult:
        """Load all geographies."""
        return self.search()

    def search(
        self,
        term: Union[str, List[str]] = None,
github V0RT3X4 / python-sdk / vortexasdk / endpoints / cargo_movements.py View on Github external
"""Cargo Movements Endpoint."""
from datetime import datetime
from typing import List, Union

from vortexasdk.api import ID
from vortexasdk.api.shared_types import to_ISODate
from vortexasdk.endpoints.cargo_movements_result import CargoMovementsResult
from vortexasdk.endpoints.endpoints import CARGO_MOVEMENTS_RESOURCE
from vortexasdk.logger import get_logger
from vortexasdk.operations import Search
from vortexasdk.utils import convert_to_list

logger = get_logger(__name__)


class CargoMovements(Search):
    """
    Cargo Movements Endpoint, use this to search through Vortexa's cargo movements.

    A detailed explanation of Cargo/Vessel Movements can be found [here](https://docs.vortexa.com/reference/intro-movement-difference).
    """

    _MAX_PAGE_RESULT_SIZE = 500

    def __init__(self):
        Search.__init__(self, CARGO_MOVEMENTS_RESOURCE)

    def search(
        self,
github V0RT3X4 / python-sdk / vortexasdk / conversions / conversions.py View on Github external
from typing import List

from vortexasdk.api import ID
from vortexasdk.api.id import split_ids_other
from vortexasdk.api.shared_types import IDsNames
from vortexasdk.logger import get_logger
from vortexasdk.operations import Search
from vortexasdk.utils import convert_to_list

logger = get_logger(__name__)


def _convert_to_ids(ids_or_names: IDsNames, searcher: Search) -> List[ID]:
    """Convert containing a mix of IDs and names to a list of IDs."""
    ids_or_names_list = convert_to_list(ids_or_names)

    ids, others = split_ids_other(ids_or_names_list)
    if len(others) == 0:
        return ids
    else:
        return ids + _search_ids(searcher, term=others)


def _search_ids(searcher: Search, **kwargs) -> List[ID]:
    """Find IDs matching a given list of search terms."""
    logger.info(
github V0RT3X4 / python-sdk / vortexasdk / endpoints / cargo_movements_result.py View on Github external
import functools
import os
from multiprocessing.pool import Pool
from typing import List

import pandas as pd

from vortexasdk.api import CargoMovement
from vortexasdk.api.entity_flattening import (
    convert_cargo_movement_to_flat_dict,
)
from vortexasdk.api.search_result import Result
from vortexasdk.result_conversions import create_dataframe, create_list
from vortexasdk.logger import get_logger

logger = get_logger(__name__)


class CargoMovementsResult(Result):
    """
    Container class holdings search results returns from the cargo movements endpoint.

    This class has two methods, `to_list()`, and `to_df()`, allowing search results to be represented as a list of `CargoMovements`,
     or as a `pd.DataFrame` , respectively.
    """

    def to_list(self) -> List[CargoMovement]:
        """Represent cargo movements as a list of `CargoMovementEntity`s."""
        # noinspection PyTypeChecker
        return create_list(super().to_list(), CargoMovement)

    def to_df(self, columns=None) -> pd.DataFrame:
github V0RT3X4 / python-sdk / vortexasdk / endpoints / vessel_movements.py View on Github external
"""Vessel Movements Endpoint."""
from datetime import datetime
from typing import List, Union

from vortexasdk.api import ID
from vortexasdk.api.shared_types import to_ISODate
from vortexasdk.endpoints.endpoints import VESSEL_MOVEMENTS_RESOURCE
from vortexasdk.endpoints.vessel_movements_result import VesselMovementsResult
from vortexasdk.logger import get_logger
from vortexasdk.operations import Search
from vortexasdk.utils import convert_to_list

logger = get_logger(__name__)


class VesselMovements(Search):
    """
    Vessel Movements Endpoint, use this to search through Vortexa's VesselMovements.

    A VesselMovement represents a single vessel moving between two locations.

    * The vessel may carry one cargo, many cargoes (coloads), or zero cargos (ballast).
    * The start and end locations for a VesselMovement may be on land (loadings and discharges), they may be STS Zones
    (STS events), or they may be Floating Storage.

    A detailed explanation of Cargo/Vessel Movements can be found [here](https://docs.vortexa.com/reference/intro-movement-difference).
    """

    _MAX_PAGE_RESULT_SIZE = 500
github V0RT3X4 / python-sdk / vortexasdk / endpoints / products_result.py View on Github external
from typing import List

import pandas as pd

from vortexasdk.api import Product
from vortexasdk.api.entity_flattening import flatten_dictionary
from vortexasdk.api.search_result import Result
from vortexasdk.logger import get_logger
from vortexasdk.result_conversions import create_dataframe, create_list

logger = get_logger(__name__)


class ProductResult(Result):
    """Container class that holds the result obtained from calling the `Product` endpoint."""

    def to_list(self) -> List[Product]:
        """Represent products as a list."""
        # noinspection PyTypeChecker
        return create_list(super().to_list(), Product)

    def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent products as a `pd.DataFrame`.

        # Arguments
            columns: The product features we want in the dataframe. Enter `columns='all'` to include all features.