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

Add local file config in isort & Add missing copyright info #547

Merged
merged 3 commits into from
Jun 14, 2022
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
3 changes: 2 additions & 1 deletion .github/linters/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ line-length = 120
[tool.isort]
profile = "black"
line_length = 120
known_first_party = "maro"
known_first_party = ["maro"]
known_local_folder = ["examples", "scripts", "tests"]
2 changes: 2 additions & 0 deletions examples/cim/rl/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions examples/cim/rl/algorithms/ppo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import torch

from maro.rl.policy import DiscretePolicyGradient
Expand Down
8 changes: 5 additions & 3 deletions examples/cim/rl/rl_component_bundle.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from functools import partial
from typing import Any, Callable, Dict, Optional

from examples.cim.rl.config import action_num, algorithm, env_conf, num_agents, reward_shaping_conf, state_dim
from examples.cim.rl.env_sampler import CIMEnvSampler

from maro.rl.policy import AbsPolicy
from maro.rl.rl_component.rl_component_bundle import RLComponentBundle
from maro.rl.rollout import AbsEnvSampler
Expand All @@ -13,6 +13,8 @@
from .algorithms.dqn import get_dqn, get_dqn_policy
from .algorithms.maddpg import get_maddpg, get_maddpg_policy
from .algorithms.ppo import get_ppo, get_ppo_policy
from examples.cim.rl.config import action_num, algorithm, env_conf, num_agents, reward_shaping_conf, state_dim
from examples.cim.rl.env_sampler import CIMEnvSampler


class CIMBundle(RLComponentBundle):
Expand Down
2 changes: 2 additions & 0 deletions examples/citi_bike/greedy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions examples/citi_bike/greedy/launcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import heapq
import io
import os
Expand Down
2 changes: 2 additions & 0 deletions examples/citi_bike/online_lp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions examples/citi_bike/online_lp/citi_bike_ilp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import math
from typing import List, Tuple

Expand Down
3 changes: 3 additions & 0 deletions examples/citi_bike/online_lp/launcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import argparse
import io
import math
Expand Down
3 changes: 3 additions & 0 deletions examples/rl/run_rl_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import argparse

from maro.cli.local.commands import run
Expand Down
3 changes: 3 additions & 0 deletions examples/simulator/data_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from maro.backends.frame import FrameBase, FrameNode, NodeAttribute, NodeBase, node

TOTAL_PRODUCT_CATEGORIES = 10
Expand Down
2 changes: 2 additions & 0 deletions examples/vm_scheduling/offline_lp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions examples/vm_scheduling/offline_lp/launcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import io
import os
import pprint
Expand Down
2 changes: 2 additions & 0 deletions examples/vm_scheduling/rl/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
13 changes: 8 additions & 5 deletions examples/vm_scheduling/rl/rl_component_bundle.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from functools import partial
from typing import Any, Callable, Dict, Optional

from examples.vm_scheduling.rl.algorithms.ac import get_ac, get_ac_policy
from examples.vm_scheduling.rl.algorithms.dqn import get_dqn, get_dqn_policy
from examples.vm_scheduling.rl.config import algorithm, env_conf, num_features, num_pms, state_dim, test_env_conf
from examples.vm_scheduling.rl.env_sampler import VMEnvSampler

from maro.rl.policy import AbsPolicy
from maro.rl.rl_component.rl_component_bundle import RLComponentBundle
from maro.rl.rollout import AbsEnvSampler
from maro.rl.training import AbsTrainer

from examples.vm_scheduling.rl.algorithms.ac import get_ac, get_ac_policy
from examples.vm_scheduling.rl.algorithms.dqn import get_dqn, get_dqn_policy
from examples.vm_scheduling.rl.config import algorithm, env_conf, num_features, num_pms, state_dim, test_env_conf
from examples.vm_scheduling.rl.env_sampler import VMEnvSampler


class VMBundle(RLComponentBundle):
def get_env_config(self) -> dict:
Expand Down
2 changes: 2 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/agent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from maro.simulator import Env
from maro.simulator.scenarios.vm_scheduling import AllocateAction, DecisionPayload, PostponeAction
from maro.simulator.scenarios.vm_scheduling.common import Action
Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/best_fit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import numpy as np
from rule_based_algorithm import RuleBasedAlgorithm

Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/bin_packing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import random

import numpy as np
Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/first_fit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from rule_based_algorithm import RuleBasedAlgorithm

from maro.simulator import Env
Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/launcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import importlib
import io
import os
Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/random_pick.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import random

from rule_based_algorithm import RuleBasedAlgorithm
Expand Down
3 changes: 3 additions & 0 deletions examples/vm_scheduling/rule_based_algorithm/round_robin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from rule_based_algorithm import RuleBasedAlgorithm

from maro.simulator import Env
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import abc

from maro.simulator import Env
Expand Down
4 changes: 2 additions & 2 deletions maro/cli/data_pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
4 changes: 2 additions & 2 deletions maro/cli/data_pipeline/citi_bike.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import csv
import os
Expand Down
4 changes: 2 additions & 2 deletions maro/cli/data_pipeline/data_process.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from maro.cli.data_pipeline.citi_bike import CitiBikeProcess
from maro.cli.data_pipeline.vm_scheduling import VmSchedulingProcess
Expand Down
4 changes: 2 additions & 2 deletions maro/cli/data_pipeline/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import json
import os
Expand Down
3 changes: 3 additions & 0 deletions maro/cli/data_pipeline/vm_scheduling.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import gzip
import os
import shutil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from flask import Blueprint

from ..jwt_wrapper import check_jwt_validity
Expand Down
3 changes: 3 additions & 0 deletions maro/cli/utils/web_terminal/terminal-srv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import argparse
import fcntl
import json
Expand Down
1 change: 1 addition & 0 deletions maro/data_lib/cim/port_buffer_tick_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from math import ceil
from typing import Callable

Expand Down
1 change: 1 addition & 0 deletions maro/event_buffer/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import abc
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions maro/event_buffer/event_linked_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from typing import List, Optional, Union

from .event import AbsEvent, ActualEvent, CascadeEvent, DummyEvent
Expand Down
1 change: 1 addition & 0 deletions maro/event_buffer/event_pool.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from itertools import count
from typing import Iterable, Iterator, List, Union

Expand Down
3 changes: 3 additions & 0 deletions maro/forecasting/moving_average.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from abc import ABC, abstractmethod
from collections import deque
from typing import Iterable
Expand Down
2 changes: 2 additions & 0 deletions maro/rl/model/algorithm_nets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
3 changes: 3 additions & 0 deletions maro/rl/model/algorithm_nets/ac_based.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from abc import ABCMeta
from typing import Tuple

Expand Down
3 changes: 3 additions & 0 deletions maro/rl/model/algorithm_nets/ddpg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from abc import ABCMeta
from typing import Tuple

Expand Down
3 changes: 3 additions & 0 deletions maro/rl/model/algorithm_nets/sac.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from abc import ABCMeta
from typing import Tuple

Expand Down
2 changes: 2 additions & 0 deletions maro/rl/rl_component/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
1 change: 1 addition & 0 deletions maro/rl/rollout/env_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def _calc_reward(self, cache_element: CacheElement) -> None:
cache_element.event,
cache_element.tick,
)
cache_element.reward_dict = {agent: cache_element.reward_dict[agent] for agent in cache_element.agent_names}

def _append_cache_element(self, cache_element: Optional[CacheElement]) -> None:
"""`cache_element` == None means we are processing the last element in trans_cache"""
Expand Down
1 change: 1 addition & 0 deletions maro/rl/training/algorithms/dqn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from dataclasses import dataclass
from typing import Callable, Dict

Expand Down
3 changes: 3 additions & 0 deletions maro/rl/training/algorithms/sac.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from dataclasses import dataclass
from typing import Callable, Dict, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions maro/rl/training/trainer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import collections
import os
from abc import ABCMeta, abstractmethod
Expand Down
3 changes: 3 additions & 0 deletions maro/rl/utils/training.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import os


Expand Down
3 changes: 3 additions & 0 deletions maro/rl/utils/transition_batch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from __future__ import annotations

from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions maro/rl/workflows/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import argparse
import importlib
import os
Expand Down
1 change: 1 addition & 0 deletions maro/rl/workflows/rollout_worker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import importlib
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions maro/rl/workflows/train_worker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import importlib
import os
import sys
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import math
import os
import random
Expand Down
2 changes: 1 addition & 1 deletion maro/simulator/utils/event_bind_binreader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.s
# Licensed under the MIT license.

from datetime import datetime

Expand Down
3 changes: 3 additions & 0 deletions maro/utils/checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import io
import os
from abc import ABC, abstractmethod
Expand Down
3 changes: 3 additions & 0 deletions maro/utils/exception/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from .base_exception import MAROException
from .error_code import ERROR_CODE

Expand Down
3 changes: 3 additions & 0 deletions scripts/launch_realtime_vis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

"""
This script is used to launch data and vis services, and the start the experiment script.

Expand Down
3 changes: 3 additions & 0 deletions tests/checkpoint/test_checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import json
import logging
import os
Expand Down
2 changes: 2 additions & 0 deletions tests/cim/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
Loading