Skip to content

Commit

Permalink
more instnaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaFox committed Apr 30, 2023
1 parent 9467984 commit 356a06a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
runtime: python39
service: iris3
automatic_scaling:
max_instances: 3
max_concurrent_requests: 3
max_instances: 6
max_concurrent_requests: 5
instance_class: F2
inbound_services:
- warmup
Expand Down
2 changes: 1 addition & 1 deletion cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
cron:
- description: "Invoke /schedule which sends out messages triggering do_label per project/plugin."
url: /schedule
schedule: every day 13:27
schedule: every day 10:00
target: iris3
11 changes: 4 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

app.wsgi_app = google.appengine.api.wrap_wsgi_app(app.wsgi_app)

from util.utils import init_logging
from util.utils import init_logging, sort_dict

# Must init logging before any library code writes logs (which would then just override our config)
init_logging()
Expand Down Expand Up @@ -66,10 +66,7 @@

gcp_utils.set_env()

logging.info(
"env GAE_USE_SOCKETS_HTTPLIB is %s", os.environ.get("GAE_USE_SOCKETS_HTTPLIB")
)
logging.info("env PYTHONMALLOC is %s", os.environ.get("PYTHONMALLOC"))
logging.info("env is %s", sort_dict( (os.environ.copy())))

PluginHolder.init()

Expand Down Expand Up @@ -254,10 +251,10 @@ def __label_one_0(data, plugin_cls: Type[Plugin]):
plugin = PluginHolder.get_plugin_instance(plugin_cls)
gcp_object = plugin.get_gcp_object(data)
if gcp_object is not None:
project_id = data["resource"]["labels"]["project_id"]
project_id = data["labels"]["project_id"]
if is_project_enabled(project_id):
logging.info(
"Will label_one() in %s, existing object %s...",
"Will label_one() in %s, existing object %s ",
project_id,
str(gcp_object)[:100],
)
Expand Down
2 changes: 1 addition & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def load_plugin_class(name) -> Type:
] = None # Initialize with NO instance to avoid importing
loaded.append(plugin_class.__name__)

logging.info("Loaded plugins: %s", loaded)

assert cls.plugins, "No plugins defined"

@classmethod
Expand Down
6 changes: 2 additions & 4 deletions util/gcp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from util import localdev_config, utils
from util.detect_gae import detect_gae
from util.utils import timed_lru_cache, log_time, dict_to_camelcase
from util.utils import timed_lru_cache, log_time, dict_to_camelcase, sort_dict

__invocation_count = Counter()

Expand All @@ -26,9 +26,7 @@ def increment_invocation_count(path: str):

def count_invocations_by_path():
d = dict(__invocation_count)
keys = sorted(list(d.keys()))
sorted_dict = {i: d[i] for i in keys}
return sorted_dict
return sort_dict(d)


def current_project_id():
Expand Down
6 changes: 6 additions & 0 deletions util/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,9 @@ def run_command(command_s):

def mkdirs(dir_):
pathlib.Path(dir_).mkdir(parents=True, exist_ok=True)


def sort_dict(d):
keys = sorted(list(d.keys()))
sorted_dict = {i: d[i] for i in keys}
return sorted_dict

0 comments on commit 356a06a

Please sign in to comment.