Commit 9224f2d9 authored by Mitar's avatar Mitar
Browse files

Removing unnecessary constructor arguments and changing Docker one.

parent 47afc0fc
Pipeline #19522548 passed with stage
in 3 minutes and 32 seconds
......@@ -74,8 +74,8 @@ class MonomialPrimitive(supervised_learning.SupervisedLearnerPrimitiveBase[Input
'primitive_family': metadata_base.PrimitiveFamily.REGRESSION,
})
def __init__(self, *, hyperparams: Hyperparams, random_seed: int = 0, docker_containers: typing.Dict[str, str] = None) -> None:
super().__init__(hyperparams=hyperparams, random_seed=random_seed, docker_containers=docker_containers)
def __init__(self, *, hyperparams: Hyperparams) -> None:
super().__init__(hyperparams=hyperparams)
self._a: float = None
self._training_inputs: Inputs = None
......
......@@ -80,8 +80,8 @@ class RandomPrimitive(generator.GeneratorPrimitiveBase[Outputs, None, Hyperparam
'primitive_family': metadata_base.PrimitiveFamily.DATA_GENERATION,
})
def __init__(self, *, hyperparams: Hyperparams, random_seed: int = 0, docker_containers: typing.Dict[str, str] = None) -> None:
super().__init__(hyperparams=hyperparams, random_seed=random_seed, docker_containers=docker_containers)
def __init__(self, *, hyperparams: Hyperparams, random_seed: int = 0) -> None:
super().__init__(hyperparams=hyperparams, random_seed=random_seed)
self._random_state = numpy.random.RandomState(self.random_seed)
......
......@@ -98,9 +98,10 @@ class SumPrimitive(base.SingletonOutputMixin[Inputs, Outputs, None, Hyperparams]
]
})
def __init__(self, *, hyperparams: Hyperparams, random_seed: int = 0, docker_containers: typing.Dict[str, str] = None) -> None:
super().__init__(hyperparams=hyperparams, random_seed=random_seed, docker_containers=docker_containers)
def __init__(self, *, hyperparams: Hyperparams, docker_containers: typing.Dict[str, base.DockerContainer] = None) -> None:
super().__init__(hyperparams=hyperparams, docker_containers=docker_containers)
# We cannot check for expected ports here because during class construction, a mock value is passed which has empty ports dict.
if DOCKER_KEY not in self.docker_containers:
raise ValueError("Docker key '{docker_key}' missing among provided Docker containers.".format(docker_key=DOCKER_KEY))
......@@ -125,11 +126,11 @@ class SumPrimitive(base.SingletonOutputMixin[Inputs, Outputs, None, Hyperparams]
# a few times before aborting.
# Primitive knows the port the container is listening on.
connection = client.HTTPConnection(self.docker_containers[DOCKER_KEY], port=8000)
connection = client.HTTPConnection(self.docker_containers[DOCKER_KEY].address, port=self.docker_containers[DOCKER_KEY].ports['8000/tcp'])
# This simple primitive does not keep any state in the Docker container.
# But if your primitive does have to associate requests with a primitive, consider
# using Python's "id(self)" call to get an identifier of a primitive's instance.
self.logger.debug("HTTP request: host=%(host)s port=%(port)s", {'host': self.docker_containers[DOCKER_KEY], 'port': 8000}, extra={'data': value})
self.logger.debug("HTTP request: container=%(container)s", {'container': self.docker_containers[DOCKER_KEY]}, extra={'data': value})
connection.request('POST', '/', data, {
'Content-Type': 'multipart/form-data',
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment