-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bulk import #386
Add bulk import #386
Changes from all commits
87aec08
62c95e0
764822e
10cfc28
97b0027
2a87b8a
fe7f93f
82d7905
bc09023
8118ed3
686538d
3ec5838
6a1c7a1
b0bc0f3
e9158ae
70ac40d
9857a96
b8494c0
7649b00
1a7f4b0
984c8b0
cfbd722
f3b2bab
b19cce2
5711249
6d5ab6e
5b900c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,4 @@ jobs: | |
secrets: | ||
PYPI_USERNAME: __token__ | ||
PYPI_PASSWORD: ${{ secrets.PROD_PYPI_PUBLISH_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ develop: | |
|
||
test-unit: | ||
@echo "Running tests..." | ||
poetry run pytest --cov=pinecone --timeout=120 tests/unit | ||
poetry run pytest --cov=pinecone --timeout=120 tests/unit -s -vv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making sure: you want to permanently add these flags here? I just know that they're usually added for debugging, so want to make sure they weren't left accidentally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I pretty much always want these flags. |
||
|
||
test-integration: | ||
@echo "Running integration tests..." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,21 @@ | |
set -eux -o pipefail | ||
|
||
version=$1 # e.g. 2024-07 | ||
modules=("control" "data") | ||
is_early_access=$2 # e.g. true | ||
|
||
# if is_early_access is true, add the "ea" module | ||
if [ "$is_early_access" = "true" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: Clever way of going about this, nice. 👍 |
||
destination="pinecone/core_ea/openapi" | ||
modules=("db_control" "db_data") | ||
py_module_name="core_ea" | ||
template_dir="codegen/python-oas-templates/templates5.2.0" | ||
else | ||
destination="pinecone/core/openapi" | ||
modules=("control" "data") | ||
py_module_name="core" | ||
template_dir="codegen/python-oas-templates/templates5.2.0" | ||
fi | ||
|
||
destination="pinecone/core/openapi" | ||
build_dir="build" | ||
|
||
update_apis_repo() { | ||
|
@@ -58,11 +70,9 @@ generate_client() { | |
local module_name=$1 | ||
|
||
oas_file="codegen/apis/_build/${version}/${module_name}_${version}.oas.yaml" | ||
openapi_generator_config="codegen/openapi-config.${module_name}.json" | ||
template_dir="codegen/python-oas-templates/templates5.2.0" | ||
package_name="pinecone.${py_module_name}.openapi.${module_name}" | ||
|
||
verify_file_exists $oas_file | ||
verify_file_exists $openapi_generator_config | ||
verify_directory_exists $template_dir | ||
|
||
# Cleanup previous build files | ||
|
@@ -73,13 +83,20 @@ generate_client() { | |
docker run --rm -v $(pwd):/workspace openapitools/openapi-generator-cli:v5.2.0 generate \ | ||
--input-spec "/workspace/$oas_file" \ | ||
--generator-name python \ | ||
--config "/workspace/$openapi_generator_config" \ | ||
--additional-properties=packageName=$package_name,pythonAttrNoneIfUnset=true \ | ||
--output "/workspace/${build_dir}" \ | ||
--template-dir "/workspace/$template_dir" | ||
|
||
# Hack to prevent coercion of strings into datetimes within "object" types while still | ||
# allowing datetime parsing for fields that are explicitly typed as datetime | ||
Comment on lines
+90
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, does this replace the templating we used to have to do to fix the previous There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, exactly. I rolled back the old changes to the templates and replaced with this. It's only this one spot where the datetime stuff was problematic. |
||
find "${build_dir}" -name "*.py" | while IFS= read -r file; do | ||
sed -i '' "s/bool, date, datetime, dict, float, int, list, str, none_type/bool, dict, float, int, list, str, none_type/g" "$file" | ||
done | ||
|
||
# Copy the generated module to the correct location | ||
rm -rf "${destination}/${module_name}" | ||
cp -r "build/pinecone/core/openapi/${module_name}" "${destination}/${module_name}" | ||
mkdir -p "${destination}" | ||
cp -r "build/pinecone/$py_module_name/openapi/${module_name}" "${destination}/${module_name}" | ||
} | ||
|
||
extract_shared_classes() { | ||
|
@@ -118,13 +135,13 @@ extract_shared_classes() { | |
|
||
# Adjust import paths in every file | ||
find "${destination}" -name "*.py" | while IFS= read -r file; do | ||
sed -i '' 's/from \.\.model_utils/from pinecone\.core\.openapi\.shared\.model_utils/g' "$file" | ||
sed -i '' "s/from \.\.model_utils/from pinecone\.$py_module_name\.openapi\.shared\.model_utils/g" "$file" | ||
|
||
for module in "${modules[@]}"; do | ||
sed -i '' "s/from pinecone\.core\.openapi\.$module import rest/from pinecone\.core\.openapi\.shared import rest/g" "$file" | ||
sed -i '' "s/from pinecone\.$py_module_name\.openapi\.$module import rest/from pinecone\.$py_module_name\.openapi\.shared import rest/g" "$file" | ||
|
||
for sharedFile in "${sharedFiles[@]}"; do | ||
sed -i '' "s/from pinecone\.core\.openapi\.$module\.$sharedFile/from pinecone\.core\.openapi\.shared\.$sharedFile/g" "$file" | ||
sed -i '' "s/from pinecone\.$py_module_name\.openapi\.$module\.$sharedFile/from pinecone\.$py_module_name\.openapi\.shared\.$sharedFile/g" "$file" | ||
done | ||
done | ||
done | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ def build(cls, api_key: str, host: Optional[str] = None, **kwargs): | |
openapi_config.host = host | ||
openapi_config.ssl_ca_cert = certifi.where() | ||
openapi_config.socket_options = cls._get_socket_options() | ||
openapi_config.discard_unknown_keys = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discovered this along the way. Seems like a better default behavior than erroring when unexpected data is returned. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks sweet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch |
||
|
||
return openapi_config | ||
|
||
@classmethod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,8 +72,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,8 +72,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,8 +89,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,8 +66,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,8 +72,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,8 +72,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,8 +91,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,6 @@ def additional_properties_type(): | |
lazy_import() | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,8 +71,6 @@ def additional_properties_type(): | |
""" | ||
return ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: We should definitely put something like this in other repos where we're using a
/codegen/
submodule in other repos, we had someone external asking about codegen in the Rust codebase. Would be good to be explicit until we've got the specs published, plus for better documenting how the codegen actually works in each repo.