Skip to content
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

Development version to upgrade underlying libraries and python version #399

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests_01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.10]
python: [3.11]
env:
BIGML_USERNAME: ${{ secrets.BIGML_USERNAME }}
BIGML_API_KEY: ${{ secrets.BIGML_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_05.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.10]
python: [3.11]
env:
BIGML_USERNAME: ${{ secrets.BIGML_USERNAME }}
BIGML_API_KEY: ${{ secrets.BIGML_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.10]
python: [3.11]
env:
BIGML_USERNAME: ${{ secrets.BIGML_USERNAME }}
BIGML_API_KEY: ${{ secrets.BIGML_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_23.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.10]
python: [3.11]
env:
BIGML_USERNAME: ${{ secrets.BIGML_USERNAME }}
BIGML_API_KEY: ${{ secrets.BIGML_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.10]
python: [3.11]
env:
BIGML_USERNAME: ${{ secrets.BIGML_USERNAME }}
BIGML_API_KEY: ${{ secrets.BIGML_API_KEY }}
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
History
-------

9.8.0.dev (2024-02-19)
----------------------

- Upgrading libraries to avoid failures in Apple M1 machines.
- Fixing local predictions input data preprocessing for missings.

9.7.1 (2023-12-08)
------------------

Expand Down
5 changes: 3 additions & 2 deletions bigml/api_handlers/resourcehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ def delete_resource(self, resource, **kwargs):
return self._delete("%s%s" % (self.url, resource_id), **kwargs)
return None

def _download_resource(self, resource, filename, retries=10):
def _download_resource(self, resource, filename, retries=10,
download_suffix=None):
"""Download CSV information from downloadable resources

"""
Expand All @@ -656,7 +657,7 @@ def _download_resource(self, resource, filename, retries=10):
"resources can be downloaded. Please, check "
"the resource status. %s" % (resource_id, error))
return self._download("%s%s%s" % (self.url, resource_id,
DOWNLOAD_DIR),
download_suffix or DOWNLOAD_DIR),
filename=filename,
retries=retries)

Expand Down
24 changes: 23 additions & 1 deletion bigml/api_handlers/sourcehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
from bigml.bigmlconnection import json_load
from bigml.api_handlers.resourcehandler import check_resource_type, \
resource_is_ready, get_source_id, get_id
from bigml.constants import SOURCE_PATH, IMAGE_EXTENSIONS
from bigml.constants import SOURCE_PATH, IMAGE_EXTENSIONS, \
IMAGE_DOWNLOAD_SUFFIX
from bigml.api_handlers.resourcehandler import ResourceHandlerMixin, LOGGER
from bigml.fields import Fields

Expand Down Expand Up @@ -562,6 +563,27 @@ def update_composite_annotations(self, source, images_file,

return source

def download_composite_images(self, source, output_dir=None, retries=10):
"""Downloads the images inside a composite

"""
check_resource_type(source, SOURCE_PATH,
message="A source id is needed.")
resource_id, error = self.final_resource(source, retries=retries)
if error or resource_id is None:
raise Exception("Failed to download %s. Only correctly finished "
"resources can be downloaded. Please, check "
"the resource status. %s" % (resource_id, error))
composite = self.retrieve_resource(resource_id)
sources = composite.get("object", {}).get("sources")

if sources:
for source in sources:
self._download_resource(os.path.join(SOURCE_PATH, source),
os.path.join(output_dir, source),
retries=retries,
download_suffix=IMAGE_DOWNLOAD_SUFFIX)

def get_source(self, source, query_string=''):
"""Retrieves a remote source.
The source parameter should be a string containing the
Expand Down
1 change: 1 addition & 0 deletions bigml/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,4 @@
IOU_REMOTE_SETTINGS = {"iou_threshold": 0.2}
TEMP_DIR = "/tmp"
TOP_IMAGE_SIZE = 512
IMAGE_DOWNLOAD_SUFFIX = "/image/raw"
3 changes: 2 additions & 1 deletion bigml/modelfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def normalize(self, value):
"""
if isinstance(value, str) and not isinstance(value, str):
value = str(value, "utf-8")
return None if value in self.missing_tokens else value
return None if hasattr(self, "missing_tokens") and \
value in self.missing_tokens else value

def fill_numeric_defaults(self, input_data):
"""Fills the value set as default for numeric missing fields if user
Expand Down
2 changes: 1 addition & 1 deletion bigml/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '9.7.1'
__version__ = '9.8.0.dev'
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
version = re.search("__version__ = '([^']+)'",
open(version_py_path).read()).group(1)

TOPIC_MODELING_DEPENDENCIES = ["cython", "pystemmer==2.0.1"]
IMAGES_DEPENDENCIES = ["bigml-sensenet==0.7.0"]
TOPIC_MODELING_DEPENDENCIES = ["cython", "pystemmer==2.2.0.1"]
IMAGES_DEPENDENCIES = ["bigml-sensenet==0.7.2"]

# Concatenate files into the long description
file_contents = []
Expand All @@ -51,7 +51,7 @@
license="http://www.apache.org/licenses/LICENSE-2.0",
setup_requires = ['pytest'],
install_requires = ["unidecode", "bigml-chronos>=0.4.3", "requests",
"requests-toolbelt", "msgpack", "numpy>=1.22,<1.24", "scipy",
"requests-toolbelt", "msgpack", "numpy>=1.22", "scipy",
"javascript"],
extras_require={"images": IMAGES_DEPENDENCIES,
"topics": TOPIC_MODELING_DEPENDENCIES,
Expand Down
Loading