numerai-cli 1.1.0__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/PKG-INFO +1 -1
  2. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/__init__.py +1 -0
  3. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/destroy_all.py +1 -0
  4. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/misc.py +47 -10
  5. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/node/__init__.py +0 -1
  6. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/node/config.py +11 -81
  7. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/node/destroy.py +2 -1
  8. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/setup.py +17 -13
  9. numerai-cli-1.1.2/numerai/cli/util/terraform.py +78 -0
  10. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/-inputs.tf +0 -6
  11. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/-main.tf +0 -1
  12. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/-inputs.tf +0 -6
  13. numerai-cli-1.1.2/numerai/terraform/aws/aws/-locals.tf +4 -0
  14. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/cluster.tf +17 -18
  15. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/webhook.tf +1 -1
  16. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/PKG-INFO +1 -1
  17. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/SOURCES.txt +1 -0
  18. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/setup.py +1 -1
  19. numerai-cli-1.1.0/numerai/terraform/gcp/gcp/-locals.tf +0 -3
  20. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/MANIFEST.in +0 -0
  21. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/README.md +0 -0
  22. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/__init__.py +0 -0
  23. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/constants.py +0 -0
  24. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/doctor.py +0 -0
  25. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/node/deploy.py +0 -0
  26. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/node/test.py +0 -0
  27. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/uninstall.py +0 -0
  28. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/upgrade.py +0 -0
  29. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/util/__init__.py +0 -0
  30. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/util/debug.py +0 -0
  31. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/util/docker.py +0 -0
  32. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/util/files.py +0 -0
  33. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/cli/util/keys.py +0 -0
  34. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/crypto-python3/Dockerfile +0 -0
  35. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/crypto-python3/predict.py +0 -0
  36. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/crypto-python3/requirements.txt +0 -0
  37. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/signals-python3/Dockerfile +0 -0
  38. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/signals-python3/predict.py +0 -0
  39. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/signals-python3/requirements.txt +0 -0
  40. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/signals-python3/train.py +0 -0
  41. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-python3/Dockerfile +0 -0
  42. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-python3/predict.py +0 -0
  43. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-python3/requirements.txt +0 -0
  44. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-python3/train.py +0 -0
  45. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-rlang/Dockerfile +0 -0
  46. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-rlang/install_packages.R +0 -0
  47. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/examples/tournament-rlang/main.R +0 -0
  48. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/-outputs.tf +0 -0
  49. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/-outputs.tf +0 -0
  50. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/main.zip +0 -0
  51. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/aws/aws/network.tf +0 -0
  52. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure/cluster.tf +0 -0
  53. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure/input.tf +0 -0
  54. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure/locals.tf +0 -0
  55. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure/outputs.tf +0 -0
  56. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure/webhook.tf +0 -0
  57. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure_cron_trigger.zip +0 -0
  58. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/azure_trigger.zip +0 -0
  59. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/input.tf +0 -0
  60. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/main.tf +0 -0
  61. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/outputs.tf +0 -0
  62. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/azure/registry.tf +0 -0
  63. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/-inputs.tf +0 -0
  64. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/-main.tf +0 -0
  65. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/-outputs.tf +0 -0
  66. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/cloud-function.zip +0 -0
  67. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/gcp/-inputs.tf +0 -0
  68. {numerai-cli-1.1.0/numerai/terraform/aws/aws → numerai-cli-1.1.2/numerai/terraform/gcp/gcp}/-locals.tf +0 -0
  69. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/gcp/-outputs.tf +0 -0
  70. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/gcp/cluster.tf +0 -0
  71. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/gcp/webhook.tf +0 -0
  72. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/gcp/workflow-source.yaml +0 -0
  73. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/registry.tf +0 -0
  74. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai/terraform/gcp/services.tf +0 -0
  75. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/dependency_links.txt +0 -0
  76. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/entry_points.txt +0 -0
  77. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/requires.txt +0 -0
  78. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/numerai_cli.egg-info/top_level.txt +0 -0
  79. {numerai-cli-1.1.0 → numerai-cli-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numerai-cli
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: A library for deploying Numer.ai Prediction Nodes.
5
5
  Home-page: https://github.com/numerai/numerai-cli
6
6
  Author: Numer.ai
@@ -35,5 +35,6 @@ def main():
35
35
  numerai.add_command(upgrade.upgrade)
36
36
  numerai.add_command(misc.copy_example)
37
37
  numerai.add_command(misc.list_constants)
38
+ numerai.add_command(misc.add_volume_aws)
38
39
  numerai.add_command(destroy_all.destroy_all)
39
40
  numerai()
@@ -1,4 +1,5 @@
1
1
  """Destroy command for Numerai CLI"""
2
+
2
3
  import click
3
4
  from numerapi import base_api
4
5
 
@@ -1,9 +1,8 @@
1
- import json
2
-
3
- import click
4
-
5
1
  from numerai.cli.constants import *
6
2
  from numerai.cli.util import files
3
+ from numerai.cli.util.terraform import apply_terraform
4
+
5
+ import click
7
6
 
8
7
 
9
8
  @click.command()
@@ -12,13 +11,15 @@ from numerai.cli.util import files
12
11
  "-e",
13
12
  type=click.Choice(EXAMPLES),
14
13
  default=DEFAULT_EXAMPLE,
15
- help=f"Specify the example to copy, defaults to {DEFAULT_EXAMPLE}. " f"Options are {EXAMPLES}.",
14
+ help=f"Specify the example to copy, defaults to {DEFAULT_EXAMPLE}. "
15
+ f"Options are {EXAMPLES}.",
16
16
  )
17
17
  @click.option(
18
18
  "--dest",
19
19
  "-d",
20
20
  type=str,
21
- help=f"Destination folder to which example code is written. " f"Defaults to the name of the example.",
21
+ help=f"Destination folder to which example code is written. "
22
+ f"Defaults to the name of the example.",
22
23
  )
23
24
  @click.option("--verbose", "-v", is_flag=True)
24
25
  def copy_example(example, dest, verbose):
@@ -49,14 +50,50 @@ def list_constants():
49
50
  click.secho(
50
51
  f" {size} -> cpus: {preset[0] / 1024}, "
51
52
  f"mem: {preset[1] / 1024} GB {suffix}",
52
- fg="green"
53
- if size == DEFAULT_SIZE or size == DEFAULT_SIZE_GCP
54
- else "yellow",
53
+ fg=(
54
+ "green"
55
+ if size == DEFAULT_SIZE or size == DEFAULT_SIZE_GCP
56
+ else "yellow"
57
+ ),
55
58
  )
56
- click.secho("Due to GCP Cloud Run size constraints, 'mem' sizes are not allowed when using GCP.")
59
+ click.secho(
60
+ "Due to GCP Cloud Run size constraints, 'mem' sizes are not allowed when using GCP."
61
+ )
57
62
  click.secho(
58
63
  "For AWS, use one of these sizes, or specify your own CPU and Memory in cores and GB using --cpu and --memory options.\n"
59
64
  "See https://learn.microsoft.com/en-us/azure/container-apps/containers#configuration for Azure,\n"
60
65
  "or https://cloud.google.com/run/docs/configuring/services/memory-limits for GCP \n"
61
66
  "to learn more info about allowed size presets for those providers."
62
67
  )
68
+
69
+
70
+ @click.command()
71
+ @click.option(
72
+ "--size",
73
+ "-s",
74
+ type=int,
75
+ required=True,
76
+ help="Specify the volume size in GB you'd like your AWS nodes to share.",
77
+ )
78
+ @click.option("--verbose", "-v", is_flag=True)
79
+ def add_volume_aws(size, verbose):
80
+ """
81
+ Set the volume size for AWS nodes. This volume is shared by all nodes.
82
+ """
83
+ click.secho("Setting volume size for AWS nodes...", fg="yellow")
84
+ # get nodes config object
85
+ nodes_config = files.load_or_init_nodes()
86
+ print(nodes_config)
87
+ # set volume size for all nodes to same size
88
+ for node in nodes_config:
89
+ nodes_config[node]["volume"] = size
90
+ files.store_config(NODES_PATH, nodes_config)
91
+ files.copy_file(
92
+ NODES_PATH,
93
+ f"{CONFIG_PATH}/{PROVIDER_AWS}/",
94
+ force=True,
95
+ verbose=verbose,
96
+ )
97
+ click.secho(f"Applying terraform to add {size} GB volume...", fg="yellow")
98
+ apply_terraform(nodes_config, [PROVIDER_AWS], PROVIDER_AWS, verbose=verbose)
99
+ click.secho("Volume size updated successfully!", fg="green")
@@ -25,7 +25,6 @@ def tournaments_dict():
25
25
  def get_models(tournament):
26
26
  napi = base_api.Api(*get_numerai_keys())
27
27
  models = napi.get_models(tournament)
28
- tournaments = napi.raw_query('query { tournaments { name tournament } }')
29
28
  name_prefix = tournaments_dict()[tournament]
30
29
  model_dict = {}
31
30
  for model_name, model_id in models.items():
@@ -1,8 +1,7 @@
1
1
  """Config command for Numerai CLI"""
2
2
 
3
- import json
4
3
  import os
5
- import click
4
+
6
5
  from numerapi import base_api
7
6
  from numerai.cli.constants import (
8
7
  DEFAULT_PROVIDER,
@@ -19,7 +18,6 @@ from numerai.cli.constants import (
19
18
  CONFIG_PATH,
20
19
  PROVIDER_GCP,
21
20
  )
22
- from numerai.cli.util.docker import terraform, check_for_dockerfile
23
21
  from numerai.cli.util import docker
24
22
  from numerai.cli.util.files import (
25
23
  load_or_init_nodes,
@@ -27,7 +25,14 @@ from numerai.cli.util.files import (
27
25
  copy_example,
28
26
  copy_file,
29
27
  )
30
- from numerai.cli.util.keys import get_provider_keys, get_numerai_keys, load_or_init_keys
28
+ from numerai.cli.util.keys import get_provider_keys, get_numerai_keys
29
+ from numerai.cli.util.terraform import (
30
+ apply_terraform,
31
+ create_azure_registry,
32
+ create_gcp_registry,
33
+ )
34
+
35
+ import click
31
36
 
32
37
 
33
38
  @click.command()
@@ -95,12 +100,6 @@ from numerai.cli.util.keys import get_provider_keys, get_numerai_keys, load_or_i
95
100
  help="Forces your webhook to register with Numerai. "
96
101
  "Use in conjunction with options that prevent webhook auto-registering.",
97
102
  )
98
- @click.option(
99
- "--volume",
100
- "-v",
101
- type=int,
102
- help="Specify additional block storage in GB. Currently only supported in AWS.",
103
- )
104
103
  @click.pass_context
105
104
  def config(
106
105
  ctx,
@@ -114,7 +113,6 @@ def config(
114
113
  cron,
115
114
  timeout_minutes,
116
115
  register_webhook,
117
- volume,
118
116
  ):
119
117
  """
120
118
  Uses Terraform to create a full Numerai Compute cluster in your desired provider.
@@ -234,7 +232,7 @@ def config(
234
232
  click.secho(f'Current node config: "{node_conf}"...')
235
233
 
236
234
  # double check there is a dockerfile in the path we are about to configure
237
- check_for_dockerfile(nodes_config[node]["path"])
235
+ docker.check_for_dockerfile(nodes_config[node]["path"])
238
236
  store_config(NODES_PATH, nodes_config)
239
237
 
240
238
  # Added after tf directory restructure: copy nodes.json to providers' tf directory
@@ -284,43 +282,10 @@ def config(
284
282
  docker.tag("hello-world:linux", node_conf["docker_repo"], verbose)
285
283
  docker.push(node_conf["docker_repo"], verbose)
286
284
  nodes_config[node] = node_conf
287
- elif provider == "aws":
288
- if volume is not None:
289
- node_conf["volume"] = volume
290
285
 
291
286
  store_config(NODES_PATH, nodes_config)
292
287
 
293
- # Apply terraform for any affected provider
294
- for affected_provider in affected_providers:
295
- if affected_provider in PROVIDERS:
296
- click.secho(f"Updating resources in {affected_provider}")
297
- terraform(
298
- "apply -auto-approve",
299
- verbose,
300
- affected_provider,
301
- env_vars=load_or_init_keys(affected_provider),
302
- inputs={"node_config_file": "nodes.json"},
303
- )
304
- else:
305
- click.secho(f"provider {affected_provider} not supported", fg="red")
306
- exit(1)
307
- click.secho("cloud resources created successfully", fg="green")
308
-
309
- # terraform output for node config, same for aws and azure
310
- click.echo(f"saving node configuration to {NODES_PATH}...")
311
-
312
- res = terraform(f"output -json {provider}_nodes", verbose, provider).decode("utf-8")
313
- try:
314
- nodes = json.loads(res)
315
- except json.JSONDecodeError:
316
- click.secho("failed to save node configuration, please retry.", fg="red")
317
- return
318
- for node_name, data in nodes.items():
319
- nodes_config[node_name].update(data)
320
-
321
- store_config(NODES_PATH, nodes_config)
322
- if verbose:
323
- click.secho(f"new config:\n{json.dumps(load_or_init_nodes(), indent=2)}")
288
+ apply_terraform(nodes_config, affected_providers, provider, verbose)
324
289
 
325
290
  webhook_url = nodes_config[node]["webhook_url"]
326
291
  napi = base_api.Api(*get_numerai_keys())
@@ -336,38 +301,3 @@ def config(
336
301
  "Prediction Node configured successfully. " "Next: deploy and test your node",
337
302
  fg="green",
338
303
  )
339
-
340
-
341
- def create_azure_registry(provider, provider_keys, verbose):
342
- """Creates a registry for azure"""
343
- terraform("init -upgrade", verbose, provider)
344
- terraform(
345
- 'apply -target="azurerm_container_registry.registry[0]" -target="azurerm_resource_group.acr_rg[0]" -auto-approve ',
346
- verbose,
347
- "azure",
348
- env_vars=provider_keys,
349
- inputs={"node_config_file": "nodes.json"},
350
- )
351
- res = terraform("output -json acr_repo_details", True, provider).decode("utf-8")
352
- return json.loads(res)
353
-
354
-
355
- def create_gcp_registry(provider, verbose):
356
- """Creates a registry for GCP"""
357
- terraform("init -upgrade", verbose, provider)
358
- terraform(
359
- 'apply -target="google_project_service.cloud_resource_manager" -auto-approve ',
360
- verbose,
361
- "gcp",
362
- inputs={"node_config_file": "nodes.json"},
363
- )
364
- terraform(
365
- 'apply -target="google_artifact_registry_repository.registry[0]" -auto-approve ',
366
- verbose,
367
- "gcp",
368
- inputs={"node_config_file": "nodes.json"},
369
- )
370
- res = terraform("output -json artifact_registry_details", True, provider).decode(
371
- "utf-8"
372
- )
373
- return json.loads(res)
@@ -1,4 +1,5 @@
1
1
  """Destroy command for Numerai CLI"""
2
+
2
3
  import click
3
4
  from numerapi import base_api
4
5
 
@@ -41,7 +42,7 @@ def destroy(ctx, preserve_node_config, verbose):
41
42
  fg="red",
42
43
  )
43
44
  return
44
-
45
+
45
46
  if not preserve_node_config:
46
47
  click.secho("backing up nodes.json...")
47
48
  copy_file(NODES_PATH, f"{NODES_PATH}.backup", force=True, verbose=True)
@@ -1,4 +1,5 @@
1
1
  """Setup command for Numerai CLI"""
2
+
2
3
  import click
3
4
  import logging
4
5
 
@@ -16,8 +17,9 @@ from numerai.cli.util.keys import config_numerai_keys, config_provider_keys
16
17
  prompt=True,
17
18
  help=f"Initialize with this providers API keys.",
18
19
  )
20
+ @click.option("--skip-key-setup", "-s", is_flag=True)
19
21
  @click.option("--verbose", "-v", is_flag=True)
20
- def setup(provider, verbose):
22
+ def setup(provider, skip_key_setup, verbose):
21
23
  """
22
24
  Initializes cli and provider API keys.
23
25
  """
@@ -38,20 +40,22 @@ def setup(provider, verbose):
38
40
  return
39
41
 
40
42
  # setup numerai keys
41
- click.secho(
42
- "Initializing numerai keys " "(press enter to keep value in brackets)...",
43
- fg="yellow",
44
- )
45
- maybe_create(KEYS_PATH, protected=True)
46
- config_numerai_keys()
43
+ if not skip_key_setup:
44
+ click.secho(
45
+ "Initializing numerai keys " "(press enter to keep value in brackets)...",
46
+ fg="yellow",
47
+ )
48
+ maybe_create(KEYS_PATH, protected=True)
49
+ config_numerai_keys()
47
50
 
48
51
  # setup provider keys
49
- click.secho(
50
- f"\nInitializing {provider} keys "
51
- f"(press enter to keep value in brackets)...",
52
- fg="yellow",
53
- )
54
- config_provider_keys(provider)
52
+ if not skip_key_setup:
53
+ click.secho(
54
+ f"\nInitializing {provider} keys "
55
+ f"(press enter to keep value in brackets)...",
56
+ fg="yellow",
57
+ )
58
+ config_provider_keys(provider)
55
59
 
56
60
  # copy tf files
57
61
  click.secho("copying terraform files...")
@@ -0,0 +1,78 @@
1
+ import json
2
+
3
+ from numerai.cli.constants import PROVIDERS, NODES_PATH
4
+ from numerai.cli.util.docker import terraform
5
+ from numerai.cli.util import docker
6
+ from numerai.cli.util.files import load_or_init_nodes, store_config
7
+ from numerai.cli.util.keys import load_or_init_keys
8
+
9
+ import click
10
+
11
+
12
+ def apply_terraform(nodes_config, affected_providers, provider, verbose):
13
+ # Apply terraform for any affected provider
14
+ for affected_provider in affected_providers:
15
+ if affected_provider in PROVIDERS:
16
+ click.secho(f"Updating resources in {affected_provider}")
17
+ terraform(
18
+ "apply -auto-approve",
19
+ verbose,
20
+ affected_provider,
21
+ env_vars=load_or_init_keys(affected_provider),
22
+ inputs={"node_config_file": "nodes.json"},
23
+ )
24
+ else:
25
+ click.secho(f"provider {affected_provider} not supported", fg="red")
26
+ exit(1)
27
+ click.secho("cloud resources created successfully", fg="green")
28
+
29
+ # terraform output for node config, same for aws and azure
30
+ click.echo(f"saving node configuration to {NODES_PATH}...")
31
+
32
+ res = terraform(f"output -json {provider}_nodes", verbose, provider).decode("utf-8")
33
+ try:
34
+ nodes = json.loads(res)
35
+ except json.JSONDecodeError:
36
+ click.secho("failed to save node configuration, please retry.", fg="red")
37
+ return
38
+ for node_name, data in nodes.items():
39
+ nodes_config[node_name].update(data)
40
+
41
+ store_config(NODES_PATH, nodes_config)
42
+ if verbose:
43
+ click.secho(f"new config:\n{json.dumps(load_or_init_nodes(), indent=2)}")
44
+
45
+
46
+ def create_azure_registry(provider, provider_keys, verbose):
47
+ """Creates a registry for azure"""
48
+ terraform("init -upgrade", verbose, provider)
49
+ terraform(
50
+ 'apply -target="azurerm_container_registry.registry[0]" -target="azurerm_resource_group.acr_rg[0]" -auto-approve ',
51
+ verbose,
52
+ "azure",
53
+ env_vars=provider_keys,
54
+ inputs={"node_config_file": "nodes.json"},
55
+ )
56
+ res = terraform("output -json acr_repo_details", True, provider).decode("utf-8")
57
+ return json.loads(res)
58
+
59
+
60
+ def create_gcp_registry(provider, verbose):
61
+ """Creates a registry for GCP"""
62
+ terraform("init -upgrade", verbose, provider)
63
+ terraform(
64
+ 'apply -target="google_project_service.cloud_resource_manager" -auto-approve ',
65
+ verbose,
66
+ "gcp",
67
+ inputs={"node_config_file": "nodes.json"},
68
+ )
69
+ terraform(
70
+ 'apply -target="google_artifact_registry_repository.registry[0]" -auto-approve ',
71
+ verbose,
72
+ "gcp",
73
+ inputs={"node_config_file": "nodes.json"},
74
+ )
75
+ res = terraform("output -json artifact_registry_details", True, provider).decode(
76
+ "utf-8"
77
+ )
78
+ return json.loads(res)
@@ -27,9 +27,3 @@ variable "gateway_stage_path" {
27
27
  type = string
28
28
  default = "v1"
29
29
  }
30
-
31
- variable "volume_size" {
32
- description = "Size of the EC2 volumes in GB"
33
- type = number
34
- default = 0
35
- }
@@ -23,5 +23,4 @@ module "aws" {
23
23
  nodes = local.aws_nodes
24
24
  node_container_port = var.node_container_port
25
25
  gateway_stage_path = var.gateway_stage_path
26
- volume_size = var.volume_size
27
26
  }
@@ -26,9 +26,3 @@ variable "gateway_stage_path" {
26
26
  type = string
27
27
  default = "v1"
28
28
  }
29
-
30
- variable "volume_size" {
31
- description = "Size of the EC2 volumes in GB"
32
- type = number
33
- nullable = true
34
- }
@@ -0,0 +1,4 @@
1
+ locals {
2
+ node_prefix = "numerai-submission"
3
+ max_node_volume_size = max([for node, config in var.nodes : config.volume]...)
4
+ }
@@ -94,14 +94,15 @@ data "aws_ami" "ecs_al2" {
94
94
 
95
95
  resource "aws_launch_template" "node" {
96
96
  image_id = data.aws_ami.ecs_al2.id
97
+ update_default_version = true
97
98
  dynamic "block_device_mappings" {
98
- for_each = var.volume_size > 0 ? {size: var.volume_size} : {}
99
+ for_each = local.max_node_volume_size > 0 ? {size: local.max_node_volume_size} : {}
99
100
  content {
100
101
  device_name = "/dev/xvda"
101
102
 
102
103
  ebs {
103
104
  encrypted = true
104
- volume_size = each.size
105
+ volume_size = local.max_node_volume_size
105
106
  volume_type = "gp3"
106
107
  }
107
108
  }
@@ -116,7 +117,7 @@ resource "aws_batch_compute_environment" "node" {
116
117
 
117
118
  launch_template {
118
119
  launch_template_id = aws_launch_template.node.id
119
- version = "$Latest"
120
+ version = aws_launch_template.node.latest_version
120
121
  }
121
122
 
122
123
  max_vcpus = 64
@@ -142,22 +143,8 @@ resource "aws_batch_compute_environment" "node" {
142
143
  }
143
144
 
144
145
 
145
- #############
146
- # Job Setup #
147
- #############
148
-
149
- resource "aws_cloudwatch_log_group" "ec2" {
150
- for_each = { for name, config in var.nodes : name => config }
151
-
152
- name = "/ec2/service/${each.key}"
153
- retention_in_days = "14"
154
- }
155
-
156
-
157
146
  resource "aws_batch_job_queue" "node" {
158
- for_each = { for name, config in var.nodes : name => config }
159
-
160
- name = each.key
147
+ name = "${local.node_prefix}-queue"
161
148
 
162
149
  state = "ENABLED"
163
150
  priority = 1
@@ -168,6 +155,18 @@ resource "aws_batch_job_queue" "node" {
168
155
  }
169
156
  }
170
157
 
158
+
159
+ #############
160
+ # Job Setup #
161
+ #############
162
+
163
+ resource "aws_cloudwatch_log_group" "ec2" {
164
+ for_each = { for name, config in var.nodes : name => config }
165
+
166
+ name = "/ec2/service/${each.key}"
167
+ retention_in_days = "14"
168
+ }
169
+
171
170
  resource "aws_batch_job_definition" "node" {
172
171
  for_each = { for name, config in var.nodes : name => config }
173
172
 
@@ -15,7 +15,7 @@ resource "aws_lambda_function" "submission" {
15
15
  environment {
16
16
  variables = {
17
17
  JOB_DEFINITION = aws_batch_job_definition.node[each.key].name
18
- JOB_QUEUE = aws_batch_job_queue.node[each.key].name
18
+ JOB_QUEUE = aws_batch_job_queue.node.name
19
19
  }
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numerai-cli
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: A library for deploying Numer.ai Prediction Nodes.
5
5
  Home-page: https://github.com/numerai/numerai-cli
6
6
  Author: Numer.ai
@@ -20,6 +20,7 @@ numerai/cli/util/debug.py
20
20
  numerai/cli/util/docker.py
21
21
  numerai/cli/util/files.py
22
22
  numerai/cli/util/keys.py
23
+ numerai/cli/util/terraform.py
23
24
  numerai/examples/crypto-python3/Dockerfile
24
25
  numerai/examples/crypto-python3/predict.py
25
26
  numerai/examples/crypto-python3/requirements.txt
@@ -9,7 +9,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
9
9
 
10
10
  setup(
11
11
  name="numerai-cli",
12
- version="1.1.0",
12
+ version="1.1.2",
13
13
  description="A library for deploying Numer.ai Prediction Nodes.",
14
14
  url="https://github.com/numerai/numerai-cli",
15
15
  author="Numer.ai",
@@ -1,3 +0,0 @@
1
- locals {
2
- node_prefix = "numerai-submission"
3
- }
File without changes
File without changes
File without changes