Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup unused imports, sort other imports #171

Merged
merged 4 commits into from
Apr 24, 2023
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: 1 addition & 4 deletions nrel/hive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
"""

import logging

from pathlib import Path

from tqdm import tqdm

from nrel.hive.app import run
from nrel.hive.config import HiveConfig
from nrel.hive.dispatcher import *
from nrel.hive.state.simulation_state.update.update import Update
from nrel.hive.state.simulation_state.update.step_simulation import StepSimulation
from nrel.hive.state.simulation_state.update.update import Update


def package_root() -> Path:
Expand Down
5 changes: 1 addition & 4 deletions nrel/hive/app/hive_cosim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
from pathlib import Path
from typing import Iterable, Tuple, NamedTuple, Optional, TypeVar

import pandas as pd
from pandas import DataFrame
from tqdm import tqdm

from nrel.hive.dispatcher.instruction_generator.instruction_generator import InstructionGenerator
from nrel.hive.initialization.load import load_simulation, load_config
from nrel.hive.initialization.initialize_simulation import InitFunction
from nrel.hive.initialization.load import load_simulation, load_config
from nrel.hive.model.sim_time import SimTime
from nrel.hive.reporting.handler.vehicle_charge_events_handler import VehicleChargeEventsHandler
from nrel.hive.runner import RunnerPayload
from nrel.hive.util import SimulationStateError

T = TypeVar("T", bound=InstructionGenerator)

Expand Down
4 changes: 2 additions & 2 deletions nrel/hive/app/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import pkg_resources
import yaml

from nrel.hive.initialization.load import load_simulation, load_config
from nrel.hive.initialization.initialize_simulation import InitFunction
from nrel.hive.dispatcher.instruction_generator.instruction_generator import InstructionGenerator
from nrel.hive.initialization.initialize_simulation import InitFunction
from nrel.hive.initialization.load import load_simulation, load_config
from nrel.hive.runner.local_simulation_runner import LocalSimulationRunner

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion nrel/hive/app/run_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import yaml

from nrel.hive.initialization.load import load_config
from nrel.hive.app.run import run_sim
from nrel.hive.util import fs

Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/config/dispatcher_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import NamedTuple, Dict, Union, Tuple, Optional
from typing import NamedTuple, Dict, Tuple, Optional

from nrel.hive.config.config_builder import ConfigBuilder
from nrel.hive.dispatcher.instruction_generator.charging_search_type import ChargingSearchType
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/config/hive_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
from datetime import datetime
from pathlib import Path
from typing import NamedTuple, Dict, Union, Tuple, Optional
from typing import NamedTuple, Dict, Union, Optional

import pkg_resources
import yaml
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/config/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import hashlib
import logging
from pathlib import Path
from typing import NamedTuple, Tuple, Dict, Optional, Union
from typing import NamedTuple, Tuple, Dict, Optional

from nrel.hive.config.config_builder import ConfigBuilder
from nrel.hive.util import fs
Expand Down
4 changes: 2 additions & 2 deletions nrel/hive/config/sim.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

from typing import NamedTuple, Dict, Optional, Union, Tuple
from typing import NamedTuple, Dict, Optional, Tuple

from nrel.hive.config.config_builder import ConfigBuilder
from nrel.hive.model.vehicle.schedules.schedule_type import ScheduleType
from nrel.hive.model.sim_time import SimTime
from nrel.hive.model.vehicle.schedules.schedule_type import ScheduleType
from nrel.hive.util.units import Seconds


Expand Down
6 changes: 3 additions & 3 deletions nrel/hive/dispatcher/forecaster/basic_forecaster.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations
from dataclasses import dataclass

from dataclasses import dataclass
from pathlib import Path
from typing import Tuple, NamedTuple, TYPE_CHECKING
from typing import Tuple, TYPE_CHECKING

from nrel.hive.model.sim_time import SimTime
from nrel.hive.dispatcher.forecaster.forecast import Forecast, ForecastType
from nrel.hive.dispatcher.forecaster.forecaster_interface import ForecasterInterface
from nrel.hive.model.sim_time import SimTime
from nrel.hive.util.iterators import DictReaderStepper

if TYPE_CHECKING:
Expand Down
3 changes: 1 addition & 2 deletions nrel/hive/dispatcher/instruction/instruction_ops.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from __future__ import annotations

from typing import Tuple, Optional, FrozenSet, TYPE_CHECKING
import functools as ft

import logging
from typing import Tuple, Optional, FrozenSet, TYPE_CHECKING

from nrel.hive.model.vehicle.trip_phase import TripPhase
from nrel.hive.model.vehicle.vehicle import RequestId
Expand Down
1 change: 1 addition & 0 deletions nrel/hive/dispatcher/instruction/instruction_result.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import NamedTuple, TYPE_CHECKING

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/dispatcher/instruction/instructions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass

import logging
from dataclasses import dataclass
from typing import Optional, TYPE_CHECKING, Tuple

from nrel.hive.dispatcher.instruction.instruction import Instruction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import functools as ft
import logging
from typing import Dict, Tuple, Callable, NamedTuple, Optional, TYPE_CHECKING

import logging
import h3
import numpy as np
from scipy.optimize import linear_sum_assignment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass

import logging
from dataclasses import dataclass
from typing import Tuple, TYPE_CHECKING

from nrel.hive.reporting import instruction_generator_event_ops
Expand Down
4 changes: 2 additions & 2 deletions nrel/hive/dispatcher/instruction_generator/dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations
from dataclasses import dataclass

import logging
import functools as ft
import logging
from dataclasses import dataclass
from typing import Tuple, TYPE_CHECKING, Optional

from nrel.hive.dispatcher.instruction_generator import assignment_ops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from nrel.hive.dispatcher.instruction_generator import assignment_ops
from nrel.hive.dispatcher.instruction_generator.charging_search_type import ChargingSearchType
from nrel.hive.model.station.station import Station
from nrel.hive.util.h3_ops import H3Ops
from nrel.hive.util.dict_ops import DictOps
from nrel.hive.util.h3_ops import H3Ops
from nrel.hive.util.units import Kilometers

log = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions nrel/hive/initialization/initialize_ops.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import yaml
import immutables
from typing import TYPE_CHECKING, FrozenSet

import immutables
import yaml

if TYPE_CHECKING:
from nrel.hive.util.typealiases import EntityId, MembershipMap

Expand Down
10 changes: 5 additions & 5 deletions nrel/hive/initialization/initialize_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
)
from nrel.hive.model.base import Base
from nrel.hive.model.energy.charger import build_chargers_table
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork
from nrel.hive.model.station.station import Station
from nrel.hive.model.vehicle.mechatronics import build_mechatronics_table
from nrel.hive.model.vehicle.schedules import build_schedules_table
from nrel.hive.model.vehicle.vehicle import Vehicle
from nrel.hive.reporting.handler.eventful_handler import EventfulHandler
from nrel.hive.reporting.handler.instruction_handler import InstructionHandler
from nrel.hive.reporting.handler.stateful_handler import StatefulHandler
from nrel.hive.reporting.handler.stats_handler import StatsHandler
from nrel.hive.reporting.handler.time_step_stats_handler import TimeStepStatsHandler
from nrel.hive.reporting.reporter import Reporter
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork
from nrel.hive.model.station.station import Station
from nrel.hive.model.vehicle.mechatronics import build_mechatronics_table
from nrel.hive.model.vehicle.schedules import build_schedules_table
from nrel.hive.model.vehicle.vehicle import Vehicle
from nrel.hive.runner.environment import Environment
from nrel.hive.state.simulation_state import simulation_state_ops
from nrel.hive.state.simulation_state.simulation_state import SimulationState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
)
from nrel.hive.model.base import Base
from nrel.hive.model.energy.charger import build_chargers_table
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.geofence import GeoFence
from nrel.hive.model.roadnetwork.haversine_roadnetwork import HaversineRoadNetwork
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork
from nrel.hive.model.station.station import Station
from nrel.hive.model.vehicle.mechatronics import build_mechatronics_table
Expand Down
11 changes: 5 additions & 6 deletions nrel/hive/initialization/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
import yaml

from nrel.hive.config import HiveConfig
from nrel.hive.reporting import reporter_ops
from nrel.hive.dispatcher.instruction_generator.charging_fleet_manager import ChargingFleetManager
from nrel.hive.dispatcher.instruction_generator.dispatcher import Dispatcher
from nrel.hive.dispatcher.instruction_generator.instruction_generator import InstructionGenerator
from nrel.hive.initialization.initialize_simulation import (
default_init_functions,
osm_init_function,
initialize,
InitFunction,
)
from nrel.hive.dispatcher.instruction_generator.instruction_generator import InstructionGenerator
from nrel.hive.util.fp import throw_on_failure
from nrel.hive.reporting import reporter_ops
from nrel.hive.runner.runner_payload import RunnerPayload
from nrel.hive.state.simulation_state.update.update import Update
from nrel.hive.dispatcher.instruction_generator.charging_fleet_manager import ChargingFleetManager
from nrel.hive.dispatcher.instruction_generator.dispatcher import Dispatcher
from nrel.hive.util import fs

from nrel.hive.util.fp import throw_on_failure

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/initialization/sample_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from typing import Tuple, List

from nrel.hive.model.request import Request
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork
from nrel.hive.model.sim_time import SimTime
from nrel.hive.runner import Environment
from nrel.hive.state.simulation_state.simulation_state import SimulationState
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork


def default_request_sampler(
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/initialization/sample_vehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from returns.result import Result, Failure, Success

from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.membership import Membership
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.osm.osm_roadnetwork import OSMRoadNetwork
from nrel.hive.model.vehicle.vehicle import Vehicle
from nrel.hive.model.membership import Membership
from nrel.hive.runner import Environment
from nrel.hive.state.driver_state.autonomous_driver_state.autonomous_available import (
AutonomousAvailable,
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/model/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from typing import Optional, Dict, TYPE_CHECKING
from dataclasses import dataclass, replace
from typing import Optional, Dict, TYPE_CHECKING

import h3

Expand Down
1 change: 0 additions & 1 deletion nrel/hive/model/energy/charger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from csv import DictReader
from pathlib import Path
from typing import Dict

from immutables import Map

Expand Down
1 change: 0 additions & 1 deletion nrel/hive/model/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from dataclasses import dataclass
from typing import Tuple


from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.membership import Membership
from nrel.hive.util.typealiases import MembershipId
Expand Down
2 changes: 1 addition & 1 deletion nrel/hive/model/passenger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import functools as ft
from typing import Optional, TYPE_CHECKING
from dataclasses import dataclass, replace
from typing import Optional, TYPE_CHECKING

from nrel.hive.model.membership import Membership
from nrel.hive.model.sim_time import SimTime
Expand Down
4 changes: 2 additions & 2 deletions nrel/hive/model/request/request.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

from typing import NamedTuple, Optional, Dict, TYPE_CHECKING
from dataclasses import dataclass, replace
from typing import Optional, Dict, TYPE_CHECKING

import h3

from nrel.hive.model.entity import Entity
from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.membership import Membership
from nrel.hive.model.passenger import Passenger, create_passenger_id
from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.roadnetwork.roadnetwork import RoadNetwork
from nrel.hive.model.sim_time import SimTime
from nrel.hive.util.exception import TimeParseError
Expand Down
7 changes: 3 additions & 4 deletions nrel/hive/model/roadnetwork/haversine_roadnetwork.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from typing import Tuple, Optional
from typing import Optional

from nrel.hive.model.roadnetwork.geofence import GeoFence
import nrel.hive.model.roadnetwork.haversine_link_id_ops as h_ops
from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.roadnetwork.geofence import GeoFence
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.linktraversal import LinkTraversal
from nrel.hive.model.roadnetwork.roadnetwork import RoadNetwork
Expand All @@ -13,8 +14,6 @@
from nrel.hive.util.typealiases import GeoId, LinkId, H3Resolution
from nrel.hive.util.units import Kilometers

import nrel.hive.model.roadnetwork.haversine_link_id_ops as h_ops


class HaversineRoadNetwork(RoadNetwork):
"""
Expand Down
5 changes: 3 additions & 2 deletions nrel/hive/model/roadnetwork/link_id.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from nrel.hive.util.typealiases import LinkId
from typing import Optional, Tuple, Any
from ast import literal_eval
from typing import Optional, Tuple, Any

from nrel.hive.util.typealiases import LinkId

NodeId = Any

Expand Down
3 changes: 0 additions & 3 deletions nrel/hive/model/roadnetwork/osm/osm_builders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from typing import TYPE_CHECKING


def osm_graph_from_polygon(polygon):
"""
builds a OSM networkx graph using a shapely polygon and the osmnx package
Expand Down
4 changes: 1 addition & 3 deletions nrel/hive/model/roadnetwork/osm/osm_roadnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import json
import logging
from pathlib import Path
from typing import Optional, Union, TYPE_CHECKING
from typing import Optional, Union

import networkx as nx

from nrel.hive.model.roadnetwork.geofence import GeoFence
from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.link_id import extract_node_ids
Expand All @@ -27,7 +26,6 @@
from nrel.hive.util import LinkId
from nrel.hive.util.typealiases import GeoId, H3Resolution
from nrel.hive.util.units import Kmph, Kilometers
from nrel.hive.model.roadnetwork.link_id import extract_node_ids

log = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions nrel/hive/model/roadnetwork/roadnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import h3

from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.geofence import GeoFence
from nrel.hive.model.entity_position import EntityPosition
from nrel.hive.model.roadnetwork.link import Link
from nrel.hive.model.roadnetwork.route import Route
from nrel.hive.model.sim_time import SimTime
from nrel.hive.util.typealiases import GeoId, H3Resolution, LinkId
Expand Down
Loading