├── tests ├── __init__.py ├── e2e │ ├── __init__.py │ ├── standard │ │ ├── __init__.py │ │ └── test_multiprocessing.py │ ├── integrations │ │ └── __init__.py │ ├── pytest.ini │ └── exceptions.py └── unit │ ├── neptune │ ├── __init__.py │ ├── new │ │ ├── __init__.py │ │ ├── utils │ │ │ ├── logging.py │ │ │ ├── __init__.py │ │ │ └── file_helpers.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ └── test_requests_utils.py │ │ ├── cli │ │ │ └── __init__.py │ │ ├── client │ │ │ ├── __init__.py │ │ │ ├── test_model_tables.py │ │ │ └── test_model_version_tables.py │ │ ├── core │ │ │ ├── __init__.py │ │ │ ├── components │ │ │ │ ├── __init__.py │ │ │ │ └── queue │ │ │ │ │ └── __init__.py │ │ │ ├── operations │ │ │ │ └── __init__.py │ │ │ └── operation_processors │ │ │ │ ├── __init__.py │ │ │ │ └── async_operation_processor │ │ │ │ └── __init__.py │ │ ├── attributes │ │ │ ├── __init__.py │ │ │ ├── atoms │ │ │ │ ├── __init__.py │ │ │ │ └── test_string.py │ │ │ ├── sets │ │ │ │ └── __init__.py │ │ │ ├── series │ │ │ │ └── __init__.py │ │ │ ├── test_attribute_utils.py │ │ │ └── test_attribute_base.py │ │ ├── internal │ │ │ ├── __init__.py │ │ │ ├── utils │ │ │ │ ├── __init__.py │ │ │ │ ├── test_hashing.py │ │ │ │ ├── test_utils.py │ │ │ │ ├── test_iso_dates.py │ │ │ │ └── test_iteration.py │ │ │ ├── backends │ │ │ │ ├── __init__.py │ │ │ │ └── test_swagger_client_wrapper.py │ │ │ ├── operation_processors │ │ │ │ └── __init__.py │ │ │ └── signals_processing │ │ │ │ └── __init__.py │ │ └── websockets │ │ │ └── __init__.py │ └── backend_test_mixin.py │ └── __init__.py ├── .github ├── pull_request_template.md ├── dependabot.yml ├── CODEOWNERS ├── workflows │ ├── pre-commit.yml │ ├── slash-commands.yml │ ├── dev1.x-e2e.yml │ ├── dev1.x-unit.yml │ ├── dev1.x-integrations.yml │ ├── unit-in-pull-request.yml │ ├── help-command.yml │ ├── run-e2e-command.yml │ ├── run-unit-command.yml │ ├── run-integrations-command.yml │ ├── pre-commit-apply-command.yml │ ├── run-all-test-command.yml │ └── unit.yml ├── SECURITY.md ├── license_header.txt ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── actions │ ├── workflow-notify │ └── action.yml │ ├── job-notify │ └── action.yml │ ├── install-package │ └── action.yml │ └── test-unit │ └── action.yml ├── dev_requirements.txt ├── CITATION.cff ├── src └── neptune │ ├── api │ ├── __init__.py │ ├── proto │ │ ├── __init__.py │ │ └── neptune_pb │ │ │ ├── __init__.py │ │ │ └── api │ │ │ ├── __init__.py │ │ │ └── model │ │ │ ├── __init__.py │ │ │ ├── attributes_pb2.py │ │ │ ├── series_values_pb2.py │ │ │ └── attributes_pb2.pyi │ ├── requests_utils.py │ └── pagination.py │ ├── core │ ├── __init__.py │ ├── typing │ │ ├── __init__.py │ │ ├── id_formats.py │ │ └── container_type.py │ ├── components │ │ ├── __init__.py │ │ ├── queue │ │ │ ├── __init__.py │ │ │ └── sync_offset_file.py │ │ └── operation_storage.py │ ├── operation_processors │ │ ├── __init__.py │ │ ├── async_operation_processor │ │ │ ├── __init__.py │ │ │ └── constants.py │ │ ├── read_only_operation_processor.py │ │ └── operation_processor.py │ └── operations │ │ ├── __init__.py │ │ ├── utils.py │ │ └── operation_visitor.py │ ├── integrations │ ├── __init__.py │ ├── aws │ │ └── __init__.py │ ├── fastai │ │ └── __init__.py │ ├── kedro │ │ └── __init__.py │ ├── optuna │ │ └── __init__.py │ ├── sacred │ │ └── __init__.py │ ├── prophet │ │ └── __init__.py │ ├── pytorch │ │ └── __init__.py │ ├── sklearn │ │ └── __init__.py │ ├── xgboost │ │ └── __init__.py │ ├── lightgbm │ │ └── __init__.py │ ├── detectron2 │ │ └── __init__.py │ ├── tensorboard │ │ └── __init__.py │ ├── mosaicml │ │ └── __init__.py │ ├── tensorflow_keras │ │ └── __init__.py │ ├── transformers │ │ └── __init__.py │ ├── pytorch_lightning │ │ └── __init__.py │ └── utils.py │ ├── internal │ ├── __init__.py │ ├── backends │ │ ├── __init__.py │ │ ├── project_name_lookup.py │ │ ├── factory.py │ │ └── hosted_neptune_backend_v2.py │ ├── streams │ │ └── __init__.py │ ├── types │ │ ├── __init__.py │ │ └── utils.py │ ├── websockets │ │ ├── __init__.py │ │ └── websockets_factory.py │ ├── signals_processing │ │ ├── __init__.py │ │ ├── signals.py │ │ └── utils.py │ ├── operation_processors │ │ ├── __init__.py │ │ └── utils.py │ ├── utils │ │ ├── storage_utils.py │ │ ├── patterns.py │ │ ├── limits.py │ │ ├── hashing.py │ │ ├── paths.py │ │ ├── iso_dates.py │ │ ├── runningmode.py │ │ ├── requirement_check.py │ │ ├── iteration.py │ │ ├── run_state.py │ │ ├── utils.py │ │ └── process_killer.py │ ├── state.py │ ├── constants.py │ ├── envs.py │ ├── patches │ │ └── __init__.py │ ├── id_formats.py │ ├── parameters.py │ ├── background_job.py │ ├── container_type.py │ ├── backgroud_job_list.py │ └── extensions.py │ ├── types │ ├── sets │ │ ├── __init__.py │ │ ├── set.py │ │ └── string_set.py │ ├── series │ │ ├── __init__.py │ │ ├── series.py │ │ └── series_value.py │ ├── model_version_stage.py │ ├── atoms │ │ ├── __init__.py │ │ ├── atom.py │ │ ├── float.py │ │ ├── boolean.py │ │ ├── integer.py │ │ ├── datetime.py │ │ └── string.py │ ├── value.py │ ├── __init__.py │ ├── value_copy.py │ └── namespace.py │ ├── attributes │ ├── sets │ │ ├── __init__.py │ │ └── set.py │ ├── atoms │ │ ├── atom.py │ │ ├── run_state.py │ │ ├── notebook_ref.py │ │ ├── __init__.py │ │ └── boolean.py │ ├── series │ │ └── __init__.py │ ├── __init__.py │ └── utils.py │ ├── cli │ ├── __init__.py │ ├── __main__.py │ └── path_option.py │ ├── objects │ ├── mode.py │ ├── __init__.py │ └── structure_version.py │ ├── constants.py │ └── version.py ├── README.md ├── .pre-commit-config.yaml └── codecov.yml /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/e2e/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/e2e/standard/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/neptune/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/e2e/integrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Before submitting checklist 2 | 3 | - [ ] Did you **update the CHANGELOG**? (not for test updates, internal changes/refactors or CI/CD setup) 4 | - [ ] Did you **ask the docs owner** to review all the user-facing changes? 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: pip 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/utils/logging.py: -------------------------------------------------------------------------------- 1 | from neptune.internal.utils.logger import NEPTUNE_LOGGER_NAME 2 | 3 | 4 | def format_log(loglevel: str, msg: str) -> str: 5 | loglevel = loglevel.lower().ljust(len("warning")) 6 | return f"[{NEPTUNE_LOGGER_NAME}] [{loglevel}] {msg}" 7 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in 2 | # the repo. Unless a later match takes precedence, 3 | # @PatrykGala and @kgodlewski will be requested for 4 | # review when someone opens a pull request. 5 | /* @PatrykGala @kgodlewski 6 | 7 | # File/directory specific owners 8 | /README.md @normandy7 @PatrykGala @kgodlewski 9 | -------------------------------------------------------------------------------- /tests/e2e/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | integrations: a test is testing an integration 4 | lightning: a test is testing pytorch-lightning integration (can also run with Lightning EcoSystem) 5 | huggingface: a test is testing an HuggingFace Transformers integration 6 | zenml: a test is running zenml tests 7 | mosaicml: a test is running mosaicml tests 8 | -------------------------------------------------------------------------------- /dev_requirements.txt: -------------------------------------------------------------------------------- 1 | -e . 2 | 3 | # dev 4 | Faker 5 | freezegun 6 | mock 7 | munch 8 | mypy 9 | pre-commit 10 | pytest 11 | pytest-cov 12 | pytest-mock 13 | pytest-timeout 14 | pytest-xdist 15 | vega_datasets 16 | backoff 17 | altair 18 | icecream 19 | bokeh 20 | matplotlib 21 | seaborn 22 | plotly 23 | torch 24 | typing_extensions>=4.6.0 25 | grpcio-tools 26 | 27 | # e2e 28 | scikit-learn 29 | torchvision 30 | accelerate 31 | backoff 32 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software in your AI research, please cite it as below." 3 | title: "neptune.ai" 4 | abstract: "Metadata store for MLOps" 5 | authors: 6 | - name: "Neptune team" 7 | license: "Apache-2.0" 8 | date-released: 2019-02-11 9 | url: "https://neptune.ai/" 10 | keywords: 11 | - mlops 12 | - metadata store 13 | - machine learning 14 | - deep learning 15 | - artificial intelligence 16 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: pre-commit 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | pre-commit: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v4 15 | 16 | - name: Install Python 17 | uses: actions/setup-python@v5 18 | with: 19 | python-version: "3.12" 20 | 21 | - name: Run pre-commit 22 | uses: pre-commit/action@v3.0.1 23 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security policy 2 | 3 | ## Privacy and security 4 | 5 | When using Neptune in your project, there are several things you can do to control what data is logged and who can access it. 6 | 7 | You can find some considerations and tips in our [documentation](https://docs-legacy.neptune.ai/about/privacy_and_sensitive_data/). 8 | 9 | ## SOC 10 | 11 | Neptune is SOC 2 compliant. You can learn more in the [security portal](https://security.neptune.ai/). 12 | 13 | ## Reporting a vulnerability 14 | 15 | Please report all vulnerabilities to security@neptune.ai. 16 | -------------------------------------------------------------------------------- /.github/license_header.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/api/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/core/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /.github/workflows/slash-commands.yml: -------------------------------------------------------------------------------- 1 | name: Slash Command Dispatch 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | slash-dispatch: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Slash Command Dispatch 12 | uses: peter-evans/slash-command-dispatch@v4 13 | with: 14 | commands: | 15 | pre-commit-apply 16 | help 17 | run-e2e 18 | run-unit 19 | run-integrations 20 | run-all-test 21 | reaction-token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 22 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 23 | permission: write 24 | -------------------------------------------------------------------------------- /src/neptune/api/proto/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/core/typing/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/integrations/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/core/components/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/backends/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/streams/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/types/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/api/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/cli/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/client/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/core/components/queue/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/websockets/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/websockets/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/api/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/core/operation_processors/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/signals_processing/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/atoms/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/sets/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/components/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/api/model/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /src/neptune/internal/operation_processors/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/series/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/components/queue/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/backends/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/operation_processors/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: 'Feature Request: ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Is your feature request related to a problem? Please describe. 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | ### Describe the solution you'd like 13 | A clear and concise description of what you want to happen. 14 | ### Describe alternatives you've considered 15 | A clear and concise description of any alternative solutions or features you've considered. 16 | ### Additional context 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/operation_processors/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/signals_processing/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /.github/workflows/dev1.x-e2e.yml: -------------------------------------------------------------------------------- 1 | name: dev1.x-e2e 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 6 * * *" # Run every day at arbitrary time (4:00 AM UTC) 7 | 8 | env: 9 | WORKSPACE_NAME: e2e-tests 10 | BUCKET_NAME: ${{ secrets.E2E_BUCKET_NAME }} 11 | USER_USERNAME: ${{ secrets.E2E_USER_USERNAME }} 12 | ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} 13 | ADMIN_NEPTUNE_API_TOKEN: ${{ secrets.E2E_ADMIN_NEPTUNE_API_TOKEN }} 14 | SERVICE_ACCOUNT_NAME: ${{ secrets.E2E_SERVICE_ACCOUNT_NAME }} 15 | 16 | jobs: 17 | dev1_x_e2e: 18 | uses: neptune-ai/neptune-client/.github/workflows/e2e.yml@dev/1.x 19 | secrets: inherit 20 | with: 21 | neptune_ref: refs/heads/dev/1.x 22 | -------------------------------------------------------------------------------- /.github/workflows/dev1.x-unit.yml: -------------------------------------------------------------------------------- 1 | name: dev1.x-unit 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 6 * * *" # Run every day at arbitrary time (4:00 AM UTC) 7 | 8 | env: 9 | WORKSPACE_NAME: e2e-tests 10 | BUCKET_NAME: ${{ secrets.E2E_BUCKET_NAME }} 11 | USER_USERNAME: ${{ secrets.E2E_USER_USERNAME }} 12 | ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} 13 | ADMIN_NEPTUNE_API_TOKEN: ${{ secrets.E2E_ADMIN_NEPTUNE_API_TOKEN }} 14 | SERVICE_ACCOUNT_NAME: ${{ secrets.E2E_SERVICE_ACCOUNT_NAME }} 15 | 16 | jobs: 17 | unit_dev1_x: 18 | uses: neptune-ai/neptune-client/.github/workflows/unit.yml@dev/1.x 19 | secrets: inherit 20 | with: 21 | neptune_ref: refs/heads/dev/1.x 22 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/core/operation_processors/async_operation_processor/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | -------------------------------------------------------------------------------- /.github/workflows/dev1.x-integrations.yml: -------------------------------------------------------------------------------- 1 | name: dev1.x-integrations 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 6 * * *" # Run every day at arbitrary time (4:00 AM UTC) 7 | 8 | env: 9 | WORKSPACE_NAME: e2e-tests 10 | BUCKET_NAME: ${{ secrets.E2E_BUCKET_NAME }} 11 | USER_USERNAME: ${{ secrets.E2E_USER_USERNAME }} 12 | ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} 13 | ADMIN_NEPTUNE_API_TOKEN: ${{ secrets.E2E_ADMIN_NEPTUNE_API_TOKEN }} 14 | SERVICE_ACCOUNT_NAME: ${{ secrets.E2E_SERVICE_ACCOUNT_NAME }} 15 | 16 | jobs: 17 | integrations_dev1_x: 18 | uses: neptune-ai/neptune-client/.github/workflows/integrations.yml@dev/1.x 19 | secrets: inherit 20 | with: 21 | neptune_ref: refs/heads/dev/1.x 22 | -------------------------------------------------------------------------------- /src/neptune/types/sets/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["StringSet"] 17 | 18 | from .string_set import StringSet 19 | -------------------------------------------------------------------------------- /src/neptune/attributes/sets/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "StringSet", 18 | ] 19 | 20 | from .string_set import StringSet 21 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/storage_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import os 17 | 18 | 19 | def normalize_file_name(name): 20 | return name.replace(os.sep, "/") 21 | -------------------------------------------------------------------------------- /src/neptune/cli/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["sync", "status"] 18 | 19 | from neptune.cli.commands import ( 20 | status, 21 | sync, 22 | ) 23 | -------------------------------------------------------------------------------- /src/neptune/attributes/atoms/atom.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Atom"] 17 | 18 | from neptune.attributes.attribute import Attribute 19 | 20 | 21 | class Atom(Attribute): 22 | pass 23 | -------------------------------------------------------------------------------- /src/neptune/attributes/sets/set.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Set"] 17 | 18 | from neptune.attributes.attribute import Attribute 19 | 20 | 21 | class Set(Attribute): 22 | pass 23 | -------------------------------------------------------------------------------- /src/neptune/attributes/atoms/run_state.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["RunState"] 17 | 18 | from neptune.attributes.atoms.atom import Atom 19 | 20 | 21 | class RunState(Atom): 22 | pass 23 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/patterns.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | PROJECT_QUALIFIED_NAME_PATTERN = "^((?P[^/]+)/){0,1}(?P[^/]+)$" 17 | 18 | __all__ = ["PROJECT_QUALIFIED_NAME_PATTERN"] 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: 'BUG: ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Describe the bug 11 | A clear and concise description of what the bug is. 12 | ### Reproduction 13 | In as much detail as possible, please provide steps to reproduce the issue or code snippet. 14 | ### Expected behavior 15 | A clear and concise description of what you expected to happen. 16 | ### Traceback 17 | If applicable, add traceback or log output/screenshots to help explain your problem. 18 | ### Environment 19 | **The output of `pip list`:** 20 | ``` 21 | 22 | ``` 23 | **The operating system you're using:** 24 | **The output of `python --version`:** 25 | ### Additional context 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /src/neptune/attributes/atoms/notebook_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["NotebookRef"] 17 | 18 | 19 | from neptune.attributes.atoms.atom import Atom 20 | 21 | 22 | class NotebookRef(Atom): 23 | pass 24 | -------------------------------------------------------------------------------- /src/neptune/core/operation_processors/async_operation_processor/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["AsyncOperationProcessor"] 18 | 19 | from .async_operation_processor import AsyncOperationProcessor 20 | -------------------------------------------------------------------------------- /src/neptune/attributes/series/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "FloatSeries", 18 | "StringSeries", 19 | ] 20 | 21 | from .float_series import FloatSeries 22 | from .string_series import StringSeries 23 | -------------------------------------------------------------------------------- /src/neptune/types/series/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = [ 18 | "FloatSeries", 19 | "StringSeries", 20 | ] 21 | 22 | from .float_series import FloatSeries 23 | from .string_series import StringSeries 24 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from unittest.mock import MagicMock 17 | 18 | 19 | def response_mock(): 20 | return MagicMock(text=MagicMock(spec_set=str), status_code=MagicMock(), json=MagicMock()) 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/aws/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-aws", suggestion="aws") 19 | 20 | from neptune_aws.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/fastai/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-fastai", suggestion="fastai") 19 | 20 | from neptune_fastai.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/kedro/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("kedro-neptune", suggestion="kedro") 19 | 20 | from kedro_neptune.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/optuna/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-optuna", suggestion="optuna") 19 | 20 | from neptune_optuna.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/sacred/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-sacred", suggestion="sacred") 19 | 20 | from neptune_sacred.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/prophet/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune_prophet", suggestion="prophet") 19 | 20 | from neptune_prophet.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-pytorch", suggestion="pytorch") 19 | 20 | from neptune_pytorch.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/sklearn/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-sklearn", suggestion="sklearn") 19 | 20 | from neptune_sklearn.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/xgboost/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-xgboost", suggestion="xgboost") 19 | 20 | from neptune_xgboost.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/internal/state.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ContainerState"] 17 | 18 | from enum import Enum 19 | 20 | 21 | class ContainerState(Enum): 22 | CREATED = "created" 23 | STARTED = "started" 24 | STOPPING = "stopping" 25 | STOPPED = "stopped" 26 | -------------------------------------------------------------------------------- /src/neptune/integrations/lightgbm/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-lightgbm", suggestion="lightgbm") 19 | 20 | from neptune_lightgbm.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/types/model_version_stage.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ModelVersionStage"] 17 | 18 | import enum 19 | 20 | 21 | class ModelVersionStage(enum.Enum): 22 | NONE = "none" 23 | STAGING = "staging" 24 | PRODUCTION = "production" 25 | ARCHIVED = "archived" 26 | -------------------------------------------------------------------------------- /src/neptune/integrations/detectron2/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-detectron2", suggestion="detectron2") 19 | 20 | from neptune_detectron2.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/tensorboard/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-tensorboard", suggestion="tensorboard") 19 | 20 | from neptune_tensorboard.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Boolean", "Datetime", "Float", "Integer", "String"] 17 | 18 | from .boolean import Boolean 19 | from .datetime import Datetime 20 | from .float import Float 21 | from .integer import Integer 22 | from .string import String 23 | -------------------------------------------------------------------------------- /src/neptune/integrations/mosaicml/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["NeptuneLogger"] 17 | 18 | from neptune.internal.utils.requirement_check import require_installed 19 | 20 | require_installed("mosaicml") 21 | 22 | from composer.loggers import NeptuneLogger # noqa: F401,F403,E402 23 | -------------------------------------------------------------------------------- /src/neptune/core/typing/id_formats.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["UniqueId", "QualifiedName", "CustomId"] 17 | 18 | from typing import NewType 19 | 20 | UniqueId = NewType("UniqueId", str) 21 | 22 | QualifiedName = NewType("QualifiedName", str) 23 | 24 | CustomId = NewType("CustomId", str) 25 | -------------------------------------------------------------------------------- /src/neptune/internal/types/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["is_unsupported_float"] 18 | 19 | import math 20 | 21 | 22 | def is_unsupported_float(value: float) -> bool: 23 | if isinstance(value, float): 24 | return math.isinf(value) or math.isnan(value) 25 | return False 26 | -------------------------------------------------------------------------------- /src/neptune/integrations/tensorflow_keras/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.utils.requirement_check import require_installed 17 | 18 | require_installed("neptune-tensorflow-keras", suggestion="tensorflow-keras") 19 | 20 | from neptune_tensorflow_keras.impl import * # noqa: F401,F403,E402 21 | -------------------------------------------------------------------------------- /src/neptune/integrations/transformers/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["NeptuneCallback"] 17 | 18 | from neptune.internal.utils.requirement_check import require_installed 19 | 20 | require_installed("transformers") 21 | 22 | from transformers.integrations import NeptuneCallback # noqa: F401,F403,E402 23 | -------------------------------------------------------------------------------- /.github/workflows/unit-in-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: pull-request-unittests 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches-ignore: 7 | - master 8 | 9 | jobs: 10 | test: 11 | timeout-minutes: 75 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | os: [ubuntu, windows, macos] 16 | python-version: ["3.8"] 17 | name: 'test (${{ matrix.os }} - py${{ matrix.python-version }})' 18 | runs-on: ${{ matrix.os }}-latest 19 | steps: 20 | - name: Checkout repository 21 | uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 24 | 25 | - name: Run tests 26 | uses: ./.github/actions/test-unit 27 | with: 28 | python-version: ${{ matrix.python-version }} 29 | os: ${{ matrix.os }} 30 | report_job: 'test (${{ matrix.os }} - py${{ matrix.python-version }})' 31 | codecov-token: ${{ secrets.CODECOV_TOKEN }} 32 | -------------------------------------------------------------------------------- /src/neptune/integrations/pytorch_lightning/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["NeptuneLogger"] 17 | 18 | from neptune.internal.utils.requirement_check import require_installed 19 | 20 | require_installed("pytorch-lightning") 21 | 22 | 23 | from pytorch_lightning.loggers import NeptuneLogger # noqa: F401,F403,E402 24 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/limits.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["custom_run_id_exceeds_length"] 17 | 18 | from typing import Optional 19 | 20 | CUSTOM_RUN_ID_LENGTH = 128 21 | 22 | 23 | def custom_run_id_exceeds_length(custom_run_id: Optional[str]) -> bool: 24 | return custom_run_id is not None and len(custom_run_id) > CUSTOM_RUN_ID_LENGTH 25 | -------------------------------------------------------------------------------- /src/neptune/objects/mode.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Mode"] 17 | 18 | from enum import Enum 19 | 20 | 21 | class Mode(str, Enum): 22 | OFFLINE = "offline" 23 | DEBUG = "debug" 24 | ASYNC = "async" 25 | SYNC = "sync" 26 | READ_ONLY = "read-only" 27 | 28 | def __repr__(self) -> str: 29 | return f'"{self.value}"' 30 | -------------------------------------------------------------------------------- /src/neptune/internal/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = [ 18 | "ANONYMOUS_API_TOKEN_CONTENT", 19 | ] 20 | 21 | ANONYMOUS_API_TOKEN_CONTENT = ( 22 | "eyJhcGlfYWRkcmVzcyI6Imh0dHBzOi8vYXBwLm5lcHR1bmUuYWkiLCJhcGlfdXJsIjoiaHR0cHM6Ly9hcHAubmVwdHVuZS" 23 | "5haSIsImFwaV9rZXkiOiJiNzA2YmM4Zi03NmY5LTRjMmUtOTM5ZC00YmEwMzZmOTMyZTQifQo=" 24 | ) 25 | -------------------------------------------------------------------------------- /src/neptune/integrations/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["join_paths", "verify_type", "RunType"] 17 | 18 | from typing import Union 19 | 20 | from neptune import Run 21 | from neptune.handler import Handler 22 | from neptune.internal.utils import verify_type 23 | from neptune.internal.utils.paths import join_paths 24 | 25 | RunType = Union[Run, Handler] 26 | -------------------------------------------------------------------------------- /src/neptune/internal/envs.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | 18 | API_TOKEN_ENV_NAME = "NEPTUNE_API_TOKEN" 19 | 20 | NEPTUNE_RETRIES_TIMEOUT_ENV = "NEPTUNE_RETRIES_TIMEOUT" 21 | 22 | PROJECT_ENV_NAME = "NEPTUNE_PROJECT" 23 | 24 | NOTEBOOK_ID_ENV_NAME = "NEPTUNE_NOTEBOOK_ID" 25 | 26 | NOTEBOOK_PATH_ENV_NAME = "NEPTUNE_NOTEBOOK_PATH" 27 | 28 | BACKEND = "NEPTUNE_BACKEND" 29 | -------------------------------------------------------------------------------- /.github/actions/workflow-notify/action.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Notify about workflow status 3 | description: Send Slack channel notification about workflow finish status 4 | inputs: 5 | slack-webhook: 6 | description: "A Slack Webhook to post a notification" 7 | required: true 8 | 9 | runs: 10 | using: "composite" 11 | steps: 12 | - uses: technote-space/workflow-conclusion-action@v3 13 | 14 | - name: Notify about failure 15 | uses: 8398a7/action-slack@v3 16 | if: env.WORKFLOW_CONCLUSION != 'success' 17 | env: 18 | SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }} 19 | with: 20 | status: failure 21 | fields: repo,message,author,job,eventName,took 22 | 23 | - name: Notify about success 24 | uses: 8398a7/action-slack@v3 25 | if: env.WORKFLOW_CONCLUSION == 'success' 26 | env: 27 | SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }} 28 | with: 29 | status: success 30 | fields: repo,message,author,job,eventName,took 31 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/hashing.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["generate_hash"] 17 | 18 | import hashlib 19 | from typing import Any 20 | 21 | 22 | def generate_hash(*descriptors: Any, length: int) -> str: 23 | hasher = hashlib.sha256() 24 | 25 | for descriptor in descriptors: 26 | hasher.update(str(descriptor).encode()) 27 | 28 | return hasher.hexdigest()[-length:] 29 | -------------------------------------------------------------------------------- /.github/workflows/help-command.yml: -------------------------------------------------------------------------------- 1 | name: help-command 2 | 3 | on: 4 | repository_dispatch: 5 | types: [help-command] 6 | 7 | jobs: 8 | help: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Update comment 12 | uses: peter-evans/create-or-update-comment@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 16 | body: | 17 | > Command | Description 18 | > --- | --- 19 | > /pre-commit-apply | Commit a pre-commit suggestions 20 | > /run-unit | Run unittests on full matrix *(win, mac, linux x py3.7-3.12) 21 | > /run-e2e | Run E2E tests on full matrix *(win, mac, linux x py3.7-3.12) 22 | > /run-integrations | Run Client integrations on full matrix *(win, mac, linux x py3.7-3.12) 23 | > /run-all-test | Run all tests on full matrix *(win, mac, linux x py3.7-3.12) 24 | reaction-type: hooray 25 | -------------------------------------------------------------------------------- /src/neptune/attributes/atoms/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Boolean", "Datetime", "Float", "Integer", "NotebookRef", "RunState", "String"] 17 | 18 | from .boolean import Boolean 19 | from .datetime import Datetime 20 | from .float import Float 21 | from .integer import Integer 22 | from .notebook_ref import NotebookRef 23 | from .run_state import RunState 24 | from .string import String 25 | -------------------------------------------------------------------------------- /src/neptune/internal/patches/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["apply_patches"] 17 | 18 | from neptune.internal.patches.bravado import patch as bravado_patch 19 | 20 | patches = [bravado_patch] 21 | 22 | 23 | # Apply patches when importing a patching module 24 | # Should be called before usages of patched objects 25 | def apply_patches(): 26 | for patch in patches: 27 | patch() 28 | -------------------------------------------------------------------------------- /tests/e2e/exceptions.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from neptune.internal.exceptions import NeptuneException 17 | 18 | 19 | class ConfigurationException(NeptuneException): 20 | pass 21 | 22 | 23 | class MissingEnvironmentVariable(ConfigurationException): 24 | def __init__(self, missing_variable): 25 | msg = f"Missing '{missing_variable}' in env configuration" 26 | super().__init__(msg) 27 | -------------------------------------------------------------------------------- /.github/actions/job-notify/action.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Notify about job status 3 | description: Send Slack channel notification about job finish status 4 | inputs: 5 | slack-webhook: 6 | description: "A Slack Webhook to post a notification" 7 | required: true 8 | job-status: 9 | description: "Finish status of a preceding job" 10 | required: true 11 | 12 | 13 | runs: 14 | using: "composite" 15 | steps: 16 | - name: Notify about failure 17 | uses: 8398a7/action-slack@v3 18 | if: ${{ inputs.job-status != 'success' }} 19 | env: 20 | SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }} 21 | with: 22 | status: failure 23 | fields: repo,message,author,job,eventName,took 24 | 25 | - name: Notify about success 26 | uses: 8398a7/action-slack@v3 27 | if: ${{ inputs.job-status == 'success' }} 28 | env: 29 | SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook }} 30 | with: 31 | status: success 32 | fields: repo,message,author,job,eventName,took 33 | -------------------------------------------------------------------------------- /src/neptune/types/value.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Value"] 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | if TYPE_CHECKING: 25 | from neptune.types.value_visitor import ValueVisitor 26 | 27 | Ret = TypeVar("Ret") 28 | 29 | 30 | class Value: 31 | @abc.abstractmethod 32 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: ... 33 | -------------------------------------------------------------------------------- /src/neptune/core/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "AssignInt", 18 | "AssignFloat", 19 | "AssignBool", 20 | "AssignString", 21 | "AssignDatetime", 22 | "LogFloats", 23 | ] 24 | 25 | from neptune.core.operations.operation import ( 26 | AssignBool, 27 | AssignDatetime, 28 | AssignFloat, 29 | AssignInt, 30 | AssignString, 31 | LogFloats, 32 | ) 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |

neptune.ai

4 |
5 | 6 |
7 | Website 8 |   •   9 | Docs 10 |   •   11 | Blog 12 |   13 |
14 |
15 | 16 | > [!IMPORTANT] 17 | > This is the Python client for Neptune app version `2.x`.
18 | > For the new Neptune client, go to **[neptune-client-scale →][client]** 19 | 20 | > [!NOTE] 21 | > For Neptune `2.x` setup and instructions, see the [2.x documentation site][legacy-setup]. 22 |
23 |   24 | 25 | Need help? Visit the [Support Center →][support] 26 | 27 | 28 | [client]: https://github.com/neptune-ai/neptune-client-scale 29 | [legacy-setup]: https://docs-legacy.neptune.ai/setup 30 | [support]: https://support.neptune.ai/ 31 | -------------------------------------------------------------------------------- /src/neptune/objects/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "NeptuneObject", 18 | "Model", 19 | "ModelVersion", 20 | "Project", 21 | "Run", 22 | ] 23 | 24 | from neptune.objects.model import Model 25 | from neptune.objects.model_version import ModelVersion 26 | from neptune.objects.neptune_object import NeptuneObject 27 | from neptune.objects.project import Project 28 | from neptune.objects.run import Run 29 | -------------------------------------------------------------------------------- /src/neptune/internal/id_formats.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["UniqueId", "SysId", "QualifiedName", "conform_optional"] 17 | 18 | import typing 19 | from typing import NewType 20 | 21 | UniqueId = NewType("UniqueId", str) 22 | 23 | SysId = NewType("SysId", str) 24 | 25 | QualifiedName = NewType("QualifiedName", str) 26 | 27 | 28 | def conform_optional(value: typing.Optional[str], cls): 29 | return cls(value) if value is not None else None 30 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/atom.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Atom"] 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.types.value import Value 25 | 26 | if TYPE_CHECKING: 27 | from neptune.types.value_visitor import ValueVisitor 28 | 29 | Ret = TypeVar("Ret") 30 | 31 | 32 | class Atom(Value): 33 | @abc.abstractmethod 34 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: ... 35 | -------------------------------------------------------------------------------- /src/neptune/types/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "Boolean", 18 | "Datetime", 19 | "Float", 20 | "Integer", 21 | "String", 22 | "StringSet", 23 | "FloatSeries", 24 | "StringSeries", 25 | ] 26 | 27 | 28 | from .atoms import ( 29 | Boolean, 30 | Datetime, 31 | Float, 32 | Integer, 33 | String, 34 | ) 35 | from .series import ( 36 | FloatSeries, 37 | StringSeries, 38 | ) 39 | from .sets import StringSet 40 | -------------------------------------------------------------------------------- /src/neptune/types/sets/set.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Set"] 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.types.value import Value 25 | 26 | if TYPE_CHECKING: 27 | from neptune.types.value_visitor import ValueVisitor 28 | 29 | Ret = TypeVar("Ret") 30 | 31 | 32 | class Set(Value): 33 | @abc.abstractmethod 34 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 35 | pass 36 | -------------------------------------------------------------------------------- /src/neptune/core/operations/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | from typing import Optional 18 | 19 | from neptune.core.operations.operation import ( 20 | LogFloats, 21 | Operation, 22 | ) 23 | 24 | 25 | def try_get_step(operation: Operation) -> Optional[float]: 26 | if isinstance(operation, LogFloats): 27 | # assumtion: there is at most one value in the LogFloats values list 28 | return operation.values[0].step if operation.values else None 29 | else: 30 | return None 31 | -------------------------------------------------------------------------------- /src/neptune/core/operation_processors/async_operation_processor/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["STOP_QUEUE_STATUS_UPDATE_FREQ_SECONDS", "STOP_QUEUE_MAX_TIME_NO_CONNECTION_SECONDS"] 18 | 19 | import os 20 | 21 | from neptune.envs import NEPTUNE_SYNC_AFTER_STOP_TIMEOUT 22 | from neptune.internal.parameters import DEFAULT_STOP_TIMEOUT 23 | 24 | STOP_QUEUE_STATUS_UPDATE_FREQ_SECONDS = 30.0 25 | STOP_QUEUE_MAX_TIME_NO_CONNECTION_SECONDS = float(os.getenv(NEPTUNE_SYNC_AFTER_STOP_TIMEOUT, DEFAULT_STOP_TIMEOUT)) 26 | -------------------------------------------------------------------------------- /src/neptune/api/requests_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ensure_json_response"] 17 | 18 | from typing import ( 19 | TYPE_CHECKING, 20 | Any, 21 | Dict, 22 | ) 23 | 24 | from simplejson.errors import JSONDecodeError 25 | 26 | if TYPE_CHECKING: 27 | from bravado_core.response import IncomingResponse 28 | 29 | 30 | def ensure_json_response(response: "IncomingResponse") -> Dict[str, Any]: 31 | try: 32 | return response.json() or dict() 33 | except JSONDecodeError: 34 | return dict() 35 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/paths.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["parse_path", "path_to_str", "join_paths"] 17 | 18 | from typing import List 19 | 20 | 21 | def _remove_empty_paths(paths: List[str]) -> List[str]: 22 | return list(filter(bool, paths)) 23 | 24 | 25 | def parse_path(path: str) -> List[str]: 26 | return _remove_empty_paths(str(path).split("/")) 27 | 28 | 29 | def path_to_str(path: List[str]) -> str: 30 | return "/".join(_remove_empty_paths(path)) 31 | 32 | 33 | def join_paths(*paths: str) -> str: 34 | return "/".join(_remove_empty_paths([str(path) for path in paths])) 35 | -------------------------------------------------------------------------------- /src/neptune/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "ANONYMOUS_API_TOKEN", 18 | "NEPTUNE_DATA_DIRECTORY", 19 | "OFFLINE_DIRECTORY", 20 | "ASYNC_DIRECTORY", 21 | "SYNC_DIRECTORY", 22 | "OFFLINE_NAME_PREFIX", 23 | "MAX_32_BIT_INT", 24 | "MIN_32_BIT_INT", 25 | ] 26 | 27 | """Constants used by Neptune""" 28 | 29 | 30 | ANONYMOUS_API_TOKEN = "ANONYMOUS" 31 | 32 | NEPTUNE_DATA_DIRECTORY = ".neptune" 33 | 34 | OFFLINE_DIRECTORY = "offline" 35 | ASYNC_DIRECTORY = "async" 36 | SYNC_DIRECTORY = "sync" 37 | 38 | OFFLINE_NAME_PREFIX = "offline/" 39 | 40 | MAX_32_BIT_INT = 2147483647 41 | MIN_32_BIT_INT = -2147483648 42 | -------------------------------------------------------------------------------- /src/neptune/attributes/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = [ 18 | "Boolean", 19 | "Datetime", 20 | "Float", 21 | "Integer", 22 | "NotebookRef", 23 | "RunState", 24 | "String", 25 | "FloatSeries", 26 | "StringSeries", 27 | "StringSet", 28 | "create_attribute_from_type", 29 | ] 30 | 31 | 32 | from .atoms import ( 33 | Boolean, 34 | Datetime, 35 | Float, 36 | Integer, 37 | NotebookRef, 38 | RunState, 39 | String, 40 | ) 41 | from .series import ( 42 | FloatSeries, 43 | StringSeries, 44 | ) 45 | from .sets import StringSet 46 | from .utils import create_attribute_from_type 47 | -------------------------------------------------------------------------------- /src/neptune/internal/parameters.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "DEFAULT_FLUSH_PERIOD", 18 | "DEFAULT_NAME", 19 | "OFFLINE_PROJECT_QUALIFIED_NAME", 20 | "ASYNC_LAG_THRESHOLD", 21 | "ASYNC_NO_PROGRESS_THRESHOLD", 22 | "DEFAULT_STOP_TIMEOUT", 23 | "MAX_SERVER_OFFSET", 24 | "IN_BETWEEN_CALLBACKS_MINIMUM_INTERVAL", 25 | ] 26 | 27 | DEFAULT_FLUSH_PERIOD = 5 28 | DEFAULT_NAME = "Untitled" 29 | OFFLINE_PROJECT_QUALIFIED_NAME = "offline/project-placeholder" 30 | ASYNC_LAG_THRESHOLD = 1800.0 31 | ASYNC_NO_PROGRESS_THRESHOLD = 300.0 32 | DEFAULT_STOP_TIMEOUT = 60.0 33 | IN_BETWEEN_CALLBACKS_MINIMUM_INTERVAL = 300.0 34 | MAX_SERVER_OFFSET = 10_000 35 | -------------------------------------------------------------------------------- /.github/workflows/run-e2e-command.yml: -------------------------------------------------------------------------------- 1 | name: run-e2e 2 | 3 | on: 4 | repository_dispatch: 5 | types: [run-e2e-command] 6 | 7 | jobs: 8 | comment: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Add reaction 12 | uses: peter-evans/create-or-update-comment@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 16 | reaction-type: hooray 17 | 18 | - name: Create URL to the run output 19 | id: vars 20 | run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT 21 | 22 | - name: Create comment 23 | uses: peter-evans/create-or-update-comment@v4 24 | with: 25 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 26 | issue-number: ${{ github.event.client_payload.github.payload.issue.number }} 27 | body: | 28 | Hey hey @${{ github.event.client_payload.github.actor }}! I'm glad to see that you're looking for something much more demanding :wink: I've triggered for you our E2E tests on every supported Operating System and Python version. [Check current status here :rocket:](${{ steps.vars.outputs.run-url }}) 29 | 30 | invoke: 31 | uses: ./.github/workflows/e2e.yml 32 | -------------------------------------------------------------------------------- /.github/workflows/run-unit-command.yml: -------------------------------------------------------------------------------- 1 | name: run-unit 2 | 3 | on: 4 | repository_dispatch: 5 | types: [run-unit-command] 6 | 7 | jobs: 8 | comment: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Add reaction 12 | uses: peter-evans/create-or-update-comment@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 16 | reaction-type: hooray 17 | 18 | - name: Create URL to the run output 19 | id: vars 20 | run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT 21 | 22 | - name: Create comment 23 | uses: peter-evans/create-or-update-comment@v4 24 | with: 25 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 26 | issue-number: ${{ github.event.client_payload.github.payload.issue.number }} 27 | body: | 28 | Hey hey @${{ github.event.client_payload.github.actor }}! I'm glad to see that you're looking for something much more demanding :wink: I've triggered for you our unittests on every supported Operating System and Python version. [Check current status here :rocket:](${{ steps.vars.outputs.run-url }}) 29 | 30 | invoke: 31 | uses: ./.github/workflows/unit.yml 32 | -------------------------------------------------------------------------------- /src/neptune/types/sets/string_set.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["StringSet"] 17 | 18 | from typing import ( 19 | TYPE_CHECKING, 20 | Iterable, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.types.sets.set import Set 25 | 26 | if TYPE_CHECKING: 27 | from neptune.types.value_visitor import ValueVisitor 28 | 29 | Ret = TypeVar("Ret") 30 | 31 | 32 | class StringSet(Set): 33 | def __init__(self, values: Iterable[str]): 34 | self.values = set(values) 35 | 36 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 37 | return visitor.visit_string_set(self) 38 | 39 | def __str__(self): 40 | return "StringSet({})".format(str(self.values)) 41 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/iso_dates.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["parse_iso_date"] 18 | 19 | import datetime 20 | from typing import Union 21 | 22 | DATE_FORMAT_LONG: str = "%Y-%m-%dT%H:%M:%S.%fZ" 23 | DATE_FORMAT_SHORT: str = "%Y-%m-%dT%H:%M:%SZ" 24 | 25 | 26 | def parse_iso_date(date: Union[str, datetime.datetime]) -> datetime.datetime: 27 | if isinstance(date, datetime.datetime): 28 | return date 29 | 30 | date_format = DATE_FORMAT_LONG if _is_long_date_format(date) else DATE_FORMAT_SHORT 31 | 32 | return datetime.datetime.strptime(date, date_format) 33 | 34 | 35 | def _is_long_date_format(date_string: str) -> bool: 36 | return len(date_string.split(".")) == 2 37 | -------------------------------------------------------------------------------- /src/neptune/internal/background_job.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["BackgroundJob"] 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | Optional, 22 | ) 23 | 24 | if TYPE_CHECKING: 25 | from neptune.objects import NeptuneObject 26 | 27 | 28 | class BackgroundJob: 29 | @abc.abstractmethod 30 | def start(self, container: "NeptuneObject") -> None: ... 31 | 32 | @abc.abstractmethod 33 | def stop(self) -> None: ... 34 | 35 | @abc.abstractmethod 36 | def join(self, seconds: Optional[float] = None) -> None: ... 37 | 38 | @abc.abstractmethod 39 | def pause(self) -> None: ... 40 | 41 | @abc.abstractmethod 42 | def resume(self) -> None: ... 43 | -------------------------------------------------------------------------------- /src/neptune/core/operation_processors/read_only_operation_processor.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ("ReadOnlyOperationProcessor",) 17 | 18 | from typing import TYPE_CHECKING 19 | 20 | from neptune.core.operation_processors.operation_processor import OperationProcessor 21 | from neptune.internal.warnings import ( 22 | NeptuneWarning, 23 | warn_once, 24 | ) 25 | 26 | if TYPE_CHECKING: 27 | from neptune.core.operations.operation import Operation 28 | 29 | 30 | class ReadOnlyOperationProcessor(OperationProcessor): 31 | def enqueue_operation(self, op: "Operation", *, wait: bool) -> None: 32 | warn_once("Client in read-only mode, nothing will be saved to server.", exception=NeptuneWarning) 33 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/runningmode.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["in_interactive", "in_notebook"] 17 | 18 | import sys 19 | 20 | 21 | def in_interactive() -> bool: 22 | """Based on: https://stackoverflow.com/a/2356427/1565454""" 23 | return hasattr(sys, "ps1") 24 | 25 | 26 | def in_notebook() -> bool: 27 | """Based on: https://stackoverflow.com/a/22424821/1565454""" 28 | try: 29 | from IPython import get_ipython # type: ignore 30 | 31 | ipy = get_ipython() 32 | return ( 33 | ipy is not None and hasattr(ipy, "config") and isinstance(ipy.config, dict) and "IPKernelApp" in ipy.config 34 | ) 35 | except ImportError: 36 | return False 37 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/requirement_check.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "require_installed", 18 | "is_installed", 19 | ] 20 | 21 | from functools import lru_cache 22 | from importlib.util import find_spec 23 | from typing import Optional 24 | 25 | from neptune.exceptions import NeptuneMissingRequirementException 26 | 27 | 28 | @lru_cache(maxsize=32) 29 | def is_installed(requirement_name: str) -> bool: 30 | return find_spec(requirement_name) is not None 31 | 32 | 33 | def require_installed(requirement_name: str, *, suggestion: Optional[str] = None) -> None: 34 | if is_installed(requirement_name): 35 | return 36 | 37 | raise NeptuneMissingRequirementException(requirement_name, suggestion) 38 | -------------------------------------------------------------------------------- /src/neptune/version.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["__version__"] 17 | 18 | from importlib.metadata import PackageNotFoundError 19 | from importlib.metadata import version as version_parser 20 | from typing import Optional 21 | 22 | 23 | def check_version(package_name: str) -> Optional[str]: 24 | try: 25 | return version_parser(package_name) 26 | except PackageNotFoundError: 27 | # package is not installed 28 | return None 29 | 30 | 31 | def detect_version() -> str: 32 | neptune_version = check_version("neptune") 33 | 34 | if neptune_version is not None: 35 | return neptune_version 36 | 37 | raise PackageNotFoundError("neptune") 38 | 39 | 40 | __version__ = detect_version() 41 | -------------------------------------------------------------------------------- /.github/workflows/run-integrations-command.yml: -------------------------------------------------------------------------------- 1 | name: run-integrations 2 | 3 | on: 4 | repository_dispatch: 5 | types: [run-integrations-command] 6 | 7 | jobs: 8 | comment: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Add reaction 12 | uses: peter-evans/create-or-update-comment@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 16 | reaction-type: hooray 17 | 18 | - name: Create URL to the run output 19 | id: vars 20 | run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT 21 | 22 | - name: Create comment 23 | uses: peter-evans/create-or-update-comment@v4 24 | with: 25 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 26 | issue-number: ${{ github.event.client_payload.github.payload.issue.number }} 27 | body: | 28 | Hey hey @${{ github.event.client_payload.github.actor }}! I'm glad to see that you're looking for something much more demanding :wink: I've triggered for you tests of our client integrations on every supported Operating System and Python version. [Check current status here :rocket:](${{ steps.vars.outputs.run-url }}) 29 | 30 | invoke: 31 | uses: ./.github/workflows/integrations.yml 32 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/test_attribute_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import unittest 17 | from unittest.mock import MagicMock 18 | 19 | from neptune.api.models import FieldType 20 | from neptune.attributes import create_attribute_from_type 21 | from neptune.attributes.attribute import Attribute 22 | 23 | 24 | class TestAttributeUtils(unittest.TestCase): 25 | def test_attribute_type_to_atom(self): 26 | # Expect all AttributeTypes are reflected in `attribute_type_to_atom`... 27 | # ... and this reflection is class based on `Attribute` 28 | self.assertTrue( 29 | all( 30 | isinstance(create_attribute_from_type(attr_type, MagicMock(), ""), Attribute) for attr_type in FieldType 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /src/neptune/internal/operation_processors/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["get_container_dir"] 17 | 18 | import os 19 | import random 20 | import string 21 | from typing import TYPE_CHECKING 22 | 23 | if TYPE_CHECKING: 24 | from neptune.internal.container_type import ContainerType 25 | from neptune.internal.id_formats import UniqueId 26 | 27 | 28 | RANDOM_KEY_LENGTH = 8 29 | 30 | 31 | def get_container_dir(container_id: "UniqueId", container_type: "ContainerType") -> str: 32 | return f"{container_type.value}__{container_id}__{os.getpid()}__{random_key(RANDOM_KEY_LENGTH)}" 33 | 34 | 35 | def random_key(length: int) -> str: 36 | characters = string.ascii_lowercase + string.digits 37 | return "".join(random.choice(characters) for _ in range(length)) 38 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit-apply-command.yml: -------------------------------------------------------------------------------- 1 | name: pre-commit-apply 2 | 3 | on: 4 | repository_dispatch: 5 | types: [pre-commit-apply-command] 6 | 7 | jobs: 8 | pre-commit: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout repository 12 | uses: actions/checkout@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | ref: ${{ github.event.client_payload.pull_request.head.ref }} 16 | 17 | - name: Install Python 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: "3.12" 21 | 22 | - name: Install pre-commit 23 | run: pip install pre-commit 24 | 25 | - name: Pre-commit 26 | id: pre-commit 27 | continue-on-error: true 28 | run: pre-commit run --all-files 29 | 30 | - name: Commit to the PR branch 31 | if: steps.pre-commit.outcome != 'success' 32 | run: | 33 | git config --global user.name '${{ secrets.NEPTUNE_BOT_USERNAME }}' 34 | git config --global user.email '${{ secrets.NEPTUNE_BOT_EMAIL }}' 35 | git commit -am "pre-commit applied" 36 | git push 37 | 38 | - name: Add reaction 39 | uses: peter-evans/create-or-update-comment@v4 40 | with: 41 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 42 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 43 | reaction-type: hooray 44 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/client/test_model_tables.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | import unittest 18 | from typing import List 19 | 20 | from neptune import init_project 21 | from neptune.internal.container_type import ContainerType 22 | from neptune.table import ( 23 | Table, 24 | TableEntry, 25 | ) 26 | from tests.unit.neptune.new.client.abstract_tables_test import AbstractTablesTestMixin 27 | 28 | 29 | class TestModelTables(AbstractTablesTestMixin, unittest.TestCase): 30 | expected_container_type = ContainerType.MODEL 31 | 32 | def get_table(self, **kwargs) -> Table: 33 | return init_project(project="organization/project", mode="read-only").fetch_models_table(**kwargs) 34 | 35 | def get_table_entries(self, table) -> List[TableEntry]: 36 | return table.to_rows() 37 | -------------------------------------------------------------------------------- /src/neptune/internal/websockets/websockets_factory.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["WebsocketsFactory"] 17 | 18 | import threading 19 | from typing import Optional 20 | 21 | from requests_oauthlib import OAuth2Session 22 | 23 | from neptune.internal.websockets.reconnecting_websocket import ReconnectingWebsocket 24 | 25 | 26 | class WebsocketsFactory: 27 | def __init__(self, url: str, session: OAuth2Session, proxies: Optional[dict] = None): 28 | self._url = url 29 | self._session = session 30 | self._proxies = proxies 31 | 32 | def create(self): 33 | return ReconnectingWebsocket( 34 | url=self._url, 35 | oauth2_session=self._session, 36 | shutdown_event=threading.Event(), 37 | proxies=self._proxies, 38 | ) 39 | -------------------------------------------------------------------------------- /src/neptune/core/components/operation_storage.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["OperationStorage"] 17 | 18 | import os 19 | import shutil 20 | from pathlib import Path 21 | 22 | from neptune.core.components.abstract import Resource 23 | 24 | UPLOAD_PATH: str = "upload_path" 25 | 26 | 27 | class OperationStorage(Resource): 28 | def __init__(self, data_path: Path): 29 | self._data_path = data_path 30 | 31 | # initialize upload directory 32 | os.makedirs(self.upload_path, exist_ok=True) 33 | 34 | @property 35 | def data_path(self) -> Path: 36 | return self._data_path 37 | 38 | @property 39 | def upload_path(self) -> Path: 40 | return self._data_path / UPLOAD_PATH 41 | 42 | def cleanup(self) -> None: 43 | shutil.rmtree(self.upload_path, ignore_errors=True) 44 | -------------------------------------------------------------------------------- /.github/actions/install-package/action.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Package 3 | description: Install python and package 4 | inputs: 5 | python-version: 6 | description: "Python version" 7 | required: true 8 | os: 9 | description: "Operating system" 10 | required: true 11 | pip_url: 12 | description: "Pip URL for integration installation" 13 | required: false 14 | 15 | runs: 16 | using: "composite" 17 | steps: 18 | - name: Get current date 19 | id: date 20 | run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT 21 | shell: bash 22 | 23 | - uses: actions/cache@v3 24 | id: cache 25 | with: 26 | path: ~/.cache/pip 27 | key: ${{ inputs.os }}-python-${{ inputs.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ steps.date.outputs.date }} 28 | 29 | - name: Install Python ${{ inputs.python-version }} 30 | uses: actions/setup-python@v4 31 | with: 32 | python-version: ${{ inputs.python-version }} 33 | 34 | - name: Install integration packages (if applicable) 35 | run: | 36 | pip install ${{ inputs.pip_url }} 37 | shell: bash 38 | if: inputs.pip_url 39 | 40 | - name: Install dependencies 41 | run: | 42 | pip install -r dev_requirements.txt 43 | shell: bash 44 | 45 | - name: List dependencies 46 | run: | 47 | pip list 48 | shell: bash 49 | -------------------------------------------------------------------------------- /src/neptune/types/series/series.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Series"] 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.types.value import Value 25 | 26 | if TYPE_CHECKING: 27 | from neptune.types.value_visitor import ValueVisitor 28 | 29 | Ret = TypeVar("Ret") 30 | 31 | 32 | class Series(Value): 33 | @abc.abstractmethod 34 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 35 | pass 36 | 37 | @property 38 | @abc.abstractmethod 39 | def values(self): 40 | pass 41 | 42 | @property 43 | @abc.abstractmethod 44 | def steps(self): 45 | pass 46 | 47 | @property 48 | @abc.abstractmethod 49 | def timestamps(self): 50 | pass 51 | 52 | def __len__(self): 53 | return len(self.values) 54 | -------------------------------------------------------------------------------- /.github/workflows/run-all-test-command.yml: -------------------------------------------------------------------------------- 1 | name: run-all-test 2 | 3 | on: 4 | repository_dispatch: 5 | types: [run-all-test-command] 6 | 7 | jobs: 8 | comment: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Add reaction 12 | uses: peter-evans/create-or-update-comment@v4 13 | with: 14 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 15 | comment-id: ${{ github.event.client_payload.github.payload.comment.id }} 16 | reaction-type: hooray 17 | 18 | - name: Create URL to the run output 19 | id: vars 20 | run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT 21 | 22 | - name: Create comment 23 | uses: peter-evans/create-or-update-comment@v4 24 | with: 25 | token: ${{ secrets.NEPTUNE_BOT_ACCESS_TOKEN }} 26 | issue-number: ${{ github.event.client_payload.github.payload.issue.number }} 27 | body: | 28 | Hey hey @${{ github.event.client_payload.github.actor }}! I'm glad to see that you're looking for something much more demanding :wink: I've triggered for you all possible tests on every supported Operating System and Python version. [Check current status here :rocket:](${{ steps.vars.outputs.run-url }}) 29 | 30 | invoke-unit: 31 | uses: ./.github/workflows/unit.yml 32 | 33 | invoke-e2e: 34 | uses: ./.github/workflows/e2e.yml 35 | 36 | invoke-integrations: 37 | uses: ./.github/workflows/integrations.yml 38 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/iteration.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["get_batches"] 17 | 18 | from itertools import ( 19 | chain, 20 | islice, 21 | ) 22 | from typing import ( 23 | Iterable, 24 | List, 25 | TypeVar, 26 | ) 27 | 28 | T = TypeVar("T") 29 | 30 | 31 | def get_batches(iterable: Iterable[T], *, batch_size: int) -> Iterable[List[T]]: 32 | assert batch_size > 0 33 | 34 | source_iter = iter(iterable) 35 | while True: 36 | # return consequent slices of `batch_size` elements 37 | slices = islice(source_iter, batch_size) 38 | try: 39 | first_from_slice = next(slices) 40 | except StopIteration: 41 | # but if there's nothing to return in last slice, close generator instead of returning empty list 42 | return 43 | yield list(chain([first_from_slice], slices)) 44 | -------------------------------------------------------------------------------- /src/neptune/internal/container_type.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ContainerType"] 17 | 18 | import enum 19 | 20 | from neptune.internal.id_formats import UniqueId 21 | 22 | 23 | class ContainerType(str, enum.Enum): 24 | RUN = "run" 25 | PROJECT = "project" 26 | MODEL = "model" 27 | MODEL_VERSION = "model_version" 28 | 29 | def to_api(self) -> str: 30 | if self == ContainerType.MODEL_VERSION: 31 | return "modelVersion" 32 | else: 33 | return self.value 34 | 35 | @staticmethod 36 | def from_api(api_type: str) -> "ContainerType": 37 | if api_type == "modelVersion": 38 | return ContainerType.MODEL_VERSION 39 | else: 40 | return ContainerType(api_type) 41 | 42 | def create_dir_name(self, container_id: UniqueId) -> str: 43 | return f"{self.value}__{container_id}" 44 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/float.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Float"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.internal.types.stringify_value import extract_if_stringify_value 25 | from neptune.types.atoms.atom import Atom 26 | 27 | if TYPE_CHECKING: 28 | from neptune.types.value_visitor import ValueVisitor 29 | 30 | Ret = TypeVar("Ret") 31 | 32 | 33 | @dataclass 34 | class Float(Atom): 35 | 36 | value: float 37 | 38 | def __init__(self, value): 39 | self.value = float(extract_if_stringify_value(value)) 40 | 41 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 42 | return visitor.visit_float(self) 43 | 44 | def __str__(self): 45 | return "Float({})".format(str(self.value)) 46 | 47 | def __float__(self): 48 | return self.value 49 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/boolean.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Boolean"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.internal.types.stringify_value import extract_if_stringify_value 25 | from neptune.types.atoms.atom import Atom 26 | 27 | if TYPE_CHECKING: 28 | from neptune.types.value_visitor import ValueVisitor 29 | 30 | Ret = TypeVar("Ret") 31 | 32 | 33 | @dataclass 34 | class Boolean(Atom): 35 | 36 | value: bool 37 | 38 | def __init__(self, value): 39 | self.value = bool(extract_if_stringify_value(value)) 40 | 41 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 42 | return visitor.visit_boolean(self) 43 | 44 | def __str__(self): 45 | return "Boolean({})".format(str(self.value)) 46 | 47 | def __bool__(self): 48 | return self.value 49 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/integer.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Integer"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.internal.types.stringify_value import extract_if_stringify_value 25 | from neptune.types.atoms.atom import Atom 26 | 27 | if TYPE_CHECKING: 28 | from neptune.types.value_visitor import ValueVisitor 29 | 30 | Ret = TypeVar("Ret") 31 | 32 | 33 | @dataclass 34 | class Integer(Atom): 35 | 36 | value: int 37 | 38 | def __init__(self, value): 39 | self.value = int(extract_if_stringify_value(value)) 40 | 41 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 42 | return visitor.visit_integer(self) 43 | 44 | def __str__(self): 45 | return "Integer({})".format(str(self.value)) 46 | 47 | def __int__(self): 48 | return self.value 49 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.3.0 4 | hooks: 5 | - id: check-yaml 6 | - id: end-of-file-fixer 7 | - id: trailing-whitespace 8 | - repo: https://github.com/pycqa/isort 9 | rev: 5.13.2 10 | hooks: 11 | - id: isort 12 | args: [--settings-path, pyproject.toml] 13 | - repo: https://github.com/psf/black 14 | rev: 24.2.0 15 | hooks: 16 | - id: black 17 | args: [--config, pyproject.toml] 18 | - repo: https://github.com/Lucas-C/pre-commit-hooks 19 | rev: v1.5.4 20 | hooks: 21 | - id: insert-license 22 | files: ^src/neptune/(?!new/)[^/]+(?:/[^/]+)*\.py$ 23 | args: [ "--license-filepath", ".github/license_header.txt", "--allow-past-years"] 24 | - repo: https://github.com/pycqa/flake8 25 | rev: 7.0.0 26 | hooks: 27 | - id: flake8 28 | entry: pflake8 29 | additional_dependencies: ["pyproject-flake8"] 30 | - repo: https://github.com/pre-commit/mirrors-mypy 31 | rev: v1.4.1 32 | hooks: 33 | - id: mypy 34 | args: [ --config-file, pyproject.toml ] 35 | pass_filenames: false 36 | additional_dependencies: 37 | - types-click 38 | - mypy-protobuf 39 | - neptune-api==0.3.0 40 | - packaging 41 | exclude: | 42 | (?x)( 43 | ^tests/unit/data/| 44 | ^.github/license_header\.txt| 45 | ^src/neptune/api/proto/ 46 | ) 47 | default_language_version: 48 | python: python3 49 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/utils/file_helpers.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import contextlib 17 | import os 18 | from tempfile import NamedTemporaryFile 19 | 20 | 21 | @contextlib.contextmanager 22 | def create_file(content=None, binary_mode=False) -> str: 23 | """ 24 | A lot this is motivated by: 25 | Whether the name can be used to open the file a second time, 26 | while the named temporary file is still open, varies across platforms 27 | (it can be so used on Unix; it cannot on Windows NT or later). 28 | ref. https://docs.python.org/3.9/library/tempfile.html#tempfile.NamedTemporaryFile 29 | """ 30 | if binary_mode: 31 | mode = "wb" 32 | else: 33 | mode = "w" 34 | with NamedTemporaryFile(mode, delete=False) as file: 35 | if content: 36 | file.write(content) 37 | file.close() 38 | yield file.name 39 | os.remove(file.name) 40 | -------------------------------------------------------------------------------- /src/neptune/core/typing/container_type.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ContainerType"] 17 | 18 | import enum 19 | 20 | from neptune.core.typing.id_formats import UniqueId 21 | 22 | 23 | class ContainerType(str, enum.Enum): 24 | RUN = "run" 25 | PROJECT = "project" 26 | MODEL = "model" 27 | MODEL_VERSION = "model_version" 28 | 29 | def to_api(self) -> str: 30 | if self == ContainerType.MODEL_VERSION: 31 | return "modelVersion" 32 | else: 33 | value: str = self.value 34 | return value 35 | 36 | @staticmethod 37 | def from_api(api_type: str) -> "ContainerType": 38 | if api_type == "modelVersion": 39 | return ContainerType.MODEL_VERSION 40 | else: 41 | return ContainerType(api_type) 42 | 43 | def create_dir_name(self, container_id: UniqueId) -> str: 44 | return f"{self.value}__{container_id}" 45 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: off 4 | patch: off 5 | 6 | flags: 7 | unit: 8 | paths: 9 | - src/neptune 10 | carryforward: true 11 | 12 | e2e: 13 | paths: 14 | - src/neptune 15 | carryforward: true 16 | 17 | ubuntu: 18 | paths: 19 | - src/neptune 20 | carryforward: true 21 | 22 | macos: 23 | paths: 24 | - src/neptune 25 | carryforward: true 26 | 27 | windows: 28 | paths: 29 | - src/neptune 30 | carryforward: true 31 | 32 | py3.7: 33 | paths: 34 | - src/neptune 35 | carryforward: true 36 | 37 | py3.8: 38 | paths: 39 | - src/neptune 40 | carryforward: true 41 | 42 | py3.9: 43 | paths: 44 | - src/neptune 45 | carryforward: true 46 | 47 | py3.10: 48 | paths: 49 | - src/neptune 50 | carryforward: true 51 | 52 | py3.11: 53 | paths: 54 | - src/neptune 55 | carryforward: true 56 | 57 | py3.12: 58 | paths: 59 | - src/neptune 60 | carryforward: true 61 | 62 | e2e-standard: 63 | paths: 64 | - src/neptune 65 | carryforward: true 66 | 67 | component_management: 68 | individual_components: 69 | - component_id: client 70 | name: client 71 | paths: 72 | - src/neptune/attributes/** 73 | - src/neptune/cli/** 74 | - src/neptune/common/** 75 | - src/neptune/internal/** 76 | - src/neptune/objects/** 77 | - src/neptune/new/** 78 | - src/neptune/types/** 79 | - src/neptune/*.py 80 | -------------------------------------------------------------------------------- /src/neptune/cli/__main__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | import warnings 18 | 19 | import click 20 | import pkg_resources 21 | 22 | from neptune.cli.commands import ( 23 | clear, 24 | status, 25 | sync, 26 | ) 27 | 28 | 29 | @click.group() 30 | def main() -> None: 31 | pass 32 | 33 | 34 | main.add_command(sync) 35 | main.add_command(status) 36 | main.add_command(clear) 37 | 38 | plugins = {entry_point.name: entry_point for entry_point in pkg_resources.iter_entry_points("neptune.plugins")} 39 | 40 | for name, entry_point in plugins.items(): 41 | # loading an entry_point may fail and this 42 | # will cause all CLI commands to fail. 43 | # So, we load the plug-ins in try and except block. 44 | try: 45 | loaded_plugin = entry_point.load() 46 | except Exception as e: 47 | warnings.warn(f"Failed to load neptune plug-in `{name}` with exception: {e}") 48 | main.add_command(loaded_plugin, name) 49 | -------------------------------------------------------------------------------- /tests/e2e/standard/test_multiprocessing.py: -------------------------------------------------------------------------------- 1 | import os 2 | import signal 3 | import unittest 4 | from multiprocessing import Barrier 5 | 6 | import pytest 7 | 8 | from neptune.internal.utils.utils import IS_WINDOWS 9 | from tests.e2e.base import AVAILABLE_CONTAINERS 10 | from tests.e2e.utils import ( 11 | Environment, 12 | initialize_container, 13 | ) 14 | 15 | 16 | @unittest.skipIf(IS_WINDOWS, "Windows does not support fork") 17 | @pytest.mark.parametrize("container_type", AVAILABLE_CONTAINERS) 18 | def test_fork_child_parent_info_exchange(container_type: str, environment: Environment): 19 | barrier = Barrier(2) 20 | with initialize_container(container_type=container_type, project=environment.project) as container: 21 | child_pid = os.fork() 22 | if child_pid == 0: 23 | # child process exec 24 | container["child_key"] = "child_value" 25 | container.wait() 26 | barrier.wait() # after barrier both processes have sent data 27 | 28 | container.sync() 29 | assert container["parent_key"].fetch() == "parent_value" 30 | 31 | os.kill(os.getpid(), signal.SIGTERM) # kill child process, as it has cloned testing runtime 32 | else: 33 | # parent process exec 34 | container["parent_key"] = "parent_value" 35 | container.wait() 36 | barrier.wait() # after barrier both processes have sent data 37 | 38 | container.sync() 39 | assert container["child_key"].fetch() == "child_value" 40 | 41 | os.waitpid(child_pid, 0) 42 | -------------------------------------------------------------------------------- /src/neptune/types/series/series_value.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["SeriesValue"] 17 | 18 | from typing import ( 19 | Generic, 20 | TypeVar, 21 | ) 22 | 23 | T = TypeVar("T") 24 | 25 | 26 | class SeriesValue(Generic[T]): 27 | def __init__(self, step: float, value: T, timestamp: float): 28 | self._step = step 29 | self._value = value 30 | self._timestamp = timestamp 31 | 32 | @property 33 | def step(self) -> float: 34 | return self._step 35 | 36 | @step.setter 37 | def step(self, step: float): 38 | self._step = step 39 | 40 | @property 41 | def value(self) -> T: 42 | return self._value 43 | 44 | @value.setter 45 | def value(self, value: T): 46 | self._value = value 47 | 48 | @property 49 | def timestamp(self) -> float: 50 | return self._timestamp 51 | 52 | @timestamp.setter 53 | def timestamp(self, timestamp: float): 54 | self._timestamp = timestamp 55 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/datetime.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Datetime"] 17 | 18 | from dataclasses import dataclass 19 | from datetime import datetime 20 | from typing import ( 21 | TYPE_CHECKING, 22 | TypeVar, 23 | Union, 24 | ) 25 | 26 | from neptune.internal.types.stringify_value import ( 27 | StringifyValue, 28 | extract_if_stringify_value, 29 | ) 30 | from neptune.types.atoms.atom import Atom 31 | 32 | if TYPE_CHECKING: 33 | from neptune.types.value_visitor import ValueVisitor 34 | 35 | Ret = TypeVar("Ret") 36 | 37 | 38 | @dataclass 39 | class Datetime(Atom): 40 | value: datetime 41 | 42 | def __init__(self, value: Union[datetime, StringifyValue]): 43 | value = extract_if_stringify_value(value) 44 | self.value = value.replace(microsecond=1000 * int(value.microsecond / 1000)) 45 | 46 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 47 | return visitor.visit_datetime(self) 48 | 49 | def __str__(self): 50 | return "Datetime({})".format(str(self.value)) 51 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/backends/test_swagger_client_wrapper.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import unittest 17 | from unittest.mock import MagicMock 18 | 19 | from neptune.internal.backends.swagger_client_wrapper import SwaggerClientWrapper 20 | 21 | 22 | class TestSwaggerClientWrapper(unittest.TestCase): 23 | def setUp(self) -> None: 24 | pass 25 | 26 | def test_api_callable_objects(self): 27 | # given 28 | swagger_client = MagicMock() 29 | api = MagicMock() 30 | api.callable_object = MagicMock() 31 | api.callable_object.sub_property = 13 32 | swagger_client.api = api 33 | 34 | wrapper = SwaggerClientWrapper(swagger_client) 35 | 36 | # when 37 | wrapper.api.method("arg1", kwarg="kwarg1") 38 | wrapper.api.callable_object("arg2", kwarg="kwarg2") 39 | 40 | # then 41 | api.method.assert_called_once_with("arg1", kwarg="kwarg1") 42 | api.callable_object.assert_called_once_with("arg2", kwarg="kwarg2") 43 | self.assertEqual(13, wrapper.api.callable_object.sub_property) 44 | -------------------------------------------------------------------------------- /src/neptune/cli/path_option.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | __all__ = ["path_option"] 18 | 19 | from pathlib import Path 20 | from typing import Any 21 | 22 | import click 23 | 24 | from neptune.constants import NEPTUNE_DATA_DIRECTORY 25 | 26 | 27 | def get_neptune_path(ctx: Any, param: Any, path: str) -> Path: 28 | # check if path exists and contains a '.neptune' folder 29 | local_path = Path(path) 30 | 31 | if (local_path / NEPTUNE_DATA_DIRECTORY).is_dir(): 32 | return local_path / NEPTUNE_DATA_DIRECTORY 33 | elif local_path.name == NEPTUNE_DATA_DIRECTORY and local_path.is_dir(): 34 | return local_path 35 | else: 36 | raise click.BadParameter("Path {} does not contain a '{}' folder.".format(local_path, NEPTUNE_DATA_DIRECTORY)) 37 | 38 | 39 | path_option = click.option( 40 | "--path", 41 | type=click.Path(exists=True, file_okay=False, resolve_path=True), 42 | default=Path.cwd(), 43 | callback=get_neptune_path, 44 | metavar="", 45 | help="path to a directory containing a '.neptune' folder with stored objects", 46 | ) 47 | -------------------------------------------------------------------------------- /src/neptune/core/operation_processors/operation_processor.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ("OperationProcessor",) 17 | 18 | import abc 19 | from typing import ( 20 | TYPE_CHECKING, 21 | Optional, 22 | ) 23 | 24 | if TYPE_CHECKING: 25 | from neptune.core.components.operation_storage import OperationStorage 26 | from neptune.core.operations.operation import Operation 27 | 28 | 29 | class OperationProcessor(abc.ABC): 30 | @abc.abstractmethod 31 | def enqueue_operation(self, op: "Operation", *, wait: bool) -> None: ... 32 | 33 | @property 34 | def operation_storage(self) -> "OperationStorage": 35 | raise NotImplementedError() 36 | 37 | def start(self) -> None: 38 | pass 39 | 40 | def pause(self) -> None: 41 | pass 42 | 43 | def resume(self) -> None: 44 | pass 45 | 46 | def flush(self) -> None: 47 | pass 48 | 49 | def wait(self) -> None: 50 | pass 51 | 52 | def stop(self, seconds: Optional[float] = None) -> None: 53 | pass 54 | 55 | def close(self) -> None: 56 | pass 57 | -------------------------------------------------------------------------------- /src/neptune/types/atoms/string.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["String"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | Optional, 22 | TypeVar, 23 | Union, 24 | ) 25 | 26 | from neptune.internal.types.stringify_value import StringifyValue 27 | from neptune.internal.utils import ( 28 | is_stringify_value, 29 | verify_type, 30 | ) 31 | from neptune.types.atoms.atom import Atom 32 | 33 | if TYPE_CHECKING: 34 | from neptune.types.value_visitor import ValueVisitor 35 | 36 | Ret = TypeVar("Ret") 37 | 38 | 39 | @dataclass 40 | class String(Atom): 41 | 42 | value: str 43 | 44 | def __init__(self, value: Optional[Union[str, StringifyValue]]): 45 | verify_type("value", value, (str, type(None), StringifyValue)) 46 | 47 | self.value = str(value.value) if is_stringify_value(value) else value 48 | 49 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 50 | return visitor.visit_string(self) 51 | 52 | def __str__(self) -> str: 53 | return "String({})".format(str(self.value)) 54 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/utils/test_hashing.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from random import ( 17 | choices, 18 | randint, 19 | ) 20 | from string import ( 21 | ascii_uppercase, 22 | digits, 23 | ) 24 | 25 | from neptune.internal.utils.hashing import generate_hash 26 | 27 | 28 | class TestHashGenerator: 29 | def test_should_be_deterministic(self): 30 | # given 31 | descriptors = [randint(0, 1024), "".join(choices(ascii_uppercase + digits, k=8))] 32 | 33 | # when 34 | hash1 = generate_hash(*descriptors, length=8) 35 | hash2 = generate_hash(*descriptors, length=8) 36 | 37 | # then 38 | assert hash1 == hash2 39 | 40 | def test_should_be_unique(self): 41 | # given 42 | unique_descriptors = set((randint(0, 1024), "".join(choices(ascii_uppercase + digits, k=8))) for _ in range(10)) 43 | 44 | # when 45 | unique_hashes = set(generate_hash(*descriptors, length=8) for descriptors in unique_descriptors) 46 | 47 | # then 48 | assert len(unique_descriptors) == len(unique_hashes) 49 | -------------------------------------------------------------------------------- /.github/workflows/unit.yml: -------------------------------------------------------------------------------- 1 | name: unit 2 | 3 | on: 4 | workflow_call: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: "0 4 * * *" # Run every day at arbitrary time (4:00 AM UTC) 8 | push: 9 | branches: 10 | - master 11 | 12 | jobs: 13 | test: 14 | timeout-minutes: 75 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] 19 | os: [ubuntu, windows, macos] 20 | 21 | name: 'test (${{ matrix.os }} - py${{ matrix.python-version }})' 22 | runs-on: ${{ matrix.os }}-latest 23 | steps: 24 | - name: Checkout repository 25 | uses: actions/checkout@v4 26 | with: 27 | fetch-depth: 0 28 | ref: ${{ github.event.client_payload.pull_request.head.ref }} 29 | 30 | - name: Run tests 31 | uses: ./.github/actions/test-unit 32 | with: 33 | python-version: ${{ matrix.python-version }} 34 | os: ${{ matrix.os }} 35 | report_job: 'test (${{ matrix.os }} - py${{ matrix.python-version }})' 36 | codecov-token: ${{ secrets.CODECOV_TOKEN }} 37 | 38 | unit-tests-notify: 39 | needs: [ test ] 40 | runs-on: ubuntu-latest 41 | if: (success() || failure()) && github.ref == 'refs/heads/master' 42 | steps: 43 | - name: Checkout repository 44 | uses: actions/checkout@v4 45 | with: 46 | fetch-depth: 0 47 | ref: ${{ github.event.client_payload.pull_request.head.ref }} 48 | 49 | - name: Notify 50 | uses: ./.github/actions/workflow-notify-v2 51 | with: 52 | slack-webhook: ${{ secrets.E2E_REGULAR_SLACK_WEBHOOK }} 53 | neptune-ref: ${{ github.ref }} 54 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/api/model/attributes_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: model/attributes.proto 4 | # Protobuf Python Version: 4.25.1 5 | """Generated protocol buffer code.""" 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | from google.protobuf.internal import builder as _builder 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | 16 | 17 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16model/attributes.proto\x12\x11neptune.api.model\"a\n\x1eProtoAttributesSearchResultDTO\x12?\n\x07\x65ntries\x18\x01 \x03(\x0b\x32..neptune.api.model.ProtoAttributeDefinitionDTO\"9\n\x1bProtoAttributeDefinitionDTO\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\tB4\n0ml.neptune.leaderboard.api.model.proto.generatedP\x01\x62\x06proto3') 18 | 19 | _globals = globals() 20 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) 21 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'model.attributes_pb2', _globals) 22 | if _descriptor._USE_C_DESCRIPTORS == False: 23 | _globals['DESCRIPTOR']._options = None 24 | _globals['DESCRIPTOR']._serialized_options = b'\n0ml.neptune.leaderboard.api.model.proto.generatedP\001' 25 | _globals['_PROTOATTRIBUTESSEARCHRESULTDTO']._serialized_start=45 26 | _globals['_PROTOATTRIBUTESSEARCHRESULTDTO']._serialized_end=142 27 | _globals['_PROTOATTRIBUTEDEFINITIONDTO']._serialized_start=144 28 | _globals['_PROTOATTRIBUTEDEFINITIONDTO']._serialized_end=201 29 | # @@protoc_insertion_point(module_scope) 30 | -------------------------------------------------------------------------------- /tests/unit/neptune/backend_test_mixin.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | from mock import MagicMock 18 | 19 | 20 | class BackendTestMixin: 21 | @staticmethod 22 | def _get_swagger_client_mock( 23 | swagger_client_factory, 24 | min_recommended=None, 25 | min_compatible=None, 26 | max_compatible=None, 27 | ): 28 | py_lib_versions = type("py_lib_versions", (object,), {})() 29 | setattr(py_lib_versions, "minRecommendedVersion", min_recommended) 30 | setattr(py_lib_versions, "minCompatibleVersion", min_compatible) 31 | setattr(py_lib_versions, "maxCompatibleVersion", max_compatible) 32 | 33 | client_config = type("client_config_response_result", (object,), {})() 34 | setattr(client_config, "pyLibVersions", py_lib_versions) 35 | setattr(client_config, "apiUrl", "ui.neptune.ai") 36 | 37 | swagger_client = MagicMock() 38 | swagger_client.api.getClientConfig.return_value.response.return_value.result = client_config 39 | swagger_client_factory.return_value = swagger_client 40 | 41 | return swagger_client 42 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/client/test_model_version_tables.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | import unittest 18 | from typing import List 19 | 20 | import pytest 21 | 22 | from neptune import init_model 23 | from neptune.exceptions import NeptuneUnsupportedFunctionalityException 24 | from neptune.internal.container_type import ContainerType 25 | from neptune.table import ( 26 | Table, 27 | TableEntry, 28 | ) 29 | from tests.unit.neptune.new.client.abstract_tables_test import AbstractTablesTestMixin 30 | 31 | 32 | @pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException) 33 | class TestModelVersionTables(AbstractTablesTestMixin, unittest.TestCase): 34 | expected_container_type = ContainerType.MODEL_VERSION 35 | 36 | def get_table(self, **kwargs) -> Table: 37 | return init_model( 38 | with_id="organization/project", 39 | project="PRO-MOD", 40 | mode="read-only", 41 | ).fetch_model_versions_table(**kwargs) 42 | 43 | def get_table_entries(self, table) -> List[TableEntry]: 44 | return table.to_rows() 45 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/run_state.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["RunState"] 17 | 18 | import enum 19 | 20 | from neptune.internal.exceptions import NeptuneException 21 | 22 | 23 | class RunState(enum.Enum): 24 | active = "Active" 25 | inactive = "Inactive" 26 | 27 | _api_active = "running" 28 | _api_inactive = "idle" 29 | 30 | @classmethod 31 | def from_string(cls, value: str) -> "RunState": 32 | try: 33 | return cls(value.capitalize()) 34 | except ValueError as e: 35 | raise NeptuneException(f"Can't map RunState to API: {value}") from e 36 | 37 | @staticmethod 38 | def from_api(value: str) -> "RunState": 39 | if value == RunState._api_active.value: 40 | return RunState.active 41 | elif value == RunState._api_inactive.value: 42 | return RunState.inactive 43 | else: 44 | raise NeptuneException(f"Unknown RunState: {value}") 45 | 46 | def to_api(self) -> str: 47 | if self is RunState.active: 48 | return self._api_active.value 49 | if self is RunState.inactive: 50 | return self._api_inactive.value 51 | -------------------------------------------------------------------------------- /src/neptune/objects/structure_version.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["StructureVersion"] 17 | 18 | from enum import Enum 19 | 20 | 21 | class StructureVersion(Enum): 22 | # ------------------------------------------------- 23 | # .neptune/ 24 | # async/ 25 | # / 26 | # exec-/ 27 | # container_type 28 | # data-1.log 29 | # ... 30 | # ------------------------------------------------- 31 | LEGACY = 1 32 | 33 | # ------------------------------------------------- 34 | # .neptune/ 35 | # async/ 36 | # run__/ 37 | # exec---/ 38 | # data-1.log 39 | # ... 40 | # ------------------------------------------------- 41 | CHILD_EXECUTION_DIRECTORIES = 2 42 | 43 | # ------------------------------------------------- 44 | # .neptune/ 45 | # async/ 46 | # run______/ 47 | # data-1.log 48 | # ... 49 | # ------------------------------------------------- 50 | DIRECT_DIRECTORY = 3 51 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/api/model/series_values_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: model/series_values.proto 4 | # Protobuf Python Version: 4.25.1 5 | """Generated protocol buffer code.""" 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | from google.protobuf.internal import builder as _builder 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | 16 | 17 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19model/series_values.proto\x12\x11neptune.api.model\"q\n\x19ProtoFloatSeriesValuesDTO\x12\x18\n\x10total_item_count\x18\x01 \x01(\x03\x12:\n\x06values\x18\x02 \x03(\x0b\x32*.neptune.api.model.ProtoFloatPointValueDTO\"P\n\x17ProtoFloatPointValueDTO\x12\x18\n\x10timestamp_millis\x18\x01 \x01(\x03\x12\x0c\n\x04step\x18\x02 \x01(\x01\x12\r\n\x05value\x18\x03 \x01(\x01\x42\x34\n0ml.neptune.leaderboard.api.model.proto.generatedP\x01\x62\x06proto3') 18 | 19 | _globals = globals() 20 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) 21 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'model.series_values_pb2', _globals) 22 | if _descriptor._USE_C_DESCRIPTORS == False: 23 | _globals['DESCRIPTOR']._options = None 24 | _globals['DESCRIPTOR']._serialized_options = b'\n0ml.neptune.leaderboard.api.model.proto.generatedP\001' 25 | _globals['_PROTOFLOATSERIESVALUESDTO']._serialized_start=48 26 | _globals['_PROTOFLOATSERIESVALUESDTO']._serialized_end=161 27 | _globals['_PROTOFLOATPOINTVALUEDTO']._serialized_start=163 28 | _globals['_PROTOFLOATPOINTVALUEDTO']._serialized_end=243 29 | # @@protoc_insertion_point(module_scope) 30 | -------------------------------------------------------------------------------- /src/neptune/internal/backgroud_job_list.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["BackgroundJobList"] 17 | 18 | import time 19 | from typing import ( 20 | TYPE_CHECKING, 21 | List, 22 | Optional, 23 | ) 24 | 25 | from neptune.internal.background_job import BackgroundJob 26 | 27 | if TYPE_CHECKING: 28 | from neptune.objects import NeptuneObject 29 | 30 | 31 | class BackgroundJobList(BackgroundJob): 32 | def __init__(self, jobs: List[BackgroundJob]) -> None: 33 | self._jobs: List[BackgroundJob] = jobs 34 | 35 | def start(self, container: "NeptuneObject") -> None: 36 | for job in self._jobs: 37 | job.start(container) 38 | 39 | def stop(self) -> None: 40 | for job in self._jobs: 41 | job.stop() 42 | 43 | def join(self, seconds: Optional[float] = None) -> None: 44 | ts = time.time() 45 | for job in self._jobs: 46 | sec_left = None if seconds is None else seconds - (time.time() - ts) 47 | job.join(sec_left) 48 | 49 | def pause(self) -> None: 50 | for job in self._jobs: 51 | job.pause() 52 | 53 | def resume(self) -> None: 54 | for job in self._jobs: 55 | job.resume() 56 | -------------------------------------------------------------------------------- /src/neptune/internal/extensions.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["load_extensions"] 17 | 18 | import sys 19 | from importlib.metadata import entry_points 20 | from typing import ( 21 | Callable, 22 | List, 23 | Tuple, 24 | ) 25 | 26 | from neptune.internal.warnings import ( 27 | NeptuneWarning, 28 | warn_once, 29 | ) 30 | 31 | 32 | def get_entry_points(name: str) -> List[Tuple[str, Callable[[], None]]]: 33 | if sys.version_info < (3, 10): 34 | return [(entry_point.name, entry_point.load()) for entry_point in entry_points().get(name, tuple())] 35 | return [ 36 | (entry_point.name, entry_point.load()) # type: ignore[unused-ignore, attr-defined] 37 | for entry_point in entry_points(group=name) # type: ignore[unused-ignore, call-arg] 38 | ] 39 | 40 | 41 | def load_extensions() -> None: 42 | for entry_point_name, loaded_extension in get_entry_points(name="neptune.extensions"): 43 | try: 44 | _ = loaded_extension() 45 | except Exception as e: 46 | warn_once( 47 | message=f"Failed to load neptune extension `{entry_point_name}` with exception: {e}", 48 | exception=NeptuneWarning, 49 | ) 50 | -------------------------------------------------------------------------------- /src/neptune/api/pagination.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ("paginate_over",) 17 | 18 | import abc 19 | from dataclasses import dataclass 20 | from typing import ( 21 | Any, 22 | Callable, 23 | Iterable, 24 | Iterator, 25 | Optional, 26 | TypeVar, 27 | ) 28 | 29 | from typing_extensions import Protocol 30 | 31 | from neptune.api.models import NextPage 32 | 33 | 34 | @dataclass 35 | class WithPagination(abc.ABC): 36 | next_page: Optional[NextPage] 37 | 38 | 39 | T = TypeVar("T", bound=WithPagination) 40 | Entry = TypeVar("Entry") 41 | 42 | 43 | class Paginatable(Protocol): 44 | def __call__(self, *, next_page: Optional[NextPage] = None, **kwargs: Any) -> Any: ... 45 | 46 | 47 | def paginate_over( 48 | getter: Paginatable, 49 | extract_entries: Callable[[T], Iterable[Entry]], 50 | **kwargs: Any, 51 | ) -> Iterator[Entry]: 52 | """ 53 | Generic approach to pagination via `NextPage` 54 | """ 55 | data = getter(**kwargs, next_page=None) 56 | yield from extract_entries(data) 57 | 58 | while data.next_page is not None and data.next_page.next_page_token is not None: 59 | data = getter(**kwargs, next_page=data.next_page) 60 | yield from extract_entries(data) 61 | -------------------------------------------------------------------------------- /src/neptune/types/value_copy.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["ValueCopy"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.internal.utils.paths import parse_path 25 | from neptune.types.value import Value 26 | 27 | if TYPE_CHECKING: 28 | from neptune.handler import Handler 29 | from neptune.types.value_visitor import ValueVisitor 30 | 31 | Ret = TypeVar("Ret") 32 | 33 | 34 | @dataclass 35 | class ValueCopy(Value): 36 | 37 | source_handler: "Handler" 38 | 39 | def __init__(self, source_handler: "Handler"): 40 | self.source_handler = source_handler 41 | 42 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 43 | source_path = self.source_handler._path 44 | source_attr = self.source_handler._container.get_attribute(source_path) 45 | if source_attr and source_attr.supports_copy: 46 | return visitor.copy_value(source_type=type(source_attr), source_path=parse_path(source_path)) 47 | else: 48 | raise Exception(f"{type(source_attr).__name__} doesn't support copying") 49 | 50 | def __str__(self): 51 | return "Copy({})".format(str(self.source_handler)) 52 | -------------------------------------------------------------------------------- /src/neptune/internal/backends/project_name_lookup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["project_name_lookup"] 17 | 18 | import os 19 | from typing import Optional 20 | 21 | from neptune.envs import PROJECT_ENV_NAME 22 | from neptune.exceptions import NeptuneMissingProjectNameException 23 | from neptune.internal.backends.api_model import Project 24 | from neptune.internal.backends.neptune_backend import NeptuneBackend 25 | from neptune.internal.id_formats import QualifiedName 26 | from neptune.internal.utils import verify_type 27 | from neptune.internal.utils.logger import get_logger 28 | 29 | _logger = get_logger() 30 | 31 | 32 | def project_name_lookup(backend: NeptuneBackend, name: Optional[QualifiedName] = None) -> Project: 33 | verify_type("name", name, (str, type(None))) 34 | 35 | if not name: 36 | name = os.getenv(PROJECT_ENV_NAME) 37 | if not name: 38 | available_workspaces = backend.get_available_workspaces() 39 | available_projects = backend.get_available_projects() 40 | 41 | raise NeptuneMissingProjectNameException( 42 | available_workspaces=available_workspaces, 43 | available_projects=available_projects, 44 | ) 45 | 46 | return backend.get_project(name) 47 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import ssl 17 | import sys 18 | 19 | from neptune.internal.utils.logger import get_logger 20 | 21 | _logger = get_logger() 22 | 23 | IS_WINDOWS = sys.platform == "win32" 24 | IS_MACOS = sys.platform == "darwin" 25 | 26 | 27 | def reset_internal_ssl_state(): 28 | """ 29 | OpenSSL's internal random number generator does not properly handle forked processes. 30 | Applications must change the PRNG state of the parent process if they use any SSL feature with os.fork(). 31 | Any successful call of RAND_add(), RAND_bytes() or RAND_pseudo_bytes() is sufficient. 32 | https://docs.python.org/3/library/ssl.html#multi-processing 33 | """ 34 | ssl.RAND_bytes(100) 35 | 36 | 37 | def update_session_proxies(session, proxies): 38 | if proxies is not None: 39 | try: 40 | session.proxies.update(proxies) 41 | except (TypeError, ValueError): 42 | raise ValueError("Wrong proxies format: {}".format(proxies)) 43 | 44 | 45 | def is_ipython(): 46 | try: 47 | import IPython 48 | 49 | ipython = IPython.core.getipython.get_ipython() 50 | return ipython is not None 51 | except ImportError: 52 | return False 53 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/utils/test_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | import unittest 18 | 19 | from neptune.internal.utils import ( 20 | verify_collection_type, 21 | verify_type, 22 | ) 23 | 24 | 25 | class TestUtils(unittest.TestCase): 26 | def test_verify_type(self): 27 | verify_type("arg", "string", str) 28 | 29 | def test_verify_type_failed(self): 30 | with self.assertRaises(TypeError): 31 | verify_type("arg", 5, str) 32 | 33 | def test_verify_type_tuple(self): 34 | verify_type("arg", "string", (int, float, str)) 35 | 36 | def test_verify_type_tuple_failed(self): 37 | with self.assertRaises(TypeError): 38 | verify_type("arg", 5, (str, type(None), float)) 39 | 40 | def test_verify_collection_type(self): 41 | verify_collection_type("arg", ["string", "aaa", 5, 1, "q"], (int, str)) 42 | 43 | def test_verify_collection_type_failed(self): 44 | with self.assertRaises(TypeError): 45 | verify_collection_type("arg", "string", (int, str)) 46 | 47 | def test_verify_collection_type_failed_element(self): 48 | with self.assertRaises(TypeError): 49 | verify_collection_type("arg", ["string", 3, "a", 4.0, 1], (int, str)) 50 | -------------------------------------------------------------------------------- /src/neptune/internal/backends/factory.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["get_backend"] 17 | 18 | from typing import Optional 19 | 20 | from neptune.internal.credentials import Credentials 21 | from neptune.objects.mode import Mode 22 | 23 | from .hosted_neptune_backend import HostedNeptuneBackend 24 | from .neptune_backend import NeptuneBackend 25 | from .neptune_backend_mock import NeptuneBackendMock 26 | from .offline_neptune_backend import OfflineNeptuneBackend 27 | 28 | 29 | def get_backend(mode: Mode, api_token: Optional[str] = None, proxies: Optional[dict] = None) -> NeptuneBackend: 30 | if mode == Mode.ASYNC: 31 | return HostedNeptuneBackend(credentials=Credentials.from_token(api_token=api_token), proxies=proxies) 32 | elif mode == Mode.SYNC: 33 | return HostedNeptuneBackend(credentials=Credentials.from_token(api_token=api_token), proxies=proxies) 34 | elif mode == Mode.DEBUG: 35 | return NeptuneBackendMock() 36 | elif mode == Mode.OFFLINE: 37 | return OfflineNeptuneBackend() 38 | elif mode == Mode.READ_ONLY: 39 | return HostedNeptuneBackend(credentials=Credentials.from_token(api_token=api_token), proxies=proxies) 40 | else: 41 | raise ValueError(f"mode should be one of {[m for m in Mode]}") 42 | -------------------------------------------------------------------------------- /src/neptune/api/proto/neptune_pb/api/model/attributes_pb2.pyi: -------------------------------------------------------------------------------- 1 | """ 2 | @generated by mypy-protobuf. Do not edit manually! 3 | isort:skip_file 4 | """ 5 | import builtins 6 | import collections.abc 7 | import google.protobuf.descriptor 8 | import google.protobuf.internal.containers 9 | import google.protobuf.message 10 | import sys 11 | 12 | if sys.version_info >= (3, 8): 13 | import typing as typing_extensions 14 | else: 15 | import typing_extensions 16 | 17 | DESCRIPTOR: google.protobuf.descriptor.FileDescriptor 18 | 19 | @typing_extensions.final 20 | class ProtoAttributesSearchResultDTO(google.protobuf.message.Message): 21 | DESCRIPTOR: google.protobuf.descriptor.Descriptor 22 | 23 | ENTRIES_FIELD_NUMBER: builtins.int 24 | @property 25 | def entries(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ProtoAttributeDefinitionDTO]: ... 26 | def __init__( 27 | self, 28 | *, 29 | entries: collections.abc.Iterable[global___ProtoAttributeDefinitionDTO] | None = ..., 30 | ) -> None: ... 31 | def ClearField(self, field_name: typing_extensions.Literal["entries", b"entries"]) -> None: ... 32 | 33 | global___ProtoAttributesSearchResultDTO = ProtoAttributesSearchResultDTO 34 | 35 | @typing_extensions.final 36 | class ProtoAttributeDefinitionDTO(google.protobuf.message.Message): 37 | DESCRIPTOR: google.protobuf.descriptor.Descriptor 38 | 39 | NAME_FIELD_NUMBER: builtins.int 40 | TYPE_FIELD_NUMBER: builtins.int 41 | name: builtins.str 42 | type: builtins.str 43 | def __init__( 44 | self, 45 | *, 46 | name: builtins.str = ..., 47 | type: builtins.str = ..., 48 | ) -> None: ... 49 | def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "type", b"type"]) -> None: ... 50 | 51 | global___ProtoAttributeDefinitionDTO = ProtoAttributeDefinitionDTO 52 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/api/test_requests_utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from bravado.requests_client import RequestsResponseAdapter 17 | from requests import Response 18 | 19 | from neptune.api.requests_utils import ensure_json_response 20 | 21 | 22 | class TestResponse(Response): 23 | def __init__(self, content: bytes) -> None: 24 | super().__init__() 25 | self._content = content 26 | 27 | 28 | def test_ensure_json_body__if_empty(): 29 | # given 30 | empty_server_response = RequestsResponseAdapter(TestResponse(content=b"")) 31 | 32 | # when 33 | body = ensure_json_response(empty_server_response) 34 | 35 | # then 36 | assert body == {} 37 | 38 | 39 | def test_ensure_json_body__invalid(): 40 | # given 41 | empty_server_response = RequestsResponseAdapter(TestResponse(content=b"deadbeef")) 42 | 43 | # when 44 | body = ensure_json_response(empty_server_response) 45 | 46 | # then 47 | assert body == {} 48 | 49 | 50 | def test_ensure_json_body__standard(): 51 | # given 52 | empty_server_response = RequestsResponseAdapter(TestResponse(content='{"key": "value"}'.encode("utf-8"))) 53 | 54 | # when 55 | body = ensure_json_response(empty_server_response) 56 | 57 | # then 58 | assert body == {"key": "value"} 59 | -------------------------------------------------------------------------------- /.github/actions/test-unit/action.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Test Unit 3 | description: Check unit tests 4 | inputs: 5 | python-version: 6 | description: "Python version" 7 | required: true 8 | os: 9 | description: "Operating system" 10 | required: true 11 | report_job: 12 | description: "Job name to update by JUnit report" 13 | required: true 14 | codecov-token: 15 | description: "Codecov token" 16 | required: false 17 | default: "" 18 | 19 | runs: 20 | using: "composite" 21 | steps: 22 | - name: Install package 23 | uses: ./.github/actions/install-package 24 | with: 25 | python-version: ${{ inputs.python-version }} 26 | os: ${{ inputs.os }}-latest 27 | 28 | - name: Test 29 | run: | 30 | pytest --cov=neptune --cov-report xml \ 31 | -v -n 2 ./tests/unit/ \ 32 | --timeout=120 --timeout_method=thread \ 33 | --color=yes \ 34 | --junitxml="./test-results/test-unit-new-${{ inputs.os }}-${{ inputs.python-version }}.xml" 35 | shell: bash 36 | 37 | - name: Upload test reports 38 | uses: actions/upload-artifact@v4 39 | if: always() 40 | with: 41 | name: test-artifacts-${{ inputs.os }},py${{ inputs.python-version }} 42 | path: ./test-results 43 | 44 | - name: Upload Pull Request coverage report do Codecov 45 | uses: codecov/codecov-action@v3 46 | with: 47 | token: ${{ inputs.codecov-token }} 48 | files: ./coverage.xml 49 | flags: unit,${{ inputs.os }},py${{ inputs.python-version }} 50 | fail_ci_if_error: false 51 | 52 | - name: Report 53 | uses: mikepenz/action-junit-report@v3.6.2 54 | if: always() 55 | with: 56 | report_paths: './test-results/test-unit-*.xml' 57 | update_check: true 58 | include_passed: true 59 | annotate_notice: true 60 | job_name: ${{ inputs.report_job }} 61 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/test_attribute_base.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import random 17 | import time 18 | import unittest 19 | import uuid 20 | from contextlib import contextmanager 21 | from unittest.mock import patch 22 | 23 | from neptune import Run 24 | from neptune.objects.neptune_object import NeptuneObject 25 | 26 | _now = time.time() 27 | 28 | 29 | class TestAttributeBase(unittest.TestCase): 30 | 31 | @staticmethod 32 | @contextmanager 33 | def _exp(): 34 | with patch.object( 35 | NeptuneObject, 36 | "_async_create_run", 37 | lambda self: self._backend._create_container(self._custom_id, self.container_type, self._project_id), 38 | ): 39 | with Run( 40 | mode="debug", 41 | capture_stderr=False, 42 | capture_traceback=False, 43 | capture_stdout=False, 44 | capture_hardware_metrics=False, 45 | ) as exp: 46 | yield exp 47 | 48 | @staticmethod 49 | def _random_path(): 50 | return ["some", "random", "path", str(uuid.uuid4())] 51 | 52 | @staticmethod 53 | def _random_wait(): 54 | return bool(random.getrandbits(1)) 55 | 56 | @staticmethod 57 | def _now(): 58 | return _now 59 | -------------------------------------------------------------------------------- /src/neptune/attributes/atoms/boolean.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Boolean"] 17 | 18 | import typing 19 | 20 | from neptune.attributes.atoms.copiable_atom import CopiableAtom 21 | from neptune.internal.container_type import ContainerType 22 | from neptune.internal.operation import AssignBool 23 | from neptune.types.atoms.boolean import Boolean as BooleanVal 24 | 25 | if typing.TYPE_CHECKING: 26 | from neptune.internal.backends.neptune_backend import NeptuneBackend 27 | 28 | 29 | class Boolean(CopiableAtom): 30 | @staticmethod 31 | def create_assignment_operation(path, value: bool): 32 | return AssignBool(path, value) 33 | 34 | @staticmethod 35 | def getter( 36 | backend: "NeptuneBackend", 37 | container_id: str, 38 | container_type: ContainerType, 39 | path: typing.List[str], 40 | ) -> bool: 41 | val = backend.get_bool_attribute(container_id, container_type, path) 42 | return val.value 43 | 44 | def assign(self, value: typing.Union[BooleanVal, bool], *, wait: bool = False): 45 | if not isinstance(value, BooleanVal): 46 | value = BooleanVal(value) 47 | 48 | with self._container.lock(): 49 | self._enqueue_operation(self.create_assignment_operation(self._path, value.value), wait=wait) 50 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/utils/test_iso_dates.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from datetime import datetime 17 | 18 | import pytest 19 | 20 | from neptune.internal.utils.iso_dates import parse_iso_date 21 | 22 | 23 | def test_parse_iso_dates_if_date_already_is_datetime(): 24 | # Given 25 | date = datetime(2022, 1, 1, 0, 0, 0, 0) 26 | 27 | # When 28 | parsed_date = parse_iso_date(date) 29 | 30 | # Then 31 | assert parsed_date == date 32 | 33 | 34 | @pytest.mark.parametrize("date", ["2022-01-01", "2022-01-01T00:00:00", "2022-01-01-00:00:00.000Z", "0-01-01-00:00:00Z"]) 35 | def test_parse_iso_date_with_incorrect_date_format(date: str): 36 | # Then 37 | with pytest.raises(ValueError): 38 | parse_iso_date(date) 39 | 40 | 41 | def test_parse_iso_date_with_correct_date_format(): 42 | # Given 43 | date_strings = ["2024-01-01T00:00:00.000Z", "1000-01-01T13:00:00.000Z", "3000-01-01T00:00:00Z"] 44 | expected_dates = [ 45 | datetime(2024, 1, 1, 0, 0, 0, 0), 46 | datetime(1000, 1, 1, 13, 0, 0, 0), 47 | datetime(3000, 1, 1, 0, 0, 0), 48 | ] 49 | 50 | for date, expected in zip(date_strings, expected_dates): 51 | # When 52 | parsed_date = parse_iso_date(date) 53 | 54 | # Then 55 | assert parsed_date == expected 56 | -------------------------------------------------------------------------------- /src/neptune/internal/signals_processing/signals.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = [ 17 | "Signal", 18 | "SignalsVisitor", 19 | "BatchStartedSignal", 20 | "BatchProcessedSignal", 21 | "BatchLagSignal", 22 | ] 23 | 24 | from abc import abstractmethod 25 | from dataclasses import dataclass 26 | 27 | 28 | @dataclass 29 | class Signal: 30 | occured_at: float 31 | 32 | @abstractmethod 33 | def accept(self, visitor: "SignalsVisitor") -> None: ... 34 | 35 | 36 | @dataclass 37 | class BatchStartedSignal(Signal): 38 | def accept(self, visitor: "SignalsVisitor") -> None: 39 | visitor.visit_batch_started(signal=self) 40 | 41 | 42 | @dataclass 43 | class BatchProcessedSignal(Signal): 44 | def accept(self, visitor: "SignalsVisitor") -> None: 45 | visitor.visit_batch_processed(signal=self) 46 | 47 | 48 | @dataclass 49 | class BatchLagSignal(Signal): 50 | lag: float 51 | 52 | def accept(self, visitor: "SignalsVisitor") -> None: 53 | visitor.visit_batch_lag(signal=self) 54 | 55 | 56 | class SignalsVisitor: 57 | @abstractmethod 58 | def visit_batch_started(self, signal: Signal) -> None: ... 59 | 60 | @abstractmethod 61 | def visit_batch_processed(self, signal: Signal) -> None: ... 62 | 63 | @abstractmethod 64 | def visit_batch_lag(self, signal: Signal) -> None: ... 65 | -------------------------------------------------------------------------------- /src/neptune/core/operations/operation_visitor.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["OperationVisitor"] 17 | 18 | import abc 19 | from typing import ( 20 | Generic, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.core.operations.operation import ( 25 | AssignBool, 26 | AssignDatetime, 27 | AssignFloat, 28 | AssignInt, 29 | AssignString, 30 | LogFloats, 31 | Operation, 32 | RunCreation, 33 | ) 34 | 35 | Ret = TypeVar("Ret") 36 | 37 | 38 | class OperationVisitor(Generic[Ret]): 39 | def visit(self, op: Operation) -> Ret: 40 | return op.accept(self) 41 | 42 | @abc.abstractmethod 43 | def visit_assign_float(self, op: AssignFloat) -> Ret: 44 | pass 45 | 46 | @abc.abstractmethod 47 | def visit_assign_int(self, op: AssignInt) -> Ret: 48 | pass 49 | 50 | @abc.abstractmethod 51 | def visit_assign_bool(self, op: AssignBool) -> Ret: 52 | pass 53 | 54 | @abc.abstractmethod 55 | def visit_assign_string(self, op: AssignString) -> Ret: 56 | pass 57 | 58 | @abc.abstractmethod 59 | def visit_assign_datetime(self, op: AssignDatetime) -> Ret: 60 | pass 61 | 62 | @abc.abstractmethod 63 | def visit_log_floats(self, op: LogFloats) -> Ret: 64 | pass 65 | 66 | @abc.abstractmethod 67 | def visit_run_creation(self, op: RunCreation) -> Ret: 68 | pass 69 | -------------------------------------------------------------------------------- /src/neptune/types/namespace.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["Namespace"] 17 | 18 | from dataclasses import dataclass 19 | from typing import ( 20 | TYPE_CHECKING, 21 | TypeVar, 22 | ) 23 | 24 | from neptune.internal.utils.logger import get_logger 25 | from neptune.internal.utils.paths import parse_path 26 | from neptune.types.value import Value 27 | 28 | if TYPE_CHECKING: 29 | from neptune.types.value_visitor import ValueVisitor 30 | 31 | logger = get_logger() 32 | Ret = TypeVar("Ret") 33 | 34 | 35 | @dataclass 36 | class Namespace(Value): 37 | 38 | value: dict 39 | 40 | def __init__(self, value): 41 | self.value = value 42 | empty_keys = [k for k in self.value.keys() if not parse_path(k)] 43 | if empty_keys: 44 | all_keys = ", ".join(['"' + k + '"' for k in empty_keys]) 45 | logger.warning( 46 | f"Key(s) {all_keys} can't be used in Namespaces and dicts stored in Neptune. Please use non-empty " 47 | f"keys instead. The value(s) will be dropped.", 48 | ) 49 | self.value = value.copy() 50 | [self.value.pop(key) for key in empty_keys] 51 | 52 | def accept(self, visitor: "ValueVisitor[Ret]") -> Ret: 53 | return visitor.visit_namespace(self) 54 | 55 | def __str__(self): 56 | return "Namespace({})".format(str(self.value)) 57 | -------------------------------------------------------------------------------- /src/neptune/internal/backends/hosted_neptune_backend_v2.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2024, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | from __future__ import annotations 17 | 18 | __all__ = ["HostedNeptuneBackendV2"] 19 | 20 | 21 | from typing import cast 22 | 23 | from neptune_api.api.backend import get_project 24 | from neptune_api.credentials import Credentials 25 | from neptune_api.models import ( 26 | Error, 27 | ProjectDTO, 28 | ) 29 | from neptune_api.types import Response 30 | 31 | from neptune.internal.backends.api_client import ( 32 | create_auth_api_client, 33 | get_config_and_token_urls, 34 | ) 35 | from neptune.internal.id_formats import QualifiedName 36 | 37 | 38 | class HostedNeptuneBackendV2: 39 | def __init__(self, credentials: Credentials) -> None: 40 | self.credentials = credentials 41 | 42 | config, token_urls = get_config_and_token_urls(self.credentials) 43 | self.auth_client = create_auth_api_client(credentials, config, token_urls) 44 | 45 | # only happy path is implemented 46 | def get_project(self, project_identifier: QualifiedName) -> ProjectDTO: 47 | response: Response[Error | ProjectDTO] = get_project.sync_detailed( 48 | client=self.auth_client, project_identifier=project_identifier 49 | ) 50 | if response.parsed is None: 51 | raise RuntimeError(response.content.decode("utf-8")) 52 | return cast(ProjectDTO, response.parsed) 53 | -------------------------------------------------------------------------------- /src/neptune/internal/signals_processing/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["signal_batch_processed", "signal_batch_started", "signal_batch_lag"] 17 | 18 | from queue import ( 19 | Full, 20 | Queue, 21 | ) 22 | from time import monotonic 23 | from typing import Optional 24 | 25 | from neptune.internal.signals_processing.signals import ( 26 | BatchLagSignal, 27 | BatchProcessedSignal, 28 | BatchStartedSignal, 29 | Signal, 30 | ) 31 | from neptune.internal.warnings import ( 32 | NeptuneWarning, 33 | warn_once, 34 | ) 35 | 36 | 37 | def signal(*, queue: "Queue[Signal]", obj: "Signal") -> None: 38 | try: 39 | queue.put_nowait(item=obj) 40 | except Full: 41 | warn_once("Signal queue is full. Some signals will be lost.", exception=NeptuneWarning) 42 | 43 | 44 | def signal_batch_started(*, queue: "Queue[Signal]", occured_at: Optional[float] = None) -> None: 45 | signal(queue=queue, obj=BatchStartedSignal(occured_at=occured_at or monotonic())) 46 | 47 | 48 | def signal_batch_processed(*, queue: "Queue[Signal]", occured_at: Optional[float] = None) -> None: 49 | signal(queue=queue, obj=BatchProcessedSignal(occured_at=occured_at or monotonic())) 50 | 51 | 52 | def signal_batch_lag(*, queue: "Queue[Signal]", lag: float, occured_at: Optional[float] = None) -> None: 53 | signal(queue=queue, obj=BatchLagSignal(occured_at=occured_at or monotonic(), lag=lag)) 54 | -------------------------------------------------------------------------------- /src/neptune/core/components/queue/sync_offset_file.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["SyncOffsetFile"] 17 | 18 | import os 19 | from pathlib import Path 20 | from typing import IO 21 | 22 | from neptune.core.components.abstract import Resource 23 | 24 | 25 | class SyncOffsetFile(Resource): 26 | def __init__(self, path: Path, default: int = 0): 27 | self._path = path 28 | mode = "r+" if path.exists() else "w+" 29 | self._file: IO = open(self._path, mode) 30 | self._default: int = default 31 | self._last: int = self.read() 32 | 33 | @property 34 | def data_path(self) -> Path: 35 | return self._path.parent 36 | 37 | def write(self, offset: int) -> None: 38 | self._file.seek(0) 39 | self._file.write(str(offset)) 40 | self._file.truncate() 41 | self._file.flush() 42 | self._last = offset 43 | 44 | def read(self) -> int: 45 | self._file.seek(0) 46 | content = self._file.read() 47 | if not content: 48 | return self._default 49 | return int(content) 50 | 51 | def read_local(self) -> int: 52 | return self._last 53 | 54 | def flush(self) -> None: 55 | self._file.flush() 56 | 57 | def close(self) -> None: 58 | self._file.close() 59 | 60 | def cleanup(self) -> None: 61 | try: 62 | os.remove(self._path) 63 | except OSError: 64 | pass 65 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/internal/utils/test_iteration.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import unittest 17 | 18 | from neptune.internal.utils.iteration import get_batches 19 | 20 | 21 | class TestIterationUtils(unittest.TestCase): 22 | def test_get_batches(self): 23 | self.assertEqual([[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]], list(get_batches(range(10), batch_size=3))) 24 | self.assertEqual([[0, 1, 2], [3, 4, 5], [6, 7, 8]], list(get_batches(range(9), batch_size=3))) 25 | self.assertEqual([[1], [2], [3]], list(get_batches([1, 2, 3], batch_size=1))) 26 | self.assertEqual([[1], [2], [3]], list(get_batches(iter([1, 2, 3]), batch_size=1))) 27 | self.assertEqual([[1, 2, 3]], list(get_batches([1, 2, 3], batch_size=100))) 28 | 29 | with self.assertRaises(AssertionError): 30 | next(get_batches([1, 2, 3], batch_size=0)) 31 | 32 | # but generator itself doesn't raise error untill used 33 | get_batches([1, 2, 3], batch_size=0) 34 | 35 | def test_batch_lists(self): 36 | list_of_lists = (list(range(i)) for i in range(10)) 37 | expected_batched = [ 38 | [[], [0], [0, 1]], 39 | [[0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4]], 40 | [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 7]], 41 | [[0, 1, 2, 3, 4, 5, 6, 7, 8]], 42 | ] 43 | self.assertEqual(expected_batched, list(get_batches(list_of_lists, batch_size=3))) 44 | -------------------------------------------------------------------------------- /src/neptune/attributes/utils.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["create_attribute_from_type"] 17 | 18 | from typing import ( 19 | TYPE_CHECKING, 20 | List, 21 | ) 22 | 23 | from neptune.api.models import FieldType 24 | from neptune.attributes import ( 25 | Boolean, 26 | Datetime, 27 | Float, 28 | FloatSeries, 29 | Integer, 30 | NotebookRef, 31 | RunState, 32 | String, 33 | StringSeries, 34 | StringSet, 35 | ) 36 | from neptune.internal.exceptions import InternalClientError 37 | 38 | if TYPE_CHECKING: 39 | from neptune.attributes.attribute import Attribute 40 | from neptune.objects import NeptuneObject 41 | 42 | _attribute_type_to_attr_class_map = { 43 | FieldType.FLOAT: Float, 44 | FieldType.INT: Integer, 45 | FieldType.BOOL: Boolean, 46 | FieldType.STRING: String, 47 | FieldType.DATETIME: Datetime, 48 | FieldType.FLOAT_SERIES: FloatSeries, 49 | FieldType.STRING_SERIES: StringSeries, 50 | FieldType.STRING_SET: StringSet, 51 | FieldType.OBJECT_STATE: RunState, 52 | FieldType.NOTEBOOK_REF: NotebookRef, 53 | } 54 | 55 | 56 | def create_attribute_from_type( 57 | attribute_type: FieldType, 58 | container: "NeptuneObject", 59 | path: List[str], 60 | ) -> "Attribute": 61 | try: 62 | return _attribute_type_to_attr_class_map[attribute_type](container, path) 63 | except KeyError: 64 | raise InternalClientError(f"Unexpected type: {attribute_type}") 65 | 66 | 67 | def delayed_(): 68 | pass 69 | -------------------------------------------------------------------------------- /src/neptune/internal/utils/process_killer.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2022, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | __all__ = ["kill_me"] 17 | 18 | import os 19 | import signal 20 | 21 | from neptune.envs import NEPTUNE_SUBPROCESS_KILL_TIMEOUT 22 | 23 | try: 24 | import psutil 25 | 26 | PSUTIL_INSTALLED = True 27 | except ImportError: 28 | PSUTIL_INSTALLED = False 29 | 30 | 31 | KILL_TIMEOUT = int(os.getenv(NEPTUNE_SUBPROCESS_KILL_TIMEOUT, "5")) 32 | 33 | 34 | def kill_me(): 35 | if PSUTIL_INSTALLED: 36 | process = psutil.Process(os.getpid()) 37 | try: 38 | children = _get_process_children(process) 39 | except psutil.NoSuchProcess: 40 | children = [] 41 | 42 | for child_proc in children: 43 | _terminate(child_proc) 44 | _, alive = psutil.wait_procs(children, timeout=KILL_TIMEOUT) 45 | for child_proc in alive: 46 | _kill(child_proc) 47 | # finish with terminating self 48 | _terminate(process) 49 | else: 50 | os.kill(os.getpid(), signal.SIGINT) 51 | 52 | 53 | def _terminate(process): 54 | try: 55 | process.terminate() 56 | except psutil.NoSuchProcess: 57 | pass 58 | 59 | 60 | def _kill(process): 61 | try: 62 | if process.is_running(): 63 | process.kill() 64 | except psutil.NoSuchProcess: 65 | pass 66 | 67 | 68 | def _get_process_children(process): 69 | try: 70 | return process.children(recursive=True) 71 | except psutil.NoSuchProcess: 72 | return [] 73 | -------------------------------------------------------------------------------- /tests/unit/neptune/new/attributes/atoms/test_string.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020, Neptune Labs Sp. z o.o. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | import pytest 17 | from mock import ( 18 | MagicMock, 19 | patch, 20 | ) 21 | 22 | from neptune.attributes.atoms.string import ( 23 | String, 24 | StringVal, 25 | ) 26 | from neptune.internal.operation import AssignString 27 | from tests.unit.neptune.new.attributes.test_attribute_base import TestAttributeBase 28 | 29 | 30 | class TestString(TestAttributeBase): 31 | @patch("neptune.objects.neptune_object.get_operation_processor") 32 | def test_assign(self, get_operation_processor): 33 | processor = MagicMock() 34 | get_operation_processor.return_value = processor 35 | 36 | value_and_expected = [ 37 | ("qwertyu", "qwertyu"), 38 | (StringVal("Some string"), "Some string"), 39 | ] 40 | 41 | for value, expected in value_and_expected: 42 | path, wait = ( 43 | self._random_path(), 44 | self._random_wait(), 45 | ) 46 | with self._exp() as exp: 47 | var = String(exp, path) 48 | var.assign(value, wait=wait) 49 | processor.enqueue_operation.assert_called_with(AssignString(path, expected), wait=wait) 50 | 51 | @pytest.mark.skip(reason="Backend not implemented") 52 | def test_get(self): 53 | with self._exp() as exp: 54 | var = String(exp, self._random_path()) 55 | var.assign("adfh") 56 | self.assertEqual("adfh", var.fetch()) 57 | --------------------------------------------------------------------------------