maleo-foundation 0.1.23__py3-none-any.whl → 0.1.24__py3-none-any.whl

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.
maleo_foundation/enums.py CHANGED
@@ -3,6 +3,11 @@ from enum import IntEnum, StrEnum, Enum
3
3
  from fastapi import responses
4
4
 
5
5
  class BaseEnums:
6
+ class EnvironmentType(StrEnum):
7
+ LOCAL = "local"
8
+ STAGING = "staging"
9
+ PRODUCTION = "production"
10
+
6
11
  class StatusType(StrEnum):
7
12
  DELETED = "deleted"
8
13
  INACTIVE = "inactive"
@@ -33,6 +33,7 @@ class LogConfig(BaseModel):
33
33
  arbitrary_types_allowed=True
34
34
 
35
35
  class Settings(BaseSettings):
36
+ ENVIRONMENT:BaseEnums.EnvironmentType = Field(..., description="Environment")
36
37
  GOOGLE_CREDENTIALS_PATH:str = Field("/creds/maleo-google-service-account.json", description="Internal credential's file path")
37
38
  INTERNAL_CREDENTIALS_PATH:str = Field("/creds/maleo-internal-service-account.json", description="Internal credential's file path")
38
39
  PRIVATE_KEY_PATH:str = Field("/keys/maleo-private-key.pem", description="Maleo's private key path")
@@ -383,7 +384,23 @@ class ServiceManager:
383
384
  return self._app
384
385
 
385
386
  def run_app(self) -> None:
386
- uvicorn.run(self._app, host=self._configs.service.host, port=self._configs.service.port, reload=True)
387
+ if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL:
388
+ import importlib.util
389
+ import sys
390
+ # Get the module path and add it to sys.path if needed
391
+ spec = importlib.util.find_spec("app")
392
+ if spec and spec.origin:
393
+ module_path = os.path.dirname(os.path.dirname(spec.origin))
394
+ if module_path not in sys.path:
395
+ sys.path.insert(0, module_path)
396
+
397
+ # Create the import string for uvicorn
398
+ app_import_string = "app.main:app"
399
+
400
+ # Run with reload enabled
401
+ uvicorn.run(app_import_string, host=self._configs.service.host, port=self._configs.service.port, reload=True)
402
+ else:
403
+ uvicorn.run(self._app, host=self._configs.service.host, port=self._configs.service.port)
387
404
 
388
405
  async def dispose(self) -> None:
389
406
  self._loggers.application.info("Disposing service manager")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.23
3
+ Version: 0.1.24
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  maleo_foundation/authentication.py,sha256=iwc9cGGi5srW3goPRyuZjoPvdyA3XPgYzIEbVl-IW78,842
3
3
  maleo_foundation/constants.py,sha256=aBmEfWlBqZxi0k-n6h2NM1YRLOjMnheEiLyQcjP-zCQ,1164
4
- maleo_foundation/enums.py,sha256=93fqLJvg0oZAXuJSFCf0-gsW8JmB6AkJvZzXLd47dIo,2820
4
+ maleo_foundation/enums.py,sha256=uvwl3dl2r6BoJMEbtSETiLoyJubHup9Lc7VOg7w7zQo,2943
5
5
  maleo_foundation/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBmdc-L4,301
6
6
  maleo_foundation/types.py,sha256=aKXnIgEhYGSfFqNMGLc4qIKGkINBRpkOo9R9cb2CbwI,2414
7
7
  maleo_foundation/clients/__init__.py,sha256=W8vydJYeDEi6gdmOZSBFSSDsfZJtb8C05CHErZgsZ30,188
@@ -32,7 +32,7 @@ maleo_foundation/expanded_types/token.py,sha256=4fRTJw6W5MYq71NksNrWNi7qYHQ4_lQw
32
32
  maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  maleo_foundation/managers/db.py,sha256=Jf0w-9JOAG5X2quDxqqw6d2WUIX7MYGdlPGxWP0rxHs,4699
34
34
  maleo_foundation/managers/middleware.py,sha256=7CDXPMb28AR7J72TWOeKFxOlMypKezEtO9mr53a88B0,4032
35
- maleo_foundation/managers/service.py,sha256=RSjaJDjrvzfTE2z0IYpzJMKYnl4BFaF7UEPl3uupH5k,19215
35
+ maleo_foundation/managers/service.py,sha256=DLp2y7tPQVyBCg8TB5nraeDz4Z5uX-Tr-9thA49QhuE,20040
36
36
  maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  maleo_foundation/managers/client/base.py,sha256=K8AFV2MTZrC1jbTqxkx7eedmxodJirNIjoRXGGcppy4,1022
38
38
  maleo_foundation/managers/client/http.py,sha256=dWFZlG1z4TERYBITReR5oSrlzvdhh2EtztVnsU8gCeA,2712
@@ -83,7 +83,7 @@ maleo_foundation/utils/logging.py,sha256=MwvZmZSA8SIdfq-knEvpYIgqnSpHcyHrZY9TVHW
83
83
  maleo_foundation/utils/query.py,sha256=ODQ3adOYQNj5E2cRW9ytbjBz56nEDcnfq8mQ6YZbCCM,4375
84
84
  maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
85
85
  maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
86
- maleo_foundation-0.1.23.dist-info/METADATA,sha256=IyQWkb3bbyLlrfs-ah3AIHil03lB2s4zsOovEZ3FJOg,3190
87
- maleo_foundation-0.1.23.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
88
- maleo_foundation-0.1.23.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
89
- maleo_foundation-0.1.23.dist-info/RECORD,,
86
+ maleo_foundation-0.1.24.dist-info/METADATA,sha256=7yxL5FgFIua_89OydBwsndTLQPfKvMqAZamurVMUHnE,3190
87
+ maleo_foundation-0.1.24.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
88
+ maleo_foundation-0.1.24.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
89
+ maleo_foundation-0.1.24.dist-info/RECORD,,