Skip to content

Commit

Permalink
tweaks for rpcinterface, required supervisord block
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Aug 15, 2024
1 parent 61a1c5a commit 826df08
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion airflow_supervisor/config/hydra/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

defaults:
# https://hydra.cc/docs/configure_hydra/logging/
- supervisord/default
- override hydra/job_logging: custom
- override hydra/hydra_logging: custom
- _self_

_target_: airflow_supervisor.SupervisorConfiguration
unix_http_server:
inet_http_server:
supervisord:
supervisorctl:
include:
program:
Expand Down
1 change: 1 addition & 0 deletions airflow_supervisor/config/hydra/supervisord/default.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# @package _global_
supervisord:
_target_: airflow_supervisor.SupervisordConfiguration
4 changes: 2 additions & 2 deletions airflow_supervisor/config/rpcinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class RpcInterfaceConfiguration(_BaseCfgModel):
def to_cfg(self, key: str) -> str:
# Overload to require key
return super().to_cfg(key=key).replace("[rpc_interface", "[rpcinterface")
return super().to_cfg(key=key).replace("[rpc_interface", "[rpcinterface").replace("rpcinterface_factory=", "supervisor.rpcinterface_factory=")

supervisor_rpcinterface_factory: str = Field(description="pkg_resources “entry point” dotted name to your RPC interface’s factory function.")
rpcinterface_factory: str = Field(description="pkg_resources “entry point” dotted name to your RPC interface’s factory function.")
kwargs: Optional[Dict[str, Any]] = Field(default=None) # TODO
2 changes: 1 addition & 1 deletion airflow_supervisor/config/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def to_cfg(self) -> str:
# supervisor setup
unix_http_server: Optional[UnixHttpServerConfiguration] = Field(default=None)
inet_http_server: Optional[InetHttpServerConfiguration] = Field(default=None)
supervisord: Optional[SupervisordConfiguration] = Field(default=None)
supervisord: SupervisordConfiguration = Field(default=SupervisordConfiguration())
supervisorctl: Optional[SupervisorctlConfiguration] = Field(default=None)
include: Optional[IncludeConfiguration] = Field(default=None)

Expand Down
6 changes: 3 additions & 3 deletions airflow_supervisor/tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_inst():

def test_cfg():
c = SupervisorConfiguration(program={"test": ProgramConfiguration(command="test")})
assert c.to_cfg().strip() == "[program:test]\ncommand=test"
assert c.to_cfg().strip() == "[supervisord]\n\n[program:test]\ncommand=test"


def test_cfg_all():
Expand All @@ -63,7 +63,7 @@ def test_cfg_all():
group={"testgroup": GroupConfiguration(programs=["test"])},
fcgiprogram={"testfcgi": FcgiProgramConfiguration(command="echo 'test'", socket="test")},
eventlistener={"testeventlistener": EventListenerConfiguration(command="echo 'test'")},
rpcinterface={"testrpcinterface": RpcInterfaceConfiguration(supervisor_rpcinterface_factory="a.test.module")},
rpcinterface={"testrpcinterface": RpcInterfaceConfiguration(rpcinterface_factory="a.test.module")},
)
print(c.to_cfg().strip())
assert (
Expand Down Expand Up @@ -104,5 +104,5 @@ def test_cfg_all():
command=echo 'test'
[rpcinterface:testrpcinterface]
supervisor_rpcinterface_factory=a.test.module"""
supervisor.rpcinterface_factory=a.test.module"""
)
6 changes: 3 additions & 3 deletions airflow_supervisor/tests/config/test_rpcinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
def test_inst():
with raises(ValidationError):
RpcInterfaceConfiguration()
RpcInterfaceConfiguration(supervisor_rpcinterface_factory="a.test.module")
RpcInterfaceConfiguration(rpcinterface_factory="a.test.module")


def test_cfg():
c = RpcInterfaceConfiguration(supervisor_rpcinterface_factory="a.test.module")
assert c.to_cfg("name").strip() == "[rpcinterface:name]\nsupervisor_rpcinterface_factory=a.test.module"
c = RpcInterfaceConfiguration(rpcinterface_factory="a.test.module")
assert c.to_cfg("name").strip() == "[rpcinterface:name]\nsupervisor.rpcinterface_factory=a.test.module"
4 changes: 1 addition & 3 deletions airflow_supervisor/tests/hydra/test_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

def test_hydra_config():
cfg = load_config("config", overrides=["+program=config"])
assert cfg.to_cfg().strip() == "[program:test]\ncommand=echo"


assert cfg.to_cfg().strip() == "[supervisord]\n\n[program:test]\ncommand=echo"

0 comments on commit 826df08

Please sign in to comment.