Skip to content

Commit aac16cd

Browse files
author
coding-kitties
authored
Merge pull request #41 from coding-kitties/hot_fix_executor
Hot fix executor
2 parents ab21ecb + a58af9e commit aac16cd

File tree

11 files changed

+47
-11
lines changed

11 files changed

+47
-11
lines changed

LICENSE

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Business Source License 1.1
33
Parameters
44

55
Licensor: coding kitties.
6-
Licensed Work: Investing Algorithm Framework
6+
Licensed Work: Investing Algorithm Framework.
77
The Licensed Work is (c) 2020 coding kitties.
88
Additional Use Grant: You may make use of the Licensed Work, provided that you do
99
not use the Licensed Work for an Algorithm
@@ -14,7 +14,23 @@ Additional Use Grant: You may make use of the Licensed Work, provided that you d
1414
contractors) to sell and host applications created with the Licensed
1515
Work.
1616

17-
Change Date: 2023-06-20
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
19+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22+
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
POSSIBILITY OF SUCH DAMAGE.
32+
33+
Change Date: 2023-07-16
1834

1935
Change License: Apache License, Version 2.0
2036

investing_algorithm_framework/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
VERSION = (0, 1, 1, 'alpha', 0)
44

55
__all__ = ['get_version']
6-

investing_algorithm_framework/configuration/setup/default_template_creators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def create(self) -> None:
9191

9292
# Format placeholders in file if needed
9393
if filename in [
94+
'Dockerfile-template',
95+
'requirements.txt-template',
9496
'manage.py-template',
9597
'settings.py-template',
9698
'context.py-template',

investing_algorithm_framework/configuration/setup/template_creator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class TemplateCreator(Template, ABC):
1010
rewrite_template_suffixes = (
1111
# Allow shipping invalid .py files without byte-compilation.
1212
('.py-template', '.py'),
13+
('-template', '')
1314
)
1415

1516
def __init__(self, bot_project_directory: str, bot_name: str) -> None:

investing_algorithm_framework/extensions/database_resolver.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __get__(self, instance, owner):
108108
return None
109109

110110

111-
class Model(object):
111+
class Model:
112112
"""
113113
Standard SQL alchemy model
114114
@@ -154,7 +154,7 @@ def _flush(self):
154154
self.session.rollback()
155155
raise
156156

157-
def _repr(self, **fields: Any) -> str:
157+
def repr(self, **fields: Any) -> str:
158158
"""
159159
Helper for __repr__
160160
"""
@@ -163,6 +163,7 @@ def _repr(self, **fields: Any) -> str:
163163
at_least_one_attached_attribute = False
164164

165165
for key, field in fields.items():
166+
166167
try:
167168
field_strings.append(f'{key}={field!r}')
168169
except DetachedInstanceError:
@@ -232,7 +233,7 @@ def session(self) -> Session:
232233
return self.Session()
233234

234235
@property
235-
def model(self) -> Model:
236+
def model(self):
236237
return self._model
237238

238239
def initialize_tables(self):
@@ -352,7 +353,7 @@ def configure(self, database_config: dict = None) -> None:
352353

353354
if self.context is None:
354355
raise DatabaseOperationalException(
355-
"Context is not configured with DatabaseResolver instance"
356+
"There is no database configuration"
356357
)
357358

358359
if not self.context.config.configured:
@@ -364,12 +365,12 @@ def configure(self, database_config: dict = None) -> None:
364365
configuration = self.context.config[DATABASE_CONFIG]
365366
except Exception:
366367
raise DatabaseOperationalException(
367-
"Database configuration has no database configuration"
368+
"Context config has no database configuration"
368369
)
369370

370371
if configuration is None:
371372
raise DatabaseOperationalException(
372-
"Database configuration has no database configuration"
373+
"There is no database configuration"
373374
)
374375
try:
375376
database_type = configuration[DATABASE_TYPE]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.7-alpine
2+
3+
WORKDIR /app
4+
COPY . /app
5+
6+
RUN pip install -r requirements.txt
7+
8+
CMD ["python", "manage.py", "run_algorithm"]

investing_algorithm_framework/templates/projects/algorithm_project_directory/algorithm_project_template/configuration/settings.py-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CONTEXT_CONFIGURATION = '{{ project_name }}.configuration.context'
88
# Change this when not in development, feature or hot-fix branch
99
DEBUG = int(os.environ.get('DEBUG', True))
1010

11-
BASE_DIR = str(Path(__file__).parent.parent)
11+
BASE_DIR = str(Path(__file__).parent.parent.parent)
1212

1313
LOG_FILE_NAME = 'log'
1414

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
investing-algorithm-framework

investing_algorithm_framework/templates/states/ordering_state.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import List
2-
import logging
32

43
from investing_algorithm_framework.core.executors import Executor
54
from investing_algorithm_framework.core.state import State

tests/extensions/test_database_resolver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class TestModel(db.model):
8787
id = Column(Integer, primary_key=True)
8888
name = Column(String)
8989

90+
def __repr__(self):
91+
return self.repr(id=self.id, name=self.name)
92+
9093
def test_creating(self):
9194
self.db.initialize_tables()
9295
assert len(self.TestModel.query.all()) == 0

tests/management/test_create_standard_algo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def test(self):
2424
# Check if manage py is present
2525
assert os.path.isfile(os.path.join(tempdir, 'manage.py'))
2626

27+
# Check if docker file is present
28+
assert os.path.isfile(os.path.join(tempdir, 'Dockerfile'))
29+
30+
# Check if requirements.txt is present
31+
assert os.path.isfile(os.path.join(tempdir, 'requirements.txt'))
32+
2733
# Check if all directories are present
2834
assert os.path.isdir(
2935
os.path.join(tempdir, self.project_name, 'data_providers')

0 commit comments

Comments
 (0)