vtlengine 1.1rc2__py3-none-any.whl → 1.2.0__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.

Potentially problematic release.


This version of vtlengine might be problematic. Click here for more details.

Files changed (44) hide show
  1. vtlengine/API/_InternalApi.py +288 -29
  2. vtlengine/API/__init__.py +277 -70
  3. vtlengine/AST/ASTComment.py +56 -0
  4. vtlengine/AST/ASTConstructor.py +71 -18
  5. vtlengine/AST/ASTConstructorModules/Expr.py +197 -75
  6. vtlengine/AST/ASTConstructorModules/ExprComponents.py +81 -38
  7. vtlengine/AST/ASTConstructorModules/Terminals.py +76 -31
  8. vtlengine/AST/ASTConstructorModules/__init__.py +50 -0
  9. vtlengine/AST/ASTEncoders.py +4 -0
  10. vtlengine/AST/ASTString.py +622 -0
  11. vtlengine/AST/ASTTemplate.py +28 -2
  12. vtlengine/AST/DAG/__init__.py +44 -6
  13. vtlengine/AST/DAG/_words.py +1 -0
  14. vtlengine/AST/Grammar/Vtl.g4 +7 -7
  15. vtlengine/AST/Grammar/lexer.py +19759 -1112
  16. vtlengine/AST/Grammar/parser.py +17996 -3199
  17. vtlengine/AST/__init__.py +127 -14
  18. vtlengine/Exceptions/messages.py +14 -2
  19. vtlengine/Interpreter/__init__.py +90 -11
  20. vtlengine/Model/__init__.py +9 -4
  21. vtlengine/Operators/Aggregation.py +13 -6
  22. vtlengine/Operators/Analytic.py +19 -13
  23. vtlengine/Operators/CastOperator.py +5 -2
  24. vtlengine/Operators/Clause.py +26 -18
  25. vtlengine/Operators/Comparison.py +3 -1
  26. vtlengine/Operators/Conditional.py +40 -18
  27. vtlengine/Operators/General.py +3 -1
  28. vtlengine/Operators/HROperators.py +3 -1
  29. vtlengine/Operators/Join.py +4 -2
  30. vtlengine/Operators/Time.py +22 -15
  31. vtlengine/Operators/Validation.py +5 -2
  32. vtlengine/Operators/__init__.py +15 -8
  33. vtlengine/Utils/__Virtual_Assets.py +34 -0
  34. vtlengine/Utils/__init__.py +49 -0
  35. vtlengine/__init__.py +4 -2
  36. vtlengine/files/parser/__init__.py +16 -26
  37. vtlengine/files/parser/_rfc_dialect.py +1 -1
  38. vtlengine/py.typed +0 -0
  39. vtlengine-1.2.0.dist-info/METADATA +92 -0
  40. vtlengine-1.2.0.dist-info/RECORD +63 -0
  41. {vtlengine-1.1rc2.dist-info → vtlengine-1.2.0.dist-info}/WHEEL +1 -1
  42. vtlengine-1.1rc2.dist-info/METADATA +0 -248
  43. vtlengine-1.1rc2.dist-info/RECORD +0 -59
  44. {vtlengine-1.1rc2.dist-info → vtlengine-1.2.0.dist-info}/LICENSE.md +0 -0
vtlengine/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
- from vtlengine.API import run, semantic_analysis
1
+ from vtlengine.API import generate_sdmx, prettify, run, run_sdmx, semantic_analysis
2
2
 
3
- __all__ = ["semantic_analysis", "run"]
3
+ __all__ = ["semantic_analysis", "run", "generate_sdmx", "run_sdmx", "prettify"]
4
+
5
+ __version__ = "1.2.0"
@@ -42,14 +42,9 @@ def _validate_csv_path(components: Dict[str, Component], csv_path: Path) -> None
42
42
  raise Exception(f"Path {csv_path} is not a file.")
43
43
  register_rfc()
44
44
  try:
45
- with open(csv_path, "r") as f:
45
+ with open(csv_path, "r", errors="replace", encoding="utf-8") as f:
46
46
  reader = DictReader(f, dialect="rfc")
47
47
  csv_columns = reader.fieldnames
48
-
49
- except UnicodeDecodeError as error:
50
- # https://coderwall.com/p/stzy9w/raising-unicodeencodeerror-and-unicodedecodeerror-
51
- # manually-for-testing-purposes
52
- raise InputValidationException("0-1-2-5", file=csv_path.name) from error
53
48
  except InputValidationException as ie:
54
49
  raise InputValidationException("{}".format(str(ie))) from None
55
50
  except Exception as e:
@@ -110,21 +105,16 @@ def _sanitize_pandas_columns(
110
105
 
111
106
 
112
107
  def _pandas_load_csv(components: Dict[str, Component], csv_path: Union[str, Path]) -> pd.DataFrame:
113
- obj_dtypes = {comp_name: np.object_ for comp_name, comp in components.items()}
114
-
115
- try:
116
- data = pd.read_csv(
117
- csv_path,
118
- dtype=obj_dtypes,
119
- engine="c",
120
- keep_default_na=False,
121
- na_values=[""],
122
- )
123
- except UnicodeDecodeError:
124
- if isinstance(csv_path, Path):
125
- raise InputValidationException(code="0-1-2-5", file=csv_path.name)
126
- else:
127
- raise InputValidationException(code="0-1-2-5", file=csv_path)
108
+ obj_dtypes = {comp_name: object for comp_name, comp in components.items()}
109
+
110
+ data = pd.read_csv(
111
+ csv_path,
112
+ dtype=obj_dtypes,
113
+ engine="c",
114
+ keep_default_na=False,
115
+ na_values=[""],
116
+ encoding_errors="replace",
117
+ )
128
118
 
129
119
  return _sanitize_pandas_columns(components, csv_path, data)
130
120
 
@@ -170,13 +160,13 @@ def _validate_pandas(
170
160
  )
171
161
  elif comp.data_type == Integer:
172
162
  data[comp_name] = data[comp_name].map(
173
- lambda x: Integer.cast(float(x)), na_action="ignore"
163
+ lambda x: Integer.cast(float(str(x))), na_action="ignore"
174
164
  )
175
165
  elif comp.data_type == Number:
176
- data[comp_name] = data[comp_name].map(lambda x: float(x), na_action="ignore")
166
+ data[comp_name] = data[comp_name].map(lambda x: float((str(x))), na_action="ignore")
177
167
  elif comp.data_type == Boolean:
178
168
  data[comp_name] = data[comp_name].map(
179
- lambda x: _parse_boolean(x), na_action="ignore"
169
+ lambda x: _parse_boolean(str(x)), na_action="ignore"
180
170
  )
181
171
  elif comp.data_type == Duration:
182
172
  values_correct = (
@@ -192,7 +182,7 @@ def _validate_pandas(
192
182
  values_correct = (
193
183
  data[comp_name]
194
184
  .map(
195
- lambda x: x.replace(" ", "") in PERIOD_IND_MAPPING,
185
+ lambda x: x.replace(" ", "") in PERIOD_IND_MAPPING, # type: ignore[union-attr]
196
186
  na_action="ignore",
197
187
  )
198
188
  .all()
@@ -207,7 +197,7 @@ def _validate_pandas(
207
197
  data[comp_name] = data[comp_name].map(
208
198
  lambda x: str(x).replace('"', ""), na_action="ignore"
209
199
  )
210
- data[comp_name] = data[comp_name].astype(np.object_, errors="raise")
200
+ data[comp_name] = data[comp_name].astype(object, errors="raise")
211
201
 
212
202
  except ValueError:
213
203
  str_comp = SCALAR_TYPES_CLASS_REVERSE[comp.data_type] if comp else "Null"
@@ -19,4 +19,4 @@ class RFCDialect(csv.Dialect):
19
19
 
20
20
  def register_rfc() -> None:
21
21
  """Register the RFC dialect."""
22
- csv.register_dialect("rfc", RFCDialect) # type: ignore[arg-type]
22
+ csv.register_dialect("rfc", RFCDialect)
vtlengine/py.typed ADDED
File without changes
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.3
2
+ Name: vtlengine
3
+ Version: 1.2.0
4
+ Summary: Run and Validate VTL Scripts
5
+ License: AGPL-3.0
6
+ Keywords: vtl,sdmx,vtlengine,Validation and Transformation Language
7
+ Author: MeaningfulData
8
+ Author-email: info@meaningfuldata.eu
9
+ Maintainer: Francisco Javier Hernandez del Caño
10
+ Maintainer-email: javier.hernandez@meaningfuldata.eu
11
+ Requires-Python: >=3.9
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Information Technology
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Typing :: Typed
17
+ Provides-Extra: all
18
+ Provides-Extra: s3
19
+ Requires-Dist: antlr4-python3-runtime (>=4.13.2,<4.14)
20
+ Requires-Dist: duckdb (>=1.1,<1.2)
21
+ Requires-Dist: fsspec (>=2022.11.0,<2023.0) ; extra == "all"
22
+ Requires-Dist: fsspec (>=2022.11.0,<2023.0) ; extra == "s3"
23
+ Requires-Dist: jsonschema (>=3.2.0,<5.0)
24
+ Requires-Dist: networkx (>=2.8,<3.0)
25
+ Requires-Dist: numpy (>=1.23.2,<2) ; python_version < "3.13"
26
+ Requires-Dist: numpy (>=2.1.0) ; python_version >= "3.13"
27
+ Requires-Dist: pandas (>=2.1.4,<3.0)
28
+ Requires-Dist: pysdmx[xml] (>=1.4.0rc1,<2.0)
29
+ Requires-Dist: s3fs (>=2022.11.0,<2023.0) ; extra == "all"
30
+ Requires-Dist: s3fs (>=2022.11.0,<2023.0) ; extra == "s3"
31
+ Requires-Dist: sqlglot (>=22.2.0,<23.0)
32
+ Project-URL: Authors, https://github.com/Meaningful-Data/vtlengine/graphs/contributors
33
+ Project-URL: Documentation, https://docs.vtlengine.meaningfuldata.eu
34
+ Project-URL: IssueTracker, https://github.com/Meaningful-Data/vtlengine/issues
35
+ Project-URL: MeaningfulData, https://www.meaningfuldata.eu/
36
+ Project-URL: Repository, https://github.com/Meaningful-Data/vtlengine
37
+ Description-Content-Type: text/markdown
38
+
39
+ # VTL Engine
40
+
41
+ | | |
42
+ |--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
43
+ | Testing | [![Testing](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml/badge.svg)](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml) |
44
+ | Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/vtlengine.svg)](https://pypi.org/project/vtlengine/) |
45
+ | License | [![License - AGPL 3.0](https://img.shields.io/pypi/l/vtlengine.svg)](https://github.com/Meaningful-Data/vtlengine/blob/main/LICENSE.md) |
46
+ | Mentioned in | [![Mentioned in Awesome Official Statistics ](https://awesome.re/mentioned-badge.svg)](https://github.com/SNStatComp/awesome-official-statistics-software) |
47
+
48
+ ## Introduction
49
+
50
+ The VTL Engine is a Python library that allows you to validate, format and execute VTL scripts.
51
+
52
+ It is a Python-based library around
53
+ the [VTL Language 2.1](https://sdmx-twg.github.io/vtl/2.1/html/index.html).
54
+
55
+ ## Useful Links
56
+
57
+ - [MeaningfulData: who we are](https://www.meaningfuldata.eu)
58
+ - [Documentation](https://docs.vtlengine.meaningfuldata.eu)
59
+ - [Source Code](https://github.com/Meaningful-Data/vtlengine)
60
+ - [Bug Tracker](https://github.com/Meaningful-Data/vtlengine/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
61
+ - [New features Tracker](https://github.com/Meaningful-Data/vtlengine/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement)
62
+
63
+ ## Installation
64
+
65
+ ### Requirements
66
+
67
+ The VTL Engine requires Python 3.9 or higher.
68
+
69
+ ### Install with pip
70
+
71
+ To install the VTL Engine on any Operating System, you can use pip:
72
+
73
+ ```bash
74
+
75
+ pip install vtlengine
76
+
77
+ ```
78
+
79
+ *Note: it is recommended to install the VTL Engine in a virtual environment.*
80
+
81
+ ### S3 extra
82
+
83
+ If you want to use the S3 functionality, you can install the VTL Engine with the `s3` extra:
84
+
85
+ ```bash
86
+ pip install vtlengine[s3]
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ The documentation for the VTL Engine is available
92
+ at [docs.vtlengine.meaningfuldata.eu](https://docs.vtlengine.meaningfuldata.eu).
@@ -0,0 +1,63 @@
1
+ vtlengine/API/_InternalApi.py,sha256=ptmL3F07ThTN2G2yLAo7p6Az_njScJYfBbasYUaLEF0,24167
2
+ vtlengine/API/__init__.py,sha256=XyL_7ZNaEfL5Xbler7iHI7MtsbHsQRvopSa25h14R3A,18598
3
+ vtlengine/API/data/schema/json_schema_2.1.json,sha256=v3-C0Xnq8qScJSPAtLgb3rjKMrd3nz-bIxgZdTSEUiU,4336
4
+ vtlengine/AST/ASTComment.py,sha256=bAJW7aaqBXU2LqMtRvL_XOttdl1AFZufa15vmQdvNlY,1667
5
+ vtlengine/AST/ASTConstructor.py,sha256=X55I98BKG1ItyGIDObF9ALVfCcWnU-0wwCWJsiPILkg,21488
6
+ vtlengine/AST/ASTConstructorModules/Expr.py,sha256=PdI66D3dwA4ymxgqqcChkctsWMRgBSfuyUtgH-KOkss,70207
7
+ vtlengine/AST/ASTConstructorModules/ExprComponents.py,sha256=2Ft4e5w2NtbfaqSNW8I9qSpG9iUaPIfdug7yYWo2gqE,38553
8
+ vtlengine/AST/ASTConstructorModules/Terminals.py,sha256=7zWDx_SFcbnL35G7Y0qZwl-lLEsfqReyzBX0UxwTCOk,27054
9
+ vtlengine/AST/ASTConstructorModules/__init__.py,sha256=J6g6NhJD8j0Ek1YmpethxRiFdjhLxUTM0mc3NHRFLlM,1879
10
+ vtlengine/AST/ASTDataExchange.py,sha256=kPSz21DGbEv-2bZowObseqf2d2_iQj1VnrqWuD9ZwtA,140
11
+ vtlengine/AST/ASTEncoders.py,sha256=-Ar6a0GqMdJZK4CtZ1pUpIeGv57oSdN5qy3-aF0Zt9c,948
12
+ vtlengine/AST/ASTString.py,sha256=mFZzkT5XO2p21ptt7nv3iBefJOcNsvuoWqwqaxfxMOc,25936
13
+ vtlengine/AST/ASTTemplate.py,sha256=qUkz0AE1ay3gFrCidzhJAqxRnZR8nj98DOKAW2rXoso,12961
14
+ vtlengine/AST/ASTVisitor.py,sha256=3QQTudBpbR4pPQdH7y07EgwuzhoGzNQ59qox8R-E3fM,500
15
+ vtlengine/AST/DAG/__init__.py,sha256=YDWcjd--blKfrzRCFHAhuzhefnAdGKEBFei9gZEVFas,16670
16
+ vtlengine/AST/DAG/_words.py,sha256=LyRL9j-vZUNHdLDJZJrq2nKUmVlpbxdzd9ovW6CnNoU,200
17
+ vtlengine/AST/Grammar/Vtl.g4,sha256=g4a76A04qH-SaR9a9LfrG4rt3GPZ7UpqZLISkY1BkmI,26323
18
+ vtlengine/AST/Grammar/VtlTokens.g4,sha256=SwDR_59U25APqslczFcvTUiPoH7bC6kGaH2GkJ3kYzA,9972
19
+ vtlengine/AST/Grammar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ vtlengine/AST/Grammar/lexer.py,sha256=66cH0cJi83Sxd8XPrPRYkBwdz4NGhPaadUnq5p0GYUI,256579
21
+ vtlengine/AST/Grammar/parser.py,sha256=fWJaGcXvUCwN2pvjJBU4l5apoQnkhQbUv_mSlKKiDXc,712465
22
+ vtlengine/AST/Grammar/tokens.py,sha256=YF7tO0nF2zYC-VaBAJLyc6VitM72CvYfFQpoPDGCMzo,3139
23
+ vtlengine/AST/VtlVisitor.py,sha256=NJfXJVP6wNmasJmPLlojFqm9R5VSamOAKg_w7BMrhac,35332
24
+ vtlengine/AST/__init__.py,sha256=JnPilognG2rT2gtpjD4OwKFX0O3ZqvV-ic8gJxRu7Xo,11672
25
+ vtlengine/DataTypes/TimeHandling.py,sha256=CYnC0sb1qbRjTnCSsA3wgez7QftOzrXHxbuZXlY3O3Q,20151
26
+ vtlengine/DataTypes/__init__.py,sha256=LYXrde68bYm7MLeMLmr4haeOTSE4Fnpq9G2Ewy7DiaU,23084
27
+ vtlengine/Exceptions/__init__.py,sha256=rSSskV_qCBFzg_W67Q1QBAL7Lnq88D7yi2BDYo1hytw,4727
28
+ vtlengine/Exceptions/messages.py,sha256=h2RHfgolbNsYXO39FXT3NTe2RwG-1AK5NL9k6utPtCA,19658
29
+ vtlengine/Interpreter/__init__.py,sha256=PKFBU6HW6_tIoycZU49GexxNbK-_CNWlQ7BFKAiy2Z8,85030
30
+ vtlengine/Model/__init__.py,sha256=xWrwhdUOj8Y-5x38zP5XnmFPw8IkBVBBG2bPsUBGLA8,15869
31
+ vtlengine/Operators/Aggregation.py,sha256=aB64ZcH3oR0WEYMFlwkML2CEc3pggKoFpIb_CoOCgJM,12002
32
+ vtlengine/Operators/Analytic.py,sha256=adm8y4mTeen4iVMsQvcvxM9U5f6Xj9UNjdCQI2OBINE,12934
33
+ vtlengine/Operators/Assignment.py,sha256=xyJgGPoFYbq6mzX06gz7Q7L8jXJxpUkgzdY3Lrne2hw,793
34
+ vtlengine/Operators/Boolean.py,sha256=3U5lHkxW5d7QQdGDNxXeXqejlPfFrXKG8_TqknrC8Ls,2856
35
+ vtlengine/Operators/CastOperator.py,sha256=pXTSs0UYBeR5hS3J2HWUyaHmoZoifl2EFch6ol_Taok,17115
36
+ vtlengine/Operators/Clause.py,sha256=Lu6zjcUBkShN6kQmjEZu_7ytaFGwfH-yB4ROoCSkLGI,15505
37
+ vtlengine/Operators/Comparison.py,sha256=CRMvs9qXVXUW32pxAnCua8b7ZHpJy0-Egvs691ekOCk,17403
38
+ vtlengine/Operators/Conditional.py,sha256=NDJa3yMdcfk8ninE1skNa5JBxLgTIKAKOeBDxlzm3oo,20258
39
+ vtlengine/Operators/General.py,sha256=ltRK8Sw686sb4rC5ji2OX-GYVxaK_PpL0Lev8P5OFHI,6828
40
+ vtlengine/Operators/HROperators.py,sha256=YybwD70906AA00c0k4IP6sjeta0pg7hqb2EUVsFqdmA,8979
41
+ vtlengine/Operators/Join.py,sha256=WhHnepjNrQiYC3keo5uuJ5RhcMxklccyKaOUOH2G5Zc,18229
42
+ vtlengine/Operators/Numeric.py,sha256=icYTWzEsw6VQFLYc5Wucgr8961d8ZwTFx_wfZ8Wp9Co,12083
43
+ vtlengine/Operators/RoleSetter.py,sha256=mHZIdcHC3wflj81ekLbioDG1f8yHZXYDQFymV-KnyXA,2274
44
+ vtlengine/Operators/Set.py,sha256=f1uLeY4XZF0cWEwpXRB_CczgbXr6s33DYPuFt39HlEg,7084
45
+ vtlengine/Operators/String.py,sha256=ghWtYl6oUEAAzynY1a9Hg4yqRA9Sa7uk2B6iF9uuSqQ,20230
46
+ vtlengine/Operators/Time.py,sha256=ESn6ldPg73bdZxOXZYJuIwCLDQnXDGTqR1y7ckQmV1M,43025
47
+ vtlengine/Operators/Validation.py,sha256=tnHRZ7o0Z_AE1Bb2DtRVP6pGGUtSs5KVwNSEJxzzGnk,10162
48
+ vtlengine/Operators/__init__.py,sha256=N1zi9RFC_l0qggRm5IPLOkPFtFS4CGAg-r1taHOrbTI,37667
49
+ vtlengine/Utils/__Virtual_Assets.py,sha256=t6cAikOjDVHilORXD6pzC3_twrl6BOutkSaaipQqEwU,856
50
+ vtlengine/Utils/__init__.py,sha256=zhGPJA8MjHmtEEwMS4CxEFYL0tk2L5F0YPn7bitdRzM,8954
51
+ vtlengine/__extras_check.py,sha256=Wr-lxGZhXJZEacVV5cUkvKt7XM-mry0kYAe3VxNrVcY,614
52
+ vtlengine/__init__.py,sha256=H1x4pfJSReVNIm472bKjZUbUf3Z0eusLQ4j-T9S5L2E,188
53
+ vtlengine/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ vtlengine/files/output/__init__.py,sha256=4tmf-p1Y1u5Ohrwt3clQA-FMGaijKI3HC_iwn3H9J8c,1250
55
+ vtlengine/files/output/_time_period_representation.py,sha256=D5XCSXyEuX_aBzTvBV3sZxACcgwXz2Uu_YH3loMP8q0,1610
56
+ vtlengine/files/parser/__init__.py,sha256=JamEIWI0pFZxT0sKYE6Fii8H2JQcsFn4Nf3T0OLSm9g,8637
57
+ vtlengine/files/parser/_rfc_dialect.py,sha256=Y8kAYBxH_t9AieN_tYg7QRh5A4DgvabKarx9Ko3QeCQ,462
58
+ vtlengine/files/parser/_time_checking.py,sha256=UAC_Pv-eQJKrhgTguWb--xfqMMs6quyMeiAkGBt_vgI,4725
59
+ vtlengine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
+ vtlengine-1.2.0.dist-info/LICENSE.md,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
61
+ vtlengine-1.2.0.dist-info/METADATA,sha256=L-6dsHpZwMO9A7T3UoSvXpU4NEEbgyvdZjneTzNGD1s,4132
62
+ vtlengine-1.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
63
+ vtlengine-1.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,248 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: vtlengine
3
- Version: 1.1rc2
4
- Summary: Run and Validate VTL Scripts
5
- License: AGPL-3.0
6
- Keywords: vtl,sdmx,vtlengine,Validation and Transformation Language
7
- Author: MeaningfulData
8
- Author-email: info@meaningfuldata.eu
9
- Maintainer: Francisco Javier Hernandez del Caño
10
- Maintainer-email: javier.hernandez@meaningfuldata.eu
11
- Requires-Python: >=3.9,<4
12
- Classifier: Development Status :: 5 - Production/Stable
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Information Technology
15
- Classifier: Intended Audience :: Science/Research
16
- Classifier: Typing :: Typed
17
- Provides-Extra: all
18
- Provides-Extra: s3
19
- Requires-Dist: antlr4-python3-runtime (>=4.9.2,<4.10)
20
- Requires-Dist: duckdb (>=1.1,<1.2)
21
- Requires-Dist: fsspec (>=2022.11.0,<2023.0) ; extra == "all"
22
- Requires-Dist: fsspec (>=2022.11.0,<2023.0) ; extra == "s3"
23
- Requires-Dist: jsonschema (>=3.2.0,<5.0)
24
- Requires-Dist: networkx (>=2.8,<3.0)
25
- Requires-Dist: pandas (>=2.1.4,<2.2)
26
- Requires-Dist: s3fs (>=2022.11.0,<2023.0) ; extra == "all"
27
- Requires-Dist: s3fs (>=2022.11.0,<2023.0) ; extra == "s3"
28
- Requires-Dist: sqlglot (>=22.2.0,<23.0)
29
- Project-URL: Authors, https://github.com/Meaningful-Data/vtlengine/graphs/contributors
30
- Project-URL: Documentation, https://docs.vtlengine.meaningfuldata.eu
31
- Project-URL: IssueTracker, https://github.com/Meaningful-Data/vtlengine/issues
32
- Project-URL: MeaningfulData, https://www.meaningfuldata.eu/
33
- Project-URL: Repository, https://github.com/Meaningful-Data/vtlengine
34
- Description-Content-Type: text/markdown
35
-
36
- # VTL Engine
37
-
38
- | | |
39
- |---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
40
- | Testing | [![Testing](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml/badge.svg)](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml) |
41
- | Package | [![PyPI Latest Release](https://img.shields.io/pypi/v/vtlengine.svg)](https://pypi.org/project/vtlengine/) |
42
- | License | [![License - AGPL 3.0](https://img.shields.io/pypi/l/vtlengine.svg)](https://github.com/Meaningful-Data/vtlengine/blob/main/LICENSE.md) |
43
-
44
- ## Introduction
45
-
46
- The VTL Engine is a Python library for validating and running VTL scripts.
47
-
48
- It is a Python-based library around the [VTL Language](http://sdmx.org/?page_id=5096).
49
-
50
- ## Installation
51
-
52
- ### Requirements
53
-
54
- The VTL Engine requires Python 3.10 or higher.
55
-
56
- ### Install with pip
57
-
58
- To install the VTL Engine on any Operating System, you can use pip:
59
-
60
- ```bash
61
-
62
- pip install vtlengine
63
-
64
- ```
65
-
66
- *Note: it is recommended to install the VTL Engine in a virtual environment.*
67
-
68
- ## Usage
69
-
70
- The VTL Engine API implements two basic methods:
71
-
72
- * **Semantic Analysis**: aimed at validating the correctness of a script and computing the data
73
- structures of the data sets created in the script.
74
- * **Run**: aimed at executing the provided input on the provided input datasets.
75
-
76
- Any action with VTL requires the following elements as input:
77
-
78
- * **VTL Script**: Is the VTL to be executed, which includes the transformation scheme, as well as de
79
- User Defined Operators, Hierarchical Rulesets and Datapoint Rulesets. It is provided as a string
80
- or as a Path object to a vtl file.
81
- * **Data structures** : Provides the structure of the input artifacts of the VTL script, according
82
- to
83
- the VTL Information model. Given that the current version doesn't prescribe a standard format for
84
- providing the information, the VTL Engine is implementing a JSON format that can be found here.
85
- Data Structures can be provided as Dictionaries or as Paths to JSON files. It is possible to have
86
- * **External routines**: The VTL Engine allows using SQL (SQLite) with the eval operator. Can be
87
- provided as a string with the SQL or as a path object to an SQL file. Its default value is `None`,
88
- which shall be used if external routines are not applicable to the VTL script.
89
- * **Value domains**: Provides the value domains that are used in the VTL script, normally with an in
90
- operator. Can be provided as a dictionary or as a path to a JSON file. Its default value
91
- is `None`, which shall be used if value domains are not applicable to the VTL script.
92
-
93
- ### Semantic Analysis
94
-
95
- The `semantic_analysis` method serves to validate the correctness of a VTL script, as well as to
96
- calculate the data structures of the datasets generated by the VTL script itself (that calculation
97
- is a pre-requisite for the semantic analysis).
98
-
99
- * If the VTL script is correct, the method returns a dictionary with the data structures of all the
100
- datasets generated by the script.
101
- * If the VTL script is incorrect, raises a VTL Engine custom error Explaining the error.
102
-
103
- #### Example 1: Correct VTL
104
-
105
- ```python
106
- from vtlengine import semantic_analysis
107
-
108
- script = """
109
- DS_A := DS_1 * 10;
110
- """
111
-
112
- data_structures = {
113
- 'datasets': [
114
- {'name': 'DS_1',
115
- 'DataStructure': [
116
- {'name': 'Id_1',
117
- 'type':
118
- 'Integer',
119
- 'role': 'Identifier',
120
- 'nullable': False},
121
- {'name': 'Me_1',
122
- 'type': 'Number',
123
- 'role': 'Measure',
124
- 'nullable': True}
125
- ]
126
- }
127
- ]
128
- }
129
-
130
- sa_result = semantic_analysis(script=script, data_structures=data_structures)
131
-
132
- print(sa_result)
133
-
134
- ```
135
-
136
- Returns:
137
-
138
- ```
139
- {'DS_A': Dataset(name='DS_A', components={'Id_1': Component(name='Id_1', data_type=<class 'vtlengine.DataTypes.Integer'>, role=<Role.IDENTIFIER: 'Identifier'>, nullable=False), 'Me_1': Component(name='Me_1', data_type=<class 'vtlengine.DataTypes.Number'>, role=<Role.MEASURE: 'Measure'>, nullable=True)}, data=None)}
140
- ```
141
-
142
- #### Example 2: Incorrect VTL
143
-
144
- Note that, as compared to Example 1, the only change is that Me_1 is of the String data type,
145
- instead of Number.
146
-
147
- ```python
148
- from vtlengine import semantic_analysis
149
-
150
- script = """
151
- DS_A := DS_1 * 10;
152
- """
153
-
154
- data_structures = {
155
- 'datasets': [
156
- {'name': 'DS_1',
157
- 'DataStructure': [
158
- {'name': 'Id_1',
159
- 'type':
160
- 'Integer',
161
- 'role': 'Identifier',
162
- 'nullable': False},
163
- {'name': 'Me_1',
164
- 'type': 'String',
165
- 'role': 'Measure',
166
- 'nullable': True}
167
- ]
168
- }
169
- ]
170
- }
171
-
172
- sa_result = semantic_analysis(script=script, data_structures=data_structures)
173
-
174
- print(sa_result)
175
-
176
- ```
177
-
178
- Will raise the following Error:
179
-
180
- ``` python
181
- raise SemanticError(code="1-1-1-2",
182
- vtlengine.Exceptions.SemanticError: ('Invalid implicit cast from String and Integer to Number.', '1-1-1-2')
183
- ```
184
-
185
- ### Run VTL Scripts
186
-
187
- The `run` method serves to execute a VTL script with input datapoints.
188
-
189
- Returns a dictionary with all the generated Datasets.
190
- When the output parameter is set, the engine will write the result of the computation to the output
191
- folder, else it will include the data in the dictionary of the computed datasets.
192
-
193
- Two validations are performed before running, which can raise errors:
194
-
195
- * Semantic analysis: Equivalent to running the `semantic_analysis` method
196
- * Data load analysis: Basic check of the data structure (names and types)
197
-
198
- #### Example 3: Simple run
199
-
200
- ```python
201
- from vtlengine import run
202
- import pandas as pd
203
-
204
- script = """
205
- DS_A := DS_1 * 10;
206
- """
207
-
208
- data_structures = {
209
- 'datasets': [
210
- {'name': 'DS_1',
211
- 'DataStructure': [
212
- {'name': 'Id_1',
213
- 'type':
214
- 'Integer',
215
- 'role': 'Identifier',
216
- 'nullable': False},
217
- {'name': 'Me_1',
218
- 'type': 'Number',
219
- 'role': 'Measure',
220
- 'nullable': True}
221
- ]
222
- }
223
- ]
224
- }
225
-
226
- data_df = pd.DataFrame(
227
- {"Id_1": [1, 2, 3],
228
- "Me_1": [10, 20, 30]})
229
-
230
- datapoints = {"DS_1": data_df}
231
-
232
- run_result = run(script=script, data_structures=data_structures,
233
- datapoints=datapoints)
234
-
235
- print(run_result)
236
- ```
237
-
238
- returns:
239
-
240
- ``` python
241
- {'DS_A': Dataset(name='DS_A', components={'Id_1': Component(name='Id_1', data_type=<class 'vtlengine.DataTypes.Integer'>, role=<Role.IDENTIFIER: 'Identifier'>, nullable=False), 'Me_1': Component(name='Me_1', data_type=<class 'vtlengine.DataTypes.Number'>, role=<Role.MEASURE: 'Measure'>, nullable=True)}, data= Id_1 Me_1
242
- 0 1 100.0
243
- 1 2 200.0
244
- 2 3 300.0)}
245
- ```
246
-
247
- For more information on usage, please refer to
248
- the [API documentation](https://docs.vtlengine.meaningfuldata.eu/api.html).
@@ -1,59 +0,0 @@
1
- vtlengine/API/_InternalApi.py,sha256=fz_JSIrLdXd29Tbg7FI6uZQE1wdOTlJPSZ27tPXHjeM,14825
2
- vtlengine/API/__init__.py,sha256=naHb-bFROB7du0ffbyQquEuvD-LkO8Turpw8XFrNvL8,10921
3
- vtlengine/API/data/schema/json_schema_2.1.json,sha256=v3-C0Xnq8qScJSPAtLgb3rjKMrd3nz-bIxgZdTSEUiU,4336
4
- vtlengine/AST/ASTConstructor.py,sha256=DdE0B6CyPt1RYb3he6L0tL-KhZ1UyHRxQisGC1GuKx8,19692
5
- vtlengine/AST/ASTConstructorModules/Expr.py,sha256=C4-toJm3bDt53_YSooeCJiqyUhK1ykgpiQTZjyZYsLE,65344
6
- vtlengine/AST/ASTConstructorModules/ExprComponents.py,sha256=6zUFY5a9KxzdOoSvC8TMyziYmfVW2bMbwYBI9r779Yg,36461
7
- vtlengine/AST/ASTConstructorModules/Terminals.py,sha256=141hfXUm5Xh53KD_W5VK5LwRMf8FYWLZ0PFR4Io2Dyo,25272
8
- vtlengine/AST/ASTConstructorModules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- vtlengine/AST/ASTDataExchange.py,sha256=kPSz21DGbEv-2bZowObseqf2d2_iQj1VnrqWuD9ZwtA,140
10
- vtlengine/AST/ASTEncoders.py,sha256=HZfG-Oo2u2l16tloEsHLAyNoLbkBC30X3H7drLq44rA,773
11
- vtlengine/AST/ASTTemplate.py,sha256=3dd9fkWNJywDn279tUuZGcOCPbyMiGiqnBwqAB1FWrU,12357
12
- vtlengine/AST/ASTVisitor.py,sha256=3QQTudBpbR4pPQdH7y07EgwuzhoGzNQ59qox8R-E3fM,500
13
- vtlengine/AST/DAG/__init__.py,sha256=DyFF3ZQW3f8RvtQ3X1I52BGk3CY8j51fCE5eEEwx6Dc,14618
14
- vtlengine/AST/DAG/_words.py,sha256=lEuBQ_w-KoKGna-x3gFGfbX1KP4Ez5EgdomH2LOeodk,170
15
- vtlengine/AST/Grammar/Vtl.g4,sha256=86bBWjQLCHZSuB5iLIk0JZRgMyMg0n7xbU8qzot2cIE,26313
16
- vtlengine/AST/Grammar/VtlTokens.g4,sha256=SwDR_59U25APqslczFcvTUiPoH7bC6kGaH2GkJ3kYzA,9972
17
- vtlengine/AST/Grammar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- vtlengine/AST/Grammar/lexer.py,sha256=ncoPevKkUpGyYx5mVKcKjocVhFoKSdu-5NSQDPY2V3g,105742
19
- vtlengine/AST/Grammar/parser.py,sha256=ISi5OWmPbLitMp-8fg-wa1-475TfKZWK98jXjyOLi-8,634355
20
- vtlengine/AST/Grammar/tokens.py,sha256=YF7tO0nF2zYC-VaBAJLyc6VitM72CvYfFQpoPDGCMzo,3139
21
- vtlengine/AST/VtlVisitor.py,sha256=NJfXJVP6wNmasJmPLlojFqm9R5VSamOAKg_w7BMrhac,35332
22
- vtlengine/AST/__init__.py,sha256=_-NLJ-GCX5mMmAUGPnY3NzErnFEgjg8LdoGfpdRQjrU,9809
23
- vtlengine/DataTypes/TimeHandling.py,sha256=CYnC0sb1qbRjTnCSsA3wgez7QftOzrXHxbuZXlY3O3Q,20151
24
- vtlengine/DataTypes/__init__.py,sha256=LYXrde68bYm7MLeMLmr4haeOTSE4Fnpq9G2Ewy7DiaU,23084
25
- vtlengine/Exceptions/__init__.py,sha256=rSSskV_qCBFzg_W67Q1QBAL7Lnq88D7yi2BDYo1hytw,4727
26
- vtlengine/Exceptions/messages.py,sha256=Flczp7SrsLfMHjXaSPhM3mx9ScsWiUvEvcdKR53teeA,18811
27
- vtlengine/Interpreter/__init__.py,sha256=MBI5ApmgHljAjmdSkFi-2II_ELGQ4xWNkYI2dPMzaSg,81375
28
- vtlengine/Model/__init__.py,sha256=DOxJA_MlFVq2s0Yqx8S4TwXulMP8v3MpIh1CgW19vYg,15553
29
- vtlengine/Operators/Aggregation.py,sha256=yS8_ZwMbQuIt-FJ_O_KQp-dYxF5bj2CktERuaGoMuAY,11798
30
- vtlengine/Operators/Analytic.py,sha256=x-koqCS4z6BeD89Q2fDzU-LnQyTuynp_aayFbvmXkpQ,12573
31
- vtlengine/Operators/Assignment.py,sha256=xyJgGPoFYbq6mzX06gz7Q7L8jXJxpUkgzdY3Lrne2hw,793
32
- vtlengine/Operators/Boolean.py,sha256=3U5lHkxW5d7QQdGDNxXeXqejlPfFrXKG8_TqknrC8Ls,2856
33
- vtlengine/Operators/CastOperator.py,sha256=mvWfNhJ1pEEk_ZQp-3unLoYJvJShUjUu_BOYQ6ByySI,16951
34
- vtlengine/Operators/Clause.py,sha256=_Sdt3qQUpphNRs4IQW5pSj9kagzwLluV9BRHMGNxqsI,15022
35
- vtlengine/Operators/Comparison.py,sha256=7G2UK1BDCDJR4jTXa-txJlAJEvzXEeYaDSA_2oxjgKY,17286
36
- vtlengine/Operators/Conditional.py,sha256=kjFQ90DS3lVIeYdsDlhxne_dOCtzTdvnWY8AOnR7ceM,19294
37
- vtlengine/Operators/General.py,sha256=q1fpqP4IYEwURXi8Eo-_j5AUktK0dvNosL9SgSe7a8w,6711
38
- vtlengine/Operators/HROperators.py,sha256=VVp5FcdbDXhU_VCfUA6t75bs51qx9fKJT4n15WM2vyM,8866
39
- vtlengine/Operators/Join.py,sha256=df2XG2tKmha_WUhHEYhgZIVc_2L8Wr45o0ISm-HOReA,18108
40
- vtlengine/Operators/Numeric.py,sha256=icYTWzEsw6VQFLYc5Wucgr8961d8ZwTFx_wfZ8Wp9Co,12083
41
- vtlengine/Operators/RoleSetter.py,sha256=mHZIdcHC3wflj81ekLbioDG1f8yHZXYDQFymV-KnyXA,2274
42
- vtlengine/Operators/Set.py,sha256=f1uLeY4XZF0cWEwpXRB_CczgbXr6s33DYPuFt39HlEg,7084
43
- vtlengine/Operators/String.py,sha256=ghWtYl6oUEAAzynY1a9Hg4yqRA9Sa7uk2B6iF9uuSqQ,20230
44
- vtlengine/Operators/Time.py,sha256=9f2kQ6iAoA4YPvlfphJ_uQjM-ZuqjSnOs312ttWMhgg,42679
45
- vtlengine/Operators/Validation.py,sha256=ev3HyU7e1XbeAtUQ1y6zY3fzBwMqetDPhG3NNveAGOE,9988
46
- vtlengine/Operators/__init__.py,sha256=GN5eaAwmzfYKD7JJRIaRqdIJzflGc3UMvrOC9mlYNVo,37227
47
- vtlengine/Utils/__init__.py,sha256=ZobqGLc4rpMrsmniexTD4J-VokQt3qLrBGdFEDHHT1M,7571
48
- vtlengine/__extras_check.py,sha256=Wr-lxGZhXJZEacVV5cUkvKt7XM-mry0kYAe3VxNrVcY,614
49
- vtlengine/__init__.py,sha256=L9tGzRGQ8HMDS23sVWIbBvj41sXR89pf0ZMzEidIEMM,89
50
- vtlengine/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
- vtlengine/files/output/__init__.py,sha256=4tmf-p1Y1u5Ohrwt3clQA-FMGaijKI3HC_iwn3H9J8c,1250
52
- vtlengine/files/output/_time_period_representation.py,sha256=D5XCSXyEuX_aBzTvBV3sZxACcgwXz2Uu_YH3loMP8q0,1610
53
- vtlengine/files/parser/__init__.py,sha256=Kt1hFk6El0B2Fpi3sSC34x4r9BfG6V2pwDv67D0Z3xg,9057
54
- vtlengine/files/parser/_rfc_dialect.py,sha256=0T8GshGA5z9ZgYStH7zz2ZwtdiGkj7B8jXcxsPkXfjs,488
55
- vtlengine/files/parser/_time_checking.py,sha256=UAC_Pv-eQJKrhgTguWb--xfqMMs6quyMeiAkGBt_vgI,4725
56
- vtlengine-1.1rc2.dist-info/LICENSE.md,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
57
- vtlengine-1.1rc2.dist-info/METADATA,sha256=35O54pqjheRYnOnis2olSRUu4DEcfLrX1gM3wjou7tw,8728
58
- vtlengine-1.1rc2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
59
- vtlengine-1.1rc2.dist-info/RECORD,,