Browse Source

oss proto gen

qrort 2 years ago
parent
commit
9d0be9d269

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# Generated protos
+*_pb2.py
+*_pb2_grpc.py
+*_pb2.pyi

+ 2 - 1
ydb/tests/functional/ydb_cli/test_ydb_backup.py

@@ -2,7 +2,8 @@
 
 from ydb.tests.library.common import yatest_common
 from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
-import ydb
+from ydb.tests.ydb_sdk_import import ydb
+
 from hamcrest import assert_that, is_, is_not, contains_inanyorder, has_item, has_items
 import os
 import logging

+ 3 - 4
ydb/tests/functional/ydb_cli/test_ydb_impex.py

@@ -2,9 +2,9 @@
 from ydb.tests.library.common import yatest_common
 from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
 from ydb.tests.oss_canonical import set_canondata_root
+from ydb.tests.ydb_sdk_import import ydb
 
 import pytest
-import ydb
 import logging
 import pyarrow as pa
 import pyarrow.parquet as pq
@@ -123,8 +123,7 @@ class TestImpex(BaseTestTableService):
         self.clear_table()
         with open("tempinput.parquet", "w"):
             pq.write_table(data, "tempinput.parquet", version="2.4")
-        output = self.execute_ydb_cli_command(["import", "file", "parquet", "-p", self.table_path, "-i", "tempinput.parquet"])
-        return self.canonical_result(output)
+        self.execute_ydb_cli_command(["import", "file", "parquet", "-p", self.table_path, "-i", "tempinput.parquet"])
 
     def run_export(self, format):
         query = "SELECT `key`, `id`, `value` FROM `{}` ORDER BY `key`".format(self.table_path)
@@ -143,7 +142,7 @@ class TestImpex(BaseTestTableService):
         self.run_import_json(DATA_JSON)
         return self.run_export("json-unicode")
 
-    @pytest.skip("test is failing right now")
+    @pytest.mark.skip("test is failing right now")
     def test_format_parquet(self):
         self.run_import_parquet(DATA_PARQUET)
         return self.run_export("csv")

+ 1 - 1
ydb/tests/functional/ydb_cli/test_ydb_scripting.py

@@ -3,8 +3,8 @@
 from ydb.tests.library.common import yatest_common
 from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
 from ydb.tests.oss_canonical import set_canondata_root
+from ydb.tests.ydb_sdk_import import ydb
 
-import ydb
 import os
 import logging
 

+ 1 - 1
ydb/tests/functional/ydb_cli/test_ydb_table.py

@@ -3,8 +3,8 @@
 from ydb.tests.library.common import yatest_common
 from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
 from ydb.tests.oss_canonical import set_canondata_root
+from ydb.tests.ydb_sdk_import import ydb
 
-import ydb
 import os
 import logging
 

+ 2 - 3
ydb/tests/library/harness/kikimr_cluster_interface.py

@@ -11,8 +11,7 @@ from ydb.tests.library.common.protobuf_console import (
     RemoveTenantRequest, GetOperationRequest)
 import ydb.public.api.protos.ydb_cms_pb2 as cms_tenants_pb
 from ydb.public.api.protos.ydb_status_codes_pb2 import StatusIds
-from ydb import issues
-
+from ydb.tests.ydb_sdk_import import ydb
 
 logger = logging.getLogger(__name__)
 logger.setLevel(logging.DEBUG)
@@ -171,7 +170,7 @@ class KiKiMRClusterInterface(object):
         if not operation.ready:
             operation = self.__wait_console_op(operation.id, timeout_seconds=timeout_seconds)
         if operation.status != StatusIds.SUCCESS:
-            raise RuntimeError('create_database failed: %s, %s' % (operation.status, issues._format_issues(operation.issues)))
+            raise RuntimeError('create_database failed: %s, %s' % (operation.status, ydb.issues._format_issues(operation.issues)))
 
         self.__wait_tenant_up(
             database_name,

+ 9 - 0
ydb/tests/ydb_sdk_import/README.md

@@ -0,0 +1,9 @@
+# Why this file was created
+
+[YDB Python tests](https://github.com/ydb-platform/ydb/tree/main/ydb/tests) import and use symbols from [YDB Python SDK](https://github.com/ydb-platform/ydb-python-sdk) in their source code. YDB Python SDK is availible as pip package, but its sources are also [shipped with YDB](https://github.com/ydb-platform/ydb/tree/main/ydb/public/sdk/python/ydb), so, when the tests are run, the developer is sure that he or she is using the most recent version of SDK.
+
+When tests are run in YDB developers private infrastructure, some tweaks are applied, and SDK sources are put at top-level, so its symbols should be imported via `import ydb`.
+
+However, when sources are published in GitHub, they are not moved prior to tests launch and reside in *ydb/public/sdk/python/ydb*, so symbols should be imported via `from ydb.public.sdk.python import ydb`.
+
+We choose the type of the import based on environment variable value.

+ 6 - 0
ydb/tests/ydb_sdk_import/__init__.py

@@ -0,0 +1,6 @@
+from ydb.tests.oss_canonical import is_oss
+
+if is_oss:
+    from ydb.public.sdk.python import ydb # noqa
+else:
+    import ydb # noqa