diff --git a/.github/workflows/tests_01.yml b/.github/workflows/tests_01.yml index c2471c71..a6709e17 100644 --- a/.github/workflows/tests_01.yml +++ b/.github/workflows/tests_01.yml @@ -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 }} diff --git a/.github/workflows/tests_05.yml b/.github/workflows/tests_05.yml index 0c943129..dc01250a 100644 --- a/.github/workflows/tests_05.yml +++ b/.github/workflows/tests_05.yml @@ -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 }} diff --git a/.github/workflows/tests_22.yml b/.github/workflows/tests_22.yml index a80d8668..7d2d8c87 100644 --- a/.github/workflows/tests_22.yml +++ b/.github/workflows/tests_22.yml @@ -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 }} diff --git a/.github/workflows/tests_23.yml b/.github/workflows/tests_23.yml index 2edc1e6b..859be798 100644 --- a/.github/workflows/tests_23.yml +++ b/.github/workflows/tests_23.yml @@ -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 }} diff --git a/.github/workflows/tests_36.yml b/.github/workflows/tests_36.yml index e6cfe5cd..934cfc83 100644 --- a/.github/workflows/tests_36.yml +++ b/.github/workflows/tests_36.yml @@ -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 }} diff --git a/HISTORY.rst b/HISTORY.rst index e5831890..1a63a61c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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) ------------------ diff --git a/bigml/api_handlers/resourcehandler.py b/bigml/api_handlers/resourcehandler.py index caef0e99..174a03ad 100644 --- a/bigml/api_handlers/resourcehandler.py +++ b/bigml/api_handlers/resourcehandler.py @@ -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 """ @@ -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) diff --git a/bigml/api_handlers/sourcehandler.py b/bigml/api_handlers/sourcehandler.py index ac897413..c8476449 100644 --- a/bigml/api_handlers/sourcehandler.py +++ b/bigml/api_handlers/sourcehandler.py @@ -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 @@ -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 diff --git a/bigml/constants.py b/bigml/constants.py index 6423faff..df0ef6f4 100644 --- a/bigml/constants.py +++ b/bigml/constants.py @@ -358,3 +358,4 @@ IOU_REMOTE_SETTINGS = {"iou_threshold": 0.2} TEMP_DIR = "/tmp" TOP_IMAGE_SIZE = 512 +IMAGE_DOWNLOAD_SUFFIX = "/image/raw" diff --git a/bigml/modelfields.py b/bigml/modelfields.py index 946e6078..2eb9b38a 100644 --- a/bigml/modelfields.py +++ b/bigml/modelfields.py @@ -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 diff --git a/bigml/version.py b/bigml/version.py index 0c8f0e8f..4e9967f4 100644 --- a/bigml/version.py +++ b/bigml/version.py @@ -1 +1 @@ -__version__ = '9.7.1' +__version__ = '9.8.0.dev' diff --git a/setup.py b/setup.py index 1414577f..824fdea2 100644 --- a/setup.py +++ b/setup.py @@ -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 = [] @@ -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,