keboola.component 1.6.1__tar.gz → 1.6.3__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 (18) hide show
  1. {keboola.component-1.6.1/src/keboola.component.egg-info → keboola.component-1.6.3}/PKG-INFO +1 -1
  2. {keboola.component-1.6.1 → keboola.component-1.6.3}/setup.py +1 -1
  3. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/dao.py +49 -32
  4. {keboola.component-1.6.1 → keboola.component-1.6.3/src/keboola.component.egg-info}/PKG-INFO +1 -1
  5. {keboola.component-1.6.1 → keboola.component-1.6.3}/LICENSE +0 -0
  6. {keboola.component-1.6.1 → keboola.component-1.6.3}/README.md +0 -0
  7. {keboola.component-1.6.1 → keboola.component-1.6.3}/setup.cfg +0 -0
  8. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/__init__.py +0 -0
  9. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/base.py +0 -0
  10. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/exceptions.py +0 -0
  11. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/interface.py +0 -0
  12. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/sync_actions.py +0 -0
  13. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola/component/table_schema.py +0 -0
  14. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola.component.egg-info/SOURCES.txt +0 -0
  15. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola.component.egg-info/dependency_links.txt +0 -0
  16. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola.component.egg-info/not-zip-safe +0 -0
  17. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola.component.egg-info/requires.txt +0 -0
  18. {keboola.component-1.6.1 → keboola.component-1.6.3}/src/keboola.component.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: keboola.component
3
- Version: 1.6.1
3
+ Version: 1.6.3
4
4
  Summary: General library for Python applications running in Keboola Connection environment
5
5
  Home-page: https://github.com/keboola/python-component
6
6
  Author: Keboola KDS Team
@@ -13,7 +13,7 @@ project_urls = {
13
13
 
14
14
  setuptools.setup(
15
15
  name="keboola.component",
16
- version="1.6.1",
16
+ version="1.6.3",
17
17
  author="Keboola KDS Team",
18
18
  project_urls=project_urls,
19
19
  setup_requires=['pytest-runner', 'flake8'],
@@ -597,9 +597,6 @@ class IODefinition(ABC):
597
597
  def __init__(self, full_path):
598
598
  self.full_path = full_path
599
599
 
600
- # infer stage by default
601
- self.__stage = self.__get_stage_inferred()
602
-
603
600
  @classmethod
604
601
  def build_from_manifest(cls,
605
602
  manifest_file_path: str
@@ -619,13 +616,13 @@ class IODefinition(ABC):
619
616
  """
620
617
  Helper property marking the stage of the file. (str)
621
618
  """
622
- return self.__stage
619
+ return self._stage
623
620
 
624
621
  @stage.setter
625
622
  def stage(self, stage: str):
626
623
  if stage not in ['in', 'out']:
627
624
  raise ValueError(f'Invalid stage "{stage}", supported values are: "in", "out"')
628
- self.__stage = stage
625
+ self._stage = stage
629
626
 
630
627
  @property
631
628
  @abstractmethod
@@ -643,17 +640,6 @@ class IODefinition(ABC):
643
640
  """
644
641
  raise NotImplementedError
645
642
 
646
- def __get_stage_inferred(self):
647
- stage = 'in'
648
- if not self.full_path or not Path(self.full_path).exists():
649
- return stage
650
-
651
- if Path(self.full_path).parent.parent.name == 'in':
652
- stage = 'in'
653
- elif Path(self.full_path).parent.parent.name == 'out':
654
- stage = 'out'
655
- return stage
656
-
657
643
  # ############ Staging parameters
658
644
 
659
645
  @dataclass
@@ -792,7 +778,7 @@ class TableDefinition(IODefinition):
792
778
  enclosure: Optional[str] = '"',
793
779
  delimiter: Optional[str] = ',',
794
780
  delete_where: Optional[dict] = None,
795
- stage: Optional[str] = None,
781
+ stage: Optional[str] = 'out',
796
782
  write_always: Optional[bool] = False,
797
783
  has_header: Optional[bool] = None,
798
784
  # input
@@ -870,7 +856,7 @@ class TableDefinition(IODefinition):
870
856
  self._data_size_bytes = kwargs.get('data_size_bytes')
871
857
  self._is_alias = kwargs.get('is_alias')
872
858
 
873
- self.stage = stage if stage else self.__get_stage_inferred()
859
+ self.stage = stage
874
860
  self.has_header = has_header or self._has_header_in_file()
875
861
 
876
862
  def __get_stage_inferred(self):
@@ -1101,7 +1087,13 @@ class TableDefinition(IODefinition):
1101
1087
  DeprecationWarning)
1102
1088
  force_legacy_mode = True
1103
1089
 
1090
+ if manifest.get('id'):
1091
+ stage = 'in'
1092
+ else:
1093
+ stage = 'out'
1094
+
1104
1095
  table_def = cls(name=name,
1096
+ stage=stage,
1105
1097
  full_path=full_path,
1106
1098
  is_sliced=is_sliced,
1107
1099
  id=manifest.get('id'),
@@ -1395,6 +1387,8 @@ class TableDefinition(IODefinition):
1395
1387
  self._table_metadata = table_metadata
1396
1388
  # backward compatibility legacy support
1397
1389
  for col, val in table_metadata._get_legacy_column_metadata_for_manifest().items():
1390
+ if not self.schema.get(col):
1391
+ self.schema[col] = ColumnDefinition()
1398
1392
  self.schema[col].metadata = {item['key']: item['value'] for item in val}
1399
1393
 
1400
1394
  @property
@@ -1536,6 +1530,7 @@ class FileDefinition(IODefinition):
1536
1530
  "notify"]
1537
1531
 
1538
1532
  def __init__(self, full_path: str,
1533
+ stage: Optional[str] = 'out',
1539
1534
  tags: Optional[List[str]] = None,
1540
1535
  is_public: Optional[bool] = False,
1541
1536
  is_permanent: Optional[bool] = False,
@@ -1552,6 +1547,7 @@ class FileDefinition(IODefinition):
1552
1547
 
1553
1548
  Args:
1554
1549
  full_path (str): Full path of the file.
1550
+ stage (str): Storage Stage 'in' or 'out' default out
1555
1551
  tags (list):
1556
1552
  List of tags that are assigned to this file
1557
1553
  is_public: When true, the file URL will be permanent and publicly accessible.
@@ -1562,6 +1558,8 @@ class FileDefinition(IODefinition):
1562
1558
  """
1563
1559
  super().__init__(full_path)
1564
1560
 
1561
+ self.stage = stage
1562
+
1565
1563
  self.tags = tags
1566
1564
  self.is_public = is_public
1567
1565
  self.is_permanent = is_permanent
@@ -1602,7 +1600,7 @@ class FileDefinition(IODefinition):
1602
1600
  Returns:
1603
1601
  An instance of FileDefinition configured for output files.
1604
1602
  """
1605
- return cls(full_path=full_path, tags=tags, is_public=is_public, is_permanent=is_permanent,
1603
+ return cls(full_path=full_path, stage="out", tags=tags, is_public=is_public, is_permanent=is_permanent,
1606
1604
  is_encrypted=is_encrypted, notify=notify)
1607
1605
 
1608
1606
  @classmethod
@@ -1632,7 +1630,7 @@ class FileDefinition(IODefinition):
1632
1630
  Returns:
1633
1631
  An instance of FileDefinition configured for input files.
1634
1632
  """
1635
- return cls(full_path=full_path, id=id, s3=s3, abs=abs, created=created, size_bytes=size_bytes,
1633
+ return cls(full_path=full_path, stage="in", id=id, s3=s3, abs=abs, created=created, size_bytes=size_bytes,
1636
1634
  max_age_days=max_age_days)
1637
1635
 
1638
1636
  @classmethod
@@ -1667,7 +1665,13 @@ class FileDefinition(IODefinition):
1667
1665
 
1668
1666
  full_path = str(file_path)
1669
1667
 
1668
+ if manifest.get('id'):
1669
+ stage = 'in'
1670
+ else:
1671
+ stage = 'out'
1672
+
1670
1673
  file_def = cls(full_path=full_path,
1674
+ stage=stage,
1671
1675
  tags=manifest.get('tags', []),
1672
1676
  is_public=manifest.get('is_public', False),
1673
1677
  is_permanent=manifest.get('is_permanent', False),
@@ -1732,18 +1736,31 @@ class FileDefinition(IODefinition):
1732
1736
 
1733
1737
  """
1734
1738
 
1735
- return {
1736
- 'id': self.id,
1737
- 'created': self.created.strftime('%Y-%m-%dT%H:%M:%S%z') if self.created else None,
1738
- 'is_public': self.is_public,
1739
- 'is_encrypted': self.is_encrypted,
1740
- 'name': self.name,
1741
- 'size_bytes': self.size_bytes,
1742
- 'tags': self.tags,
1743
- 'notify': self.notify,
1744
- 'max_age_days': self.max_age_days,
1745
- 'is_permanent': self.is_permanent,
1746
- }
1739
+ if manifest_type == 'in':
1740
+
1741
+ manifest_dictionary = {
1742
+ 'id': self.id,
1743
+ 'created': self.created.strftime('%Y-%m-%dT%H:%M:%S%z') if self.created else None,
1744
+ 'is_public': self.is_public,
1745
+ 'is_encrypted': self.is_encrypted,
1746
+ 'name': self.name,
1747
+ 'size_bytes': self.size_bytes,
1748
+ 'tags': self.tags,
1749
+ 'notify': self.notify,
1750
+ 'max_age_days': self.max_age_days,
1751
+ 'is_permanent': self.is_permanent,
1752
+ }
1753
+
1754
+ else:
1755
+ manifest_dictionary = {
1756
+ 'is_public': self.is_public,
1757
+ 'is_permanent': self.is_permanent,
1758
+ 'is_encrypted': self.is_encrypted,
1759
+ 'tags': self.tags,
1760
+ 'notify': self.notify,
1761
+ }
1762
+
1763
+ return manifest_dictionary
1747
1764
 
1748
1765
  @property
1749
1766
  def name(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: keboola.component
3
- Version: 1.6.1
3
+ Version: 1.6.3
4
4
  Summary: General library for Python applications running in Keboola Connection environment
5
5
  Home-page: https://github.com/keboola/python-component
6
6
  Author: Keboola KDS Team