From 61355a819fdd1c8d7a3c24025f261369d43eb133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 01:12:21 +0200 Subject: [PATCH 1/8] use py-template --- .cruft.json | 23 + .gitattributes | 1 + .github/dependabot.yml | 29 ++ .github/workflows/package.yaml | 26 - .github/workflows/release.yml | 38 ++ .github/workflows/tests.yaml | 54 -- .github/workflows/tests.yml | 63 +++ .github/workflows/update-template.yaml | 16 + .gitignore | 100 +++- .pre-commit-config.yaml | 65 ++- .pre-commit-hooks.yaml | 12 - .pylintrc | 607 ---------------------- CODE_OF_CONDUCT.md | 76 --- CODE_OF_CONDUCT.rst | 105 ++++ CONTRIBUTING.md | 81 --- CONTRIBUTING.rst | 109 ++++ LICENSE | 4 +- README.rst | 100 ++-- dvclive/__init__.py | 3 - dvclive/version.py | 69 --- noxfile.py | 62 +++ pyproject.toml | 65 +++ scripts/build_package.sh | 12 - setup.cfg | 116 ++++- setup.py | 108 ---- src/dvclive/__init__.py | 1 + {dvclive => src/dvclive}/catalyst.py | 0 {dvclive => src/dvclive}/data/__init__.py | 0 {dvclive => src/dvclive}/data/base.py | 0 {dvclive => src/dvclive}/data/image.py | 0 {dvclive => src/dvclive}/data/plot.py | 0 {dvclive => src/dvclive}/data/scalar.py | 0 {dvclive => src/dvclive}/data/utils.py | 0 {dvclive => src/dvclive}/dvc.py | 0 {dvclive => src/dvclive}/env.py | 0 {dvclive => src/dvclive}/error.py | 0 {dvclive => src/dvclive}/fastai.py | 0 {dvclive => src/dvclive}/huggingface.py | 0 {dvclive => src/dvclive}/keras.py | 0 {dvclive => src/dvclive}/lgbm.py | 0 {dvclive => src/dvclive}/lightning.py | 0 {dvclive => src/dvclive}/live.py | 0 {dvclive => src/dvclive}/report.py | 0 {dvclive => src/dvclive}/utils.py | 0 {dvclive => src/dvclive}/xgb.py | 0 45 files changed, 823 insertions(+), 1122 deletions(-) create mode 100644 .cruft.json create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/package.yaml create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tests.yaml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/update-template.yaml delete mode 100644 .pre-commit-hooks.yaml delete mode 100644 .pylintrc delete mode 100644 CODE_OF_CONDUCT.md create mode 100644 CODE_OF_CONDUCT.rst delete mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTING.rst delete mode 100644 dvclive/__init__.py delete mode 100644 dvclive/version.py create mode 100644 noxfile.py delete mode 100755 scripts/build_package.sh delete mode 100644 setup.py create mode 100644 src/dvclive/__init__.py rename {dvclive => src/dvclive}/catalyst.py (100%) rename {dvclive => src/dvclive}/data/__init__.py (100%) rename {dvclive => src/dvclive}/data/base.py (100%) rename {dvclive => src/dvclive}/data/image.py (100%) rename {dvclive => src/dvclive}/data/plot.py (100%) rename {dvclive => src/dvclive}/data/scalar.py (100%) rename {dvclive => src/dvclive}/data/utils.py (100%) rename {dvclive => src/dvclive}/dvc.py (100%) rename {dvclive => src/dvclive}/env.py (100%) rename {dvclive => src/dvclive}/error.py (100%) rename {dvclive => src/dvclive}/fastai.py (100%) rename {dvclive => src/dvclive}/huggingface.py (100%) rename {dvclive => src/dvclive}/keras.py (100%) rename {dvclive => src/dvclive}/lgbm.py (100%) rename {dvclive => src/dvclive}/lightning.py (100%) rename {dvclive => src/dvclive}/live.py (100%) rename {dvclive => src/dvclive}/report.py (100%) rename {dvclive => src/dvclive}/utils.py (100%) rename {dvclive => src/dvclive}/xgb.py (100%) diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 00000000..2b4ce6bb --- /dev/null +++ b/.cruft.json @@ -0,0 +1,23 @@ +{ + "template": "https://github.com/iterative/py-template", + "commit": "9d2e2863ebeea39f1ac27523c939fc7a6743a3b4", + "checkout": null, + "context": { + "cookiecutter": { + "project_name": "dvclive", + "package_name": "dvclive", + "friendly_name": "dvclive", + "author": "Paweł Redzyński", + "email": "pawel@iterative.ai", + "github_user": "iterative", + "version": "0.0.0", + "copyright_year": "2022", + "license": "Apache-2.0", + "docs": "False", + "short_description": "Metric logger for ML projects.", + "development_status": "Development Status :: 4 - Beta", + "_template": "https://github.com/iterative/py-template" + } + }, + "directory": null +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..56f6f984 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +version: 2 + +updates: + - directory: "/" + package-ecosystem: "pip" + schedule: + interval: "weekly" + labels: + - "maintenance" + # Update via cruft + ignore: + - dependency-name: "mkdocs*" + - dependency-name: "pytest*" + - dependency-name: "pylint" + - dependency-name: "mypy" + + - directory: "/" + package-ecosystem: "github-actions" + schedule: + interval: "weekly" + labels: + - "maintenance" + # Update via cruft + ignore: + - dependency-name: "actions/checkout" + - dependency-name: "actions/setup-python" + - dependency-name: "pypa/gh-action-pypi-publish" + - dependency-name: "codecov/codecov-action" + - dependency-name: "peter-evans/create-pull-request" diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml deleted file mode 100644 index fa394692..00000000 --- a/.github/workflows/package.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build packages -on: - push: - branches: - - main - release: - types: [released, prereleased] - -jobs: - python: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2.3.2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2.1.4 - with: - python-version: 3.8 - - name: Install - run: pip install ".[all,tests]" - - name: Build packages - run: ./scripts/build_package.sh - - name: Publish packages to PyPI - if: github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..bfee8dfd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + release: + types: [published] + workflow_dispatch: + +env: + FORCE_COLOR: "1" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Upgrade pip and nox + run: | + pip install --upgrade pip nox + pip --version + nox --version + + - name: Build package + run: nox -s build + + - name: Upload package + if: github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index d1c2f501..00000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: tests - -on: - pull_request: - branches: - - main - push: - branches: - - main - -jobs: - code-check: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2.3.2 - - name: set up Python 3.8 - uses: actions/setup-python@v2.1.4 - with: - python-version: 3.8 - - name: install requirements - run: pip install ".[tests]" collective.checkdocs --use-deprecated=legacy-resolver - - name: Check README - run: python setup.py checkdocs - - name: check formatting - run: pre-commit run --all-files - tests: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-18.04, windows-2019, macos-10.15] - pyv: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v2.3.2 - - name: set up python - uses: actions/setup-python@v2.1.4 - with: - python-version: ${{ matrix.pyv }} - - name: install - run: pip install wheel ".[tests]" --use-deprecated=legacy-resolver - - name: install libomp - # required for xgboost - if: runner.os == 'macOS' - run: | - wget https://raw.githubusercontent.com/Homebrew/homebrew-core/679923b4eb48a8dc7ecc1f05d06063cd79b3fc00/Formula/libomp.rb -O $(find $(brew --repository) -name libomp.rb) - brew install ninja libomp - brew pin libomp - - name: run tests - run: py.test -v --cov dvclive --cov-report=xml - - name: upload coverage report - uses: codecov/codecov-action@v1.0.13 - with: - file: ./coverage.xml - fail_ci_if_error: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..0932393b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,63 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +env: + FORCE_COLOR: "1" + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + tests: + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, windows-latest, macos-latest] + pyv: ["3.8", "3.9", "3.10"] + include: + - { os: ubuntu-latest, pyv: "pypy3.8" } + - { os: ubuntu-latest, pyv: "3.11.0-rc - 3.11", nox_pyv: "3.11" } + + steps: + - name: Check out the repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.pyv }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.pyv }} + + - name: Upgrade pip and nox + run: | + python -m pip install --upgrade pip nox + pip --version + nox --version + + - name: install libomp + # required for xgboost + if: runner.os == 'macOS' + run: | + wget https://raw.githubusercontent.com/Homebrew/homebrew-core/679923b4eb48a8dc7ecc1f05d06063cd79b3fc00/Formula/libomp.rb -O $(find $(brew --repository) -name libomp.rb) + brew install ninja libomp + brew pin libomp + - name: Lint code and check dependencies + run: nox -s lint safety + + - name: Run tests + run: nox -s tests-${{ matrix.nox_pyv || matrix.pyv }} -- --cov-report=xml + + - name: Upload coverage report + uses: codecov/codecov-action@v3.1.0 + + - name: Build package + run: nox -s build diff --git a/.github/workflows/update-template.yaml b/.github/workflows/update-template.yaml new file mode 100644 index 00000000..d99ea98b --- /dev/null +++ b/.github/workflows/update-template.yaml @@ -0,0 +1,16 @@ +name: Update template + +on: + schedule: + - cron: '5 1 * * *' # every day at 01:05 + workflow_dispatch: + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: iterative/py-template@main diff --git a/.gitignore b/.gitignore index 622b336c..a81c8ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,10 +26,85 @@ share/python-wheels/ *.egg MANIFEST +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + # Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ .pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py -# ENV +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments .env .venv env/ @@ -38,9 +113,26 @@ ENV/ env.bak/ venv.bak/ +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + # mypy .mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ -# Editor -.vscode/ -.idea/ \ No newline at end of file +# Cython debug symbols +cython_debug/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 88c36202..0b52d4f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,47 @@ -ci: - skip: [pylint] - +default_language_version: + python: python3 repos: - - hooks: - - id: black - language_version: python3 - repo: https://github.com/ambv/black + - repo: https://github.com/psf/black rev: 22.6.0 - - hooks: - - id: isort - language_version: python3 - repo: https://github.com/timothycrosley/isort + hooks: + - id: black + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + args: ['--assume-in-merge'] + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + args: ['--fix=lf'] + - id: sort-simple-yaml + - id: trailing-whitespace + - repo: https://github.com/codespell-project/codespell + rev: v2.2.1 + hooks: + - id: codespell + - repo: https://github.com/asottile/pyupgrade + rev: v2.37.3 + hooks: + - id: pyupgrade + - repo: https://github.com/PyCQA/isort rev: 5.10.1 - - hooks: - - id: flake8 - language_version: python3 - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 - - repo: local hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] + - id: isort + - repo: https://gitlab.com/pycqa/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + additional_dependencies: + - flake8-broken-line==0.5.0 + - flake8-bugbear==22.8.23 + - flake8-comprehensions==3.10.0 + - flake8-debugger==4.1.2 + - flake8-string-format==0.3.0 diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml deleted file mode 100644 index 61b6cb24..00000000 --- a/.pre-commit-hooks.yaml +++ /dev/null @@ -1,12 +0,0 @@ -- args: - - git-hook - - pre-commit - entry: dvclive - id: dvclive-pre-commit - language: python - language_version: python3 - name: dvclive pre-commit - require_serial: true - stages: - - commit - verbose: true \ No newline at end of file diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 1049a671..00000000 --- a/.pylintrc +++ /dev/null @@ -1,607 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-whitelist= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -init-hook="import sys; \ - from pathlib import Path; \ - from pylint.config import find_pylintrc; \ - sys.path.append(Path(find_pylintrc()).parent / 'tests');" - - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=1 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -#load-plugins=pylint_plugin_disable - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=format, - # ^ most of them are covered by flake8, - # and are conventions rather than warnings or errors - refactoring, # will be noisy if it starts giving suggestions - spelling, - # design is too-few-* and too-many-* checks, too-much-* for us right now - design, - # following were generated by default - # most of them are redundant Py3 checks for Py2+3 codebase - print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, - # custom disables start here - no-self-use, - invalid-name, - # already a check enabled for `wildcard-import` - unused-wildcard-import, - misplaced-comparison-constant, - # probably soon: https://github.com/iterative/dvc/issues/1843 - logging-format-interpolation, - logging-fstring-interpolation, - # we don't have proper docstrings yet - # even if we do, we'll be doing it gradually - missing-function-docstring, - missing-module-docstring, - missing-class-docstring, - duplicate-code, - # too noisy, and detects issues even when import is inside a function - # see: https://github.com/PyCQA/pylint/issues/850 - cyclic-import, - # isort should cover these: - wrong-import-order, - wrong-import-position, - ungrouped-imports, - multiple-imports, - # we use it to speedup/optimize - import-outside-toplevel, - protected-access - - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[LOGGING] - -# Format style used to check logging format string. `old` means using % -# formatting, while `new` is for `{}` formatting. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package.. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=pytest.lazy_fixture,logging.TRACE,logger.trace,sys.getwindowsversion,torch.* - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local,Dvcfile - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.*|^ignored_|^unused_|args|kwargs - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=79 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -#argument-rgx= - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -#class-attribute-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -#class-rgx= - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _, - s3, - gs, - x, y, - x0, y0, - x1, y1, - dx, dy - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -#inlinevar-rgx= - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -#method-rgx= - -# Naming style matching correct module names. -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style. -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -#variable-rgx= - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement. -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=12 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception". -overgeneral-exceptions=Exception diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index c66fa0c9..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at info@dvc.org. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 00000000..9d4aa7d9 --- /dev/null +++ b/CODE_OF_CONDUCT.rst @@ -0,0 +1,105 @@ +Contributor Covenant Code of Conduct +==================================== + +Our Pledge +---------- + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + + +Our Standards +------------- + +Examples of behavior that contributes to a positive environment for our community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +Enforcement Responsibilities +---------------------------- + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + + +Scope +----- + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + + +Enforcement +----------- + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at pawel@iterative.ai. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + + +Enforcement Guidelines +---------------------- + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + + +1. Correction +~~~~~~~~~~~~~ + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + + +2. Warning +~~~~~~~~~~ + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + + +3. Temporary Ban +~~~~~~~~~~~~~~~~ + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + + +4. Permanent Ban +~~~~~~~~~~~~~~~~ + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + + +Attribution +----------- + +This Code of Conduct is adapted from the `Contributor Covenant `__, version 2.0, +available at https://www.contributor-covenant.org/version/2/0/code_of_conduct/. + +Community Impact Guidelines were inspired by `Mozilla’s code of conduct enforcement ladder `__. + +.. _homepage: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index fe1259a5..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,81 +0,0 @@ -# Contributing to DVCLive - -We welcome contributions to [DVCLive](https://github.com/iterative/dvclive) by the -community. - -## How to report a problem - -Please search [issue tracker](https://github.com/iterative/dvclive/issues) before -creating a new issue (problem or an improvement request). Feel free to add -issues related to the project. - -If you feel that you can fix or implement it yourself, please read a few -paragraphs below to learn how to submit your changes. - -## Submitting changes - -- Open a new issue in the - [issue tracker](https://github.com/iterative/dvclive/issues). -- Setup the [development environment](#development-environment) if you need to - run tests or [run](#running-development-version) DVCLive with your changes. -- Fork [DVCLive](https://github.com/iterative/dvclive.git) and prepare necessary - changes. -- [Add tests](#writing-tests) for your changes to `tests/`. You can skip this - step if the effort to create tests for your change is unreasonable. Changes - without tests are still going to be considered by us. -- [Run tests](#running-tests) and make sure all of them pass. -- Submit a pull request, referencing any issues it addresses. - -We will review your pull request as soon as possible. Thank you for -contributing! - -## Development environment - -Get the latest development version. Fork and clone the repo: - -```bash -git clone git@github.com:/dvclive.git -``` - -Make sure that you have Python 3 installed. Version 3.6 or higher is required to -run style checkers on pre-commit. On macOS, we recommend using `brew` to install -Python. For Windows, we recommend an official -[python.org release](https://www.python.org/downloads/windows/). - -Install DVCLive in editable mode with `pip install -e ".[tests]"`. But before we -do that, we **strongly** recommend creating a -[virtual environment](https://python.readthedocs.io/en/stable/library/venv.html): - -```bash -$ cd dvclive -$ python3 -m venv .env -$ source .env/bin/activate -$ pip install -e ".[tests]" -``` - -Install coding style pre-commit hooks with: - -```bash -$ pip install pre-commit -$ pre-commit install -``` - -That's it. You should be ready to make changes, run tests, and make commits! If -you experience any problems, please don't hesitate to ping us. - - -## Writing tests - -We have unit tests in `tests/`. To get started, you can search for existing ones -testing similar functionality to your changes. - -## Running tests - -The simplest way to run tests: - -```bash -cd dvclive -pytest -vv tests -``` - -This uses `pytest` to run the full test suite and report the result. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..870af8b4 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,109 @@ +Contributor Guide +================= + +Thank you for your interest in improving this project. +This project is open-source under the `Apache 2.0 license`_ and +welcomes contributions in the form of bug reports, feature requests, and pull requests. + +Here is a list of important resources for contributors: + +- `Source Code`_ +- `Issue Tracker`_ +- `Code of Conduct`_ + +.. _Apache 2.0 license: https://opensource.org/licenses/Apache-2.0 +.. _Source Code: https://github.com/iterative/dvclive +.. _Issue Tracker: https://github.com/iterative/dvclive/issues + +How to report a bug +------------------- + +Report bugs on the `Issue Tracker`_. + +When filing an issue, make sure to answer these questions: + +- Which operating system and Python version are you using? +- Which version of this project are you using? +- What did you do? +- What did you expect to see? +- What did you see instead? + +The best way to get your bug fixed is to provide a test case, +and/or steps to reproduce the issue. + + +How to request a feature +------------------------ + +Request features on the `Issue Tracker`_. + + +How to set up your development environment +------------------------------------------ + +You need Python 3.8+ and the following tools: + +- Nox_ + +Install the package with development requirements: + +.. code:: console + + $ pip install nox + +.. _Nox: https://nox.thea.codes/ + + +How to test the project +----------------------- + +Run the full test suite: + +.. code:: console + + $ nox + +List the available Nox sessions: + +.. code:: console + + $ nox --list-sessions + +You can also run a specific Nox session. +For example, invoke the unit test suite like this: + +.. code:: console + + $ nox --session=tests + +Unit tests are located in the ``tests`` directory, +and are written using the pytest_ testing framework. + +.. _pytest: https://pytest.readthedocs.io/ + + +How to submit changes +--------------------- + +Open a `pull request`_ to submit changes to this project. + +Your pull request needs to meet the following guidelines for acceptance: + +- The Nox test suite must pass without errors and warnings. +- Include unit tests. This project maintains 100% code coverage. +- If your changes add functionality, update the documentation accordingly. + +Feel free to submit early, though—we can always iterate on this. + +To run linting and code formatting checks, you can invoke a `lint` session in nox: + +.. code:: console + + $ nox -s lint + +It is recommended to open an issue before starting work on anything. +This will allow a chance to talk it over with the owners and validate your approach. + +.. _pull request: https://github.com/iterative/dvclive/pulls +.. github-only +.. _Code of Conduct: CODE_OF_CONDUCT.rst diff --git a/LICENSE b/LICENSE index ffae8e71..6bc4e6e4 100644 --- a/LICENSE +++ b/LICENSE @@ -178,7 +178,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" + boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2020-2021 Iterative, Inc. + Copyright 2022 Iterative. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.rst b/README.rst index 97e6bd83..ea48d3db 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,39 @@ DVCLive -======= +------- +|PyPI| |Status| |Python Version| |License| -|CI| |Coverage| |PyPI| +|Tests| |Codecov| |pre-commit| |Black| + +.. |PyPI| image:: https://img.shields.io/pypi/v/dvclive.svg + :target: https://pypi.org/project/dvclive/ + :alt: PyPI +.. |Status| image:: https://img.shields.io/pypi/status/dvclive.svg + :target: https://pypi.org/project/dvclive/ + :alt: Status +.. |Python Version| image:: https://img.shields.io/pypi/pyversions/dvclive + :target: https://pypi.org/project/dvclive + :alt: Python Version +.. |License| image:: https://img.shields.io/pypi/l/dvclive + :target: https://opensource.org/licenses/Apache-2.0 + :alt: License +.. |Tests| image:: https://github.com/iterative/dvclive/workflows/Tests/badge.svg + :target: https://github.com/iterative/dvclive/actions?workflow=Tests + :alt: Tests +.. |Codecov| image:: https://codecov.io/gh/iterative/dvclive/branch/main/graph/badge.svg + :target: https://app.codecov.io/gh/iterative/dvclive + :alt: Codecov +.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit +.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Black DVCLive is a Python library for logging machine learning metrics and other metadata in simple file formats, which is fully compatible with DVC. `Documentation `_ -============================================== +---------------------------------------------- - `Get Started `_ - `DVCLive with DVC `_ @@ -15,21 +41,24 @@ DVCLive is a Python library for logging machine learning metrics and other metad - `API Reference `_ Installation -============ - -pip (PyPI) ----------- +------------ -|PyPI| +You can install *dvclive* via pip_ from PyPI_: -.. code-block:: bash +.. code:: console - pip install dvclive + $ pip install dvclive Depending on the *ML framework* you plan to use to train your model, you might need to specify one of the optional dependencies: ``mmcv``, ``tf``, ``xgb``. Or ``all`` to include them all. -The command should look like this: ``pip install dvclive[tf]`` (in this case TensorFlow and it's dependencies -will be installed automatically). +For example, for TensorFlow the command should look like this: + +.. code-block:: bash + + pip install dvclive[tf] + +TensorFlow and its dependencies will be installed automatically. + To install the development version, run: @@ -38,34 +67,45 @@ To install the development version, run: pip install git+git://github.com/iterative/dvclive Comparison to related technologies -================================== +---------------------------------- **DVCLive** is an *ML Logger*, similar to: - `MLFlow `_ - `Weights & Biases `_ -- `Neptune `_ +- `Neptune `_ -The main difference with those *ML Loggers* is that **DVCLive** does not require any additional services or servers to run. +The main difference with those *ML Loggers* is that **DVCLive** does not require any additional services or servers to run. -Logged metrics and metadata are stored as plain text files that can be versioned by version control tools (i.e Git) or tracked as pointers to files in DVC storage. +Logged metrics and metadata are stored as plain text files that can be versioned by version control tools (i.e Git) or tracked as pointers to files in DVC storage. -Copyright -========= +----- -This project is distributed under the Apache license version 2.0 (see the LICENSE file in the project root). -By submitting a pull request to this project, you agree to license your contribution under the Apache license version -2.0 to this project. +Contributing +------------ -.. |CI| image:: https://github.com/iterative/dvclive/workflows/tests/badge.svg - :target: https://github.com/iterative/dvclive/actions - :alt: GHA Tests +Contributions are very welcome. +To learn more, see the `Contributor Guide`_. -.. |Coverage| image:: https://codecov.io/gh/iterative/dvclive/branch/master/graph/badge.svg - :target: https://codecov.io/gh/iterative/dvclive - :alt: Codecov -.. |PyPI| image:: https://img.shields.io/pypi/v/dvclive.svg?label=pip&logo=PyPI&logoColor=white - :target: https://pypi.org/project/dvclive - :alt: PyPI +License +------- + +Distributed under the terms of the `Apache 2.0 license`_, +*dvclive* is free and open source software. + + +Issues +------ + +If you encounter any problems, +please `file an issue`_ along with a detailed description. + + +.. _Apache 2.0 license: https://opensource.org/licenses/Apache-2.0 +.. _PyPI: https://pypi.org/ +.. _file an issue: https://github.com/iterative/dvclive/issues +.. _pip: https://pip.pypa.io/ +.. github-only +.. _Contributor Guide: CONTRIBUTING.rst diff --git a/dvclive/__init__.py b/dvclive/__init__.py deleted file mode 100644 index 29902a8d..00000000 --- a/dvclive/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from dvclive.version import __version__ # noqa: F401 - -from .live import Live # noqa: F401 diff --git a/dvclive/version.py b/dvclive/version.py deleted file mode 100644 index 9753c541..00000000 --- a/dvclive/version.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -import subprocess - -_BASE_VERSION = "0.10.0" - - -def _generate_version(base_version): - """Generate a version with information about the Git repository.""" - pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - if not _is_git_repo(pkg_dir) or not _have_git(): - return base_version - - if _is_release(pkg_dir, base_version) and not _is_dirty(pkg_dir): - return base_version - - return "{base_version}+{short_sha}{dirty}".format( - base_version=base_version, - short_sha=_git_revision(pkg_dir).decode("utf-8")[0:6], - dirty=".mod" if _is_dirty(pkg_dir) else "", - ) - - -def _is_git_repo(dir_path): - """Is the given directory version-controlled with Git?""" - return os.path.exists(os.path.join(dir_path, ".git")) - - -def _have_git(): - """Can we run the git executable?""" - try: - subprocess.check_output(["git", "--help"]) - return True - except subprocess.CalledProcessError: - return False - except OSError: - return False - - -def _is_release(dir_path, base_version): - try: - output = subprocess.check_output( - ["git", "describe", "--tags", "--exact-match"], - cwd=dir_path, - stderr=subprocess.STDOUT, - ).decode("utf-8") - tag = output.strip() - return tag == base_version - except subprocess.CalledProcessError: - return False - - -def _git_revision(dir_path): - """Get SHA of the HEAD of a Git repository.""" - return subprocess.check_output( - ["git", "rev-parse", "HEAD"], cwd=dir_path - ).strip() - - -def _is_dirty(dir_path): - """Check whether a git repository has uncommitted changes.""" - try: - subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path) - return False - except subprocess.CalledProcessError: - return True - - -__version__ = _generate_version(_BASE_VERSION) diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 00000000..820e12c6 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,62 @@ +"""Automation using nox.""" +import glob +import os + +import nox + +nox.options.reuse_existing_virtualenvs = True +nox.options.sessions = "lint", "tests" +locations = "src", "tests" + + +@nox.session(python=["3.8", "3.9", "3.10", "3.11", "pypy3.8", "pypy3.9"]) +def tests(session: nox.Session) -> None: + session.install(".[tests]") + session.run( + "pytest", + "--cov", + "--cov-config=pyproject.toml", + *session.posargs, + env={"COVERAGE_FILE": f".coverage.{session.python}"}, + ) + + +@nox.session +def lint(session: nox.Session) -> None: + session.install("pre-commit") + session.install("-e", ".[dev]") + + args = *(session.posargs or ("--show-diff-on-failure",)), "--all-files" + session.run("pre-commit", "run", *args) + session.run("python", "-m", "mypy") + session.run("python", "-m", "pylint", *locations) + + +@nox.session +def safety(session: nox.Session) -> None: + """Scan dependencies for insecure packages.""" + session.install(".[dev]") + session.install("safety") + session.run("safety", "check", "--full-report") + + +@nox.session +def build(session: nox.Session) -> None: + session.install("build", "setuptools", "twine") + session.run("python", "-m", "build") + dists = glob.glob("dist/*") + session.run("twine", "check", *dists, silent=True) + + +@nox.session +def dev(session: nox.Session) -> None: + """Sets up a python development environment for the project.""" + args = session.posargs or ("venv",) + venv_dir = os.fsdecode(os.path.abspath(args[0])) + + session.log(f"Setting up virtual environment in {venv_dir}") + session.install("virtualenv") + session.run("virtualenv", venv_dir, silent=True) + + python = os.path.join(venv_dir, "bin/python") + session.run(python, "-m", "pip", "install", "-e", ".[dev]", external=True) diff --git a/pyproject.toml b/pyproject.toml index a4fc8cbe..9617acec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,9 @@ +[build-system] +requires = ["setuptools>=48", "setuptools_scm[toml]>=6.3.1"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] + [tool.black] line-length = 79 include = '\.pyi?$' @@ -15,3 +21,62 @@ exclude = ''' | dist )/ ''' + +[tool.isort] +profile = "black" +known_first_party = ["dvclive"] +line_length = 79 + +[tool.pytest.ini_options] +addopts = "-ra" + +[tool.coverage.run] +branch = true +source = ["dvclive", "tests"] + +[tool.coverage.paths] +source = ["src", "*/site-packages"] + +[tool.coverage.report] +show_missing = true +exclude_lines = [ + "pragma: no cover", + "if __name__ == .__main__.:", + "if typing.TYPE_CHECKING:", + "if TYPE_CHECKING:", + "raise NotImplementedError", + "raise AssertionError", + "@overload", +] + +[tool.mypy] +# Error output +show_column_numbers = true +show_error_codes = true +show_error_context = true +show_traceback = true +pretty = true +check_untyped_defs = false +# Warnings +warn_no_return = true +warn_redundant_casts = true +warn_unreachable = true +ignore_missing_imports = true +files = ["src", "tests"] + +[tool.pylint.message_control] +enable = ["c-extension-no-member", "no-else-return"] +disable = [ + "format", "refactoring", "spelling", "design", + "invalid-name", "duplicate-code", "fixme", + "unused-wildcard-import", "cyclic-import", "wrong-import-order", + "wrong-import-position", "ungrouped-imports", "multiple-imports", + "logging-format-interpolation", "logging-fstring-interpolation", + "missing-function-docstring", "missing-module-docstring", + "missing-class-docstring", "raise-missing-from", "import-outside-toplevel", +] + +[tool.pylint.variables] +dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_" +ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs" +generated-members = ["torch.*"] diff --git a/scripts/build_package.sh b/scripts/build_package.sh deleted file mode 100755 index c3eab679..00000000 --- a/scripts/build_package.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e -set -x - -if [ ! -d "dvclive" ]; then - echo "Please run this script from repository root" >&2 - exit 1 -fi - -python setup.py sdist -python setup.py bdist_wheel --universal \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index faba55d6..5260e903 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,93 @@ +[metadata] +description = Metric logger for ML projects. +name = dvclive +long_description = file: README.rst +long_description_content_type = text/x-rst +license = Apache-2.0 +license_files = LICENSE +url = https://github.com/iterative/dvclive +project_urls = + Documentation = https://dvc.org/doc/dvclive + Source = https://github.com/iterative/dvclive +platforms=any +authors = Paweł Redzyński +author_email = pawel@iterative.ai +maintainer = Iterative +maintainer_email = support@dvc.org +keywords=data-science, metrics, machine-learning, developer-tools, ai +classifiers = + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Development Status :: 4 - Beta + +[options] +python_requires = >=3.8 +zip_safe = False +package_dir= + =src +packages = find: +install_requires= + dvc_render[table]>=0.0.8 + +[options.extras_require] +tests = + pytest==7.1.2 + pytest-sugar==0.9.5 + pytest-cov==3.0.0 + pytest-mock==3.8.2 + pylint==2.15.0 + pylint-plugin-utils>=0.6 + mypy==0.971 + pandas>=1.3.1 + funcy>=1.1 + dvc>=2.0.0 + %(all)s +dev = + %(tests)s +image = + pillow +sklearn = + scikit-learn +plots = + %(sklearn)s +mmcv = + mmcv +tf = + tensorflow +xgb = + xgboost +lgbm = + lightgbm +huggingface = + transformers + datasets +catalyst = + catalyst<=21.12 +fastai = + fastai +pytorch_lightning = + pytorch_lightning>=1.6 +all = + %(image)s + %(mmcv)s + %(tf)s + %(xgb)s + %(lgbm)s + %(huggingface)s + %(catalyst)s + %(fastai)s + %(pytorch_lightning)s + %(plots)s + +[options.packages.find] +exclude = + tests + tests.* +where=src + [flake8] ignore= E203, # Whitespace before ':' @@ -5,21 +95,15 @@ ignore= W503, # Line break occurred before a binary operator P1, # unindexed parameters in the str.format, see: # https://pypi.org/project/flake8-string-format/ -max_line_length=79 +per-file-ignores = + tests/test_mmcv.py:C408, + # Unnecessary dict call +max_line_length = 79 max-complexity = 15 -select=B,C,E,F,W,T4,B902,T,P -show_source=true -count=true - -[isort] -profile=black -known_first_party=dvc,tests -known_third_party=setuptools,tensorflow -line_length=79 +select = B,C,E,F,W,T4,B902,T,P +show_source = true +count = true -[mypy] -show_column_numbers = True -show_error_codes = True -show_error_context = True -show_traceback = True -pretty = True +[codespell] +ignore-words-list = + fpr diff --git a/setup.py b/setup.py deleted file mode 100644 index 91e9e586..00000000 --- a/setup.py +++ /dev/null @@ -1,108 +0,0 @@ -import importlib.util -import os - -from setuptools import find_packages, setup -from setuptools.command.build_py import build_py as _build_py - -# Read package meta-data from version.py -# see https://packaging.python.org/guides/single-sourcing-package-version/ -pkg_dir = os.path.dirname(os.path.abspath(__file__)) -version_path = os.path.join(pkg_dir, "dvclive", "version.py") -spec = importlib.util.spec_from_file_location("dvclive.version", version_path) -dvclive_version = importlib.util.module_from_spec(spec) -spec.loader.exec_module(dvclive_version) -version = dvclive_version.__version__ - - -# To achieve consistency between the build version and the one provided -# by your package during runtime, you need to **pin** the build version. -# -# This custom class will replace the version.py module with a **static** -# `__version__` that your package can read at runtime, assuring consistency. -# -# References: -# - https://docs.python.org/3/distutils/extending.html -# - https://github.com/python/mypy -class build_py(_build_py): - def pin_version(self): - path = os.path.join(self.build_lib, "dvclive") - self.mkpath(path) - with open(os.path.join(path, "version.py"), "w") as fobj: - fobj.write("# AUTOGENERATED at build time by setup.py\n") - fobj.write('__version__ = "{}"\n'.format(version)) - - def run(self): - self.execute(self.pin_version, ()) - _build_py.run(self) - - -render = ["dvc_render[table]>=0.0.8"] -image = ["pillow"] -plots = ["scikit-learn"] -mmcv = ["mmcv"] -tf = ["tensorflow"] -xgb = ["xgboost"] -lgbm = ["lightgbm"] -hugginface = ["transformers", "datasets"] -catalyst = ["catalyst<=21.12"] -fastai = ["fastai"] -pl = ["pytorch_lightning>=1.6"] - -all_libs = ( - render - + image - + mmcv - + tf - + xgb - + lgbm - + hugginface - + catalyst - + fastai - + pl - + plots -) - -tests_requires = [ - "pylint==2.5.3", - "pytest>=6.0.1", - "pre-commit", - "pylint-plugin-utils>=0.6", - "pytest-cov>=2.12.1", - "pytest-mock>=3.6.1", - "pandas>=1.3.1", - "funcy>=1.14", - "dvc>=2.0.0", -] + all_libs - -setup( - name="dvclive", - version=version, - author="Paweł Redzyński", - author_email="pawel@iterative.ai", - packages=find_packages(exclude="tests"), - description="Metric logger for ML projects.", - long_description=open("README.rst", "r", encoding="UTF-8").read(), - license="Apache License 2.0", - license_files=("LICENSE",), - install_requires=render, - extras_require={ - "tests": tests_requires, - "all": all_libs, - "tf": tf, - "xgb": xgb, - "lgbm": lgbm, - "mmcv": mmcv, - "huggingface": hugginface, - "catalyst": catalyst, - "fastai": fastai, - "pytorch_lightning": pl, - "sklearn": plots, - "image": image, - "plots": plots, - }, - keywords="data-science metrics machine-learning developer-tools ai", - python_requires=">=3.8", - cmdclass={"build_py": build_py}, - url="https://dvc.org/doc/dvclive", - download_url="https://github.com/iterative/dvclive", -) diff --git a/src/dvclive/__init__.py b/src/dvclive/__init__.py new file mode 100644 index 00000000..bb8b1cd2 --- /dev/null +++ b/src/dvclive/__init__.py @@ -0,0 +1 @@ +from .live import Live # noqa: F401 diff --git a/dvclive/catalyst.py b/src/dvclive/catalyst.py similarity index 100% rename from dvclive/catalyst.py rename to src/dvclive/catalyst.py diff --git a/dvclive/data/__init__.py b/src/dvclive/data/__init__.py similarity index 100% rename from dvclive/data/__init__.py rename to src/dvclive/data/__init__.py diff --git a/dvclive/data/base.py b/src/dvclive/data/base.py similarity index 100% rename from dvclive/data/base.py rename to src/dvclive/data/base.py diff --git a/dvclive/data/image.py b/src/dvclive/data/image.py similarity index 100% rename from dvclive/data/image.py rename to src/dvclive/data/image.py diff --git a/dvclive/data/plot.py b/src/dvclive/data/plot.py similarity index 100% rename from dvclive/data/plot.py rename to src/dvclive/data/plot.py diff --git a/dvclive/data/scalar.py b/src/dvclive/data/scalar.py similarity index 100% rename from dvclive/data/scalar.py rename to src/dvclive/data/scalar.py diff --git a/dvclive/data/utils.py b/src/dvclive/data/utils.py similarity index 100% rename from dvclive/data/utils.py rename to src/dvclive/data/utils.py diff --git a/dvclive/dvc.py b/src/dvclive/dvc.py similarity index 100% rename from dvclive/dvc.py rename to src/dvclive/dvc.py diff --git a/dvclive/env.py b/src/dvclive/env.py similarity index 100% rename from dvclive/env.py rename to src/dvclive/env.py diff --git a/dvclive/error.py b/src/dvclive/error.py similarity index 100% rename from dvclive/error.py rename to src/dvclive/error.py diff --git a/dvclive/fastai.py b/src/dvclive/fastai.py similarity index 100% rename from dvclive/fastai.py rename to src/dvclive/fastai.py diff --git a/dvclive/huggingface.py b/src/dvclive/huggingface.py similarity index 100% rename from dvclive/huggingface.py rename to src/dvclive/huggingface.py diff --git a/dvclive/keras.py b/src/dvclive/keras.py similarity index 100% rename from dvclive/keras.py rename to src/dvclive/keras.py diff --git a/dvclive/lgbm.py b/src/dvclive/lgbm.py similarity index 100% rename from dvclive/lgbm.py rename to src/dvclive/lgbm.py diff --git a/dvclive/lightning.py b/src/dvclive/lightning.py similarity index 100% rename from dvclive/lightning.py rename to src/dvclive/lightning.py diff --git a/dvclive/live.py b/src/dvclive/live.py similarity index 100% rename from dvclive/live.py rename to src/dvclive/live.py diff --git a/dvclive/report.py b/src/dvclive/report.py similarity index 100% rename from dvclive/report.py rename to src/dvclive/report.py diff --git a/dvclive/utils.py b/src/dvclive/utils.py similarity index 100% rename from dvclive/utils.py rename to src/dvclive/utils.py diff --git a/dvclive/xgb.py b/src/dvclive/xgb.py similarity index 100% rename from dvclive/xgb.py rename to src/dvclive/xgb.py From 189064380904cbad46d71e4354839560a46ca516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 12:03:02 +0200 Subject: [PATCH 2/8] fix type hints/mypy errors --- src/dvclive/data/__init__.py | 2 +- src/dvclive/data/base.py | 11 ++++++----- src/dvclive/data/plot.py | 20 +++++++++++++++----- src/dvclive/keras.py | 2 +- src/dvclive/lightning.py | 10 ++++------ tests/test_main.py | 5 +++-- tests/test_report.py | 2 +- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/dvclive/data/__init__.py b/src/dvclive/data/__init__.py index eb44291d..64825119 100644 --- a/src/dvclive/data/__init__.py +++ b/src/dvclive/data/__init__.py @@ -10,4 +10,4 @@ "precision_recall": PrecisionRecall, "roc": Roc, } -DATA_TYPES = list(PLOTS.values()) + [Scalar, Image] +DATA_TYPES = (*PLOTS.values(), Scalar, Image) diff --git a/src/dvclive/data/base.py b/src/dvclive/data/base.py index e71204e3..df0c6fdf 100644 --- a/src/dvclive/data/base.py +++ b/src/dvclive/data/base.py @@ -1,6 +1,6 @@ import abc from pathlib import Path -from typing import Optional +from typing import Any, Dict, List, Optional from dvclive.error import DataAlreadyLoggedError @@ -10,12 +10,12 @@ def __init__(self, name: str, output_folder: str) -> None: self.name = name self.output_folder: Path = Path(output_folder) / self.subfolder self._step: Optional[int] = None - self.val = None + self.val: Optional[List[Any]] = None self._step_none_logged: bool = False - self._dump_kwargs = None + self._dump_kwargs: Optional[Dict[str, Any]] = None @property - def step(self) -> int: + def step(self) -> Optional[int]: return self._step @step.setter @@ -50,7 +50,8 @@ def summary(self): def could_log(val: object) -> bool: pass - def dump(self, val, step, **kwargs): + def dump(self, val: List[Any], step: Optional[int], **kwargs): + assert val is not None self.val = val self.step = step self._dump_kwargs = kwargs diff --git a/src/dvclive/data/plot.py b/src/dvclive/data/plot.py index 2161f445..e0b880a8 100644 --- a/src/dvclive/data/plot.py +++ b/src/dvclive/data/plot.py @@ -62,7 +62,9 @@ def get_properties(): "y_label": "True Positive Rate", } - def no_step_dump(self) -> int: + def no_step_dump(self) -> None: + assert self.val is not None + from sklearn import metrics fpr, tpr, roc_thresholds = metrics.roc_curve( @@ -88,7 +90,9 @@ def get_properties(): "y_label": "Precision", } - def no_step_dump(self) -> int: + def no_step_dump(self) -> None: + assert self.val is not None + from sklearn import metrics precision, recall, prc_thresholds = metrics.precision_recall_curve( @@ -115,7 +119,9 @@ def get_properties(): "y_label": "False Negative Rate", } - def no_step_dump(self) -> int: + def no_step_dump(self) -> None: + assert self.val is not None + from sklearn import metrics fpr, fnr, roc_thresholds = metrics.det_curve( @@ -143,7 +149,9 @@ def get_properties(): "y_label": "Predicted Label", } - def no_step_dump(self) -> int: + def no_step_dump(self) -> None: + assert self.val is not None + cm = [ {"actual": str(actual), "predicted": str(predicted)} for actual, predicted in zip(self.val[0], self.val[1]) @@ -162,7 +170,9 @@ def get_properties(): "y_label": "Fraction of Positives", } - def no_step_dump(self) -> int: + def no_step_dump(self) -> None: + assert self.val is not None + from sklearn import calibration prob_true, prob_pred = calibration.calibration_curve( diff --git a/src/dvclive/keras.py b/src/dvclive/keras.py index 6db44199..bde30b10 100644 --- a/src/dvclive/keras.py +++ b/src/dvclive/keras.py @@ -22,7 +22,7 @@ def __init__( def on_train_begin(self, logs=None): # pylint: disable=unused-argument if ( - self.dvclive._resume + self.dvclive._resume # pylint: disable=protected-access and self.model_file is not None and os.path.exists(self.model_file) ): diff --git a/src/dvclive/lightning.py b/src/dvclive/lightning.py index c575490e..f62ec4cc 100644 --- a/src/dvclive/lightning.py +++ b/src/dvclive/lightning.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Any, Dict, Optional from pytorch_lightning.loggers import LightningLoggerBase from pytorch_lightning.loggers.base import rank_zero_experiment @@ -36,7 +36,7 @@ def name(self): def log_hyperparams(self, params, *args, **kwargs): pass - @property + @property # type: ignore @rank_zero_experiment def experiment(self): r""" @@ -60,11 +60,9 @@ def version(self): return self._version @rank_zero_only - def log_metrics( - self, metrics: Dict[str, float], step: Optional[int] = None - ): + def log_metrics(self, metrics: Dict[str, Any], step: Optional[int] = None): assert ( - rank_zero_only.rank == 0 + rank_zero_only.rank == 0 # type: ignore ), "experiment tried to log from global_rank != 0" for metric_name, metric_val in metrics.items(): diff --git a/tests/test_main.py b/tests/test_main.py index 131273b0..ee5c25fa 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,3 +1,4 @@ +# pylint: disable=protected-access import json import os from pathlib import Path @@ -17,8 +18,8 @@ from dvclive.utils import parse_tsv -def read_logs(path: str): - path = Path(path) +def read_logs(path_: str): + path = Path(path_) assert path.is_dir() history = {} for metric_file in path.rglob("*.tsv"): diff --git a/tests/test_report.py b/tests/test_report.py index b72b49b5..bb7011aa 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -1,4 +1,4 @@ -# pylint: disable=unused-argument +# pylint: disable=unused-argument,protected-access import os import pytest From a7f368957cbbd22b507fb4f070cff6585d03758b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 12:09:04 +0200 Subject: [PATCH 3/8] fix typos --- src/dvclive/error.py | 2 +- src/dvclive/utils.py | 4 ++-- tests/test_main.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dvclive/error.py b/src/dvclive/error.py index 51ee7aff..0e4c3452 100644 --- a/src/dvclive/error.py +++ b/src/dvclive/error.py @@ -42,5 +42,5 @@ def __init__(self, name, step): self.name = name self.val = step super().__init__( - f"Data '{name}' has already being logged whith step '{step}'" + f"Data '{name}' has already been logged with step '{step}'" ) diff --git a/src/dvclive/utils.py b/src/dvclive/utils.py index d47a64a1..791a1269 100644 --- a/src/dvclive/utils.py +++ b/src/dvclive/utils.py @@ -25,7 +25,7 @@ def nested_set(d, keys, value): def nested_update(d, u): - """Update values of a nested dictionnary of varying depth""" + """Update values of a nested dictionary of varying depth""" for k, v in u.items(): if isinstance(v, Mapping): d[k] = nested_update(d.get(k, {}), v) @@ -71,7 +71,7 @@ def env2bool(var, undefined=False): def standardize_metric_name(metric_name: str, framework: str) -> str: """Map framework-specific format to DVCLive standard. - Use `{split}/` as prefix in order to seperate by subfolders. + Use `{split}/` as prefix in order to separate by subfolders. Use `{train|eval}` as split name. """ if framework == "dvclive.fastai": diff --git a/tests/test_main.py b/tests/test_main.py index ee5c25fa..1e8888b3 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -174,7 +174,7 @@ def test_require_step_update(tmp_dir, metric): with pytest.raises( DataAlreadyLoggedError, - match="has already being logged whith step 'None'", + match="has already been logged with step 'None'", ): dvclive.log(metric, 2.0) From 4e5d77d68777ef79b1aa676c27d3ecaec32f2217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 13:48:29 +0200 Subject: [PATCH 4/8] utils: fix types in open_file_in_browser --- src/dvclive/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dvclive/utils.py b/src/dvclive/utils.py index 791a1269..b36b1ae0 100644 --- a/src/dvclive/utils.py +++ b/src/dvclive/utils.py @@ -53,7 +53,11 @@ def wrapper(*args, **kwargs): @run_once def open_file_in_browser(file) -> bool: path = Path(file) - url = path if "Microsoft" in uname().release else path.resolve().as_uri() + url = ( + str(path) + if "Microsoft" in uname().release + else path.resolve().as_uri() + ) return webbrowser.open(url) From 2d9b2b32dc6267c7d6f3bb47b2ad7a606be6103f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 14:48:39 +0200 Subject: [PATCH 5/8] explicitly specify encoding in open() calls --- src/dvclive/data/plot.py | 2 +- src/dvclive/data/scalar.py | 2 +- src/dvclive/dvc.py | 2 +- src/dvclive/live.py | 4 ++-- src/dvclive/report.py | 3 ++- src/dvclive/utils.py | 2 +- tests/test_main.py | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dvclive/data/plot.py b/src/dvclive/data/plot.py index e0b880a8..6b7657eb 100644 --- a/src/dvclive/data/plot.py +++ b/src/dvclive/data/plot.py @@ -30,7 +30,7 @@ def summary(self): @staticmethod def write_json(content, output_file): - with open(output_file, "w") as f: + with open(output_file, "w", encoding="utf-8") as f: json.dump(content, f, indent=4) def no_step_dump(self) -> None: diff --git a/src/dvclive/data/scalar.py b/src/dvclive/data/scalar.py index 66e64206..f834935d 100644 --- a/src/dvclive/data/scalar.py +++ b/src/dvclive/data/scalar.py @@ -46,7 +46,7 @@ def step_dump(self) -> None: ) existed = self.output_path.exists() - with open(self.output_path, "a") as fobj: + with open(self.output_path, "a", encoding="utf-8") as fobj: writer = csv.DictWriter(fobj, d.keys(), delimiter="\t") if not existed: diff --git a/src/dvclive/dvc.py b/src/dvclive/dvc.py index c3efaf83..eb5f005d 100644 --- a/src/dvclive/dvc.py +++ b/src/dvclive/dvc.py @@ -38,7 +38,7 @@ def make_checkpoint(): signal_file = os.path.join(root_dir, ".dvc", "tmp", env.DVC_CHECKPOINT) - with builtins.open(signal_file, "w") as fobj: + with builtins.open(signal_file, "w", encoding="utf-8") as fobj: # NOTE: force flushing/writing empty file to disk, otherwise when # run in certain contexts (pytest) file may not actually be written fobj.write("") diff --git a/src/dvclive/live.py b/src/dvclive/live.py index d71141ce..4aae343b 100644 --- a/src/dvclive/live.py +++ b/src/dvclive/live.py @@ -199,7 +199,7 @@ def make_summary(self): for data in self._scalars.values(): summary_data = nested_update(summary_data, data.summary) - with open(self.summary_path, "w") as f: + with open(self.summary_path, "w", encoding="utf-8") as f: json.dump(summary_data, f, indent=4, cls=NumpyEncoder) def make_report(self): @@ -222,5 +222,5 @@ def read_step(self): return 0 def read_latest(self): - with open(self.summary_path, "r") as fobj: + with open(self.summary_path, "r", encoding="utf-8") as fobj: return json.load(fobj) diff --git a/src/dvclive/report.py b/src/dvclive/report.py index 4fc212ea..7f5b5cab 100644 --- a/src/dvclive/report.py +++ b/src/dvclive/report.py @@ -70,7 +70,8 @@ def get_metrics_renderers(dvclive_summary): if summary_path.exists(): return [ TableRenderer( - [json.loads(summary_path.read_text())], summary_path.name + [json.loads(summary_path.read_text(encoding="utf-8"))], + summary_path.name, ) ] return [] diff --git a/src/dvclive/utils.py b/src/dvclive/utils.py index b36b1ae0..71670133 100644 --- a/src/dvclive/utils.py +++ b/src/dvclive/utils.py @@ -35,7 +35,7 @@ def nested_update(d, u): def parse_tsv(path): - with open(path, "r") as fd: + with open(path, "r", encoding="utf-8") as fd: reader = csv.DictReader(fd, delimiter="\t") return list(reader) diff --git a/tests/test_main.py b/tests/test_main.py index 1e8888b3..d0c8201e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -46,7 +46,7 @@ def read_latest(path, metric_name): def _parse_json(path): - with open(path, "r") as fd: + with open(path, "r", encoding="utf-8") as fd: return json.load(fd) From a9b82a84d2d276e009acdea2d0c3e227a45eb25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 16:25:00 +0200 Subject: [PATCH 6/8] gha: increase timeout --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0932393b..81abe333 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ concurrency: jobs: tests: - timeout-minutes: 10 + timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false From 067ac3667e278628546afe2887aa3d9b77a713b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Thu, 1 Sep 2022 16:33:17 +0200 Subject: [PATCH 7/8] gha: don't test on pypy or 3.11 Most ML frameworks won't work on pypy and won't be available on 3.11 until it is officially released --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 81abe333..88fb6700 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,9 +22,6 @@ jobs: matrix: os: [ubuntu-20.04, windows-latest, macos-latest] pyv: ["3.8", "3.9", "3.10"] - include: - - { os: ubuntu-latest, pyv: "pypy3.8" } - - { os: ubuntu-latest, pyv: "3.11.0-rc - 3.11", nox_pyv: "3.11" } steps: - name: Check out the repository From 13e30fda062e64fe66b9890f494e15332863ac98 Mon Sep 17 00:00:00 2001 From: daniele <36171005+dtrifiro@users.noreply.github.com> Date: Thu, 8 Sep 2022 17:04:56 +0200 Subject: [PATCH 8/8] setup.cfg: set authors to Iterative Co-authored-by: skshetry --- setup.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5260e903..417d024b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,9 +10,7 @@ project_urls = Documentation = https://dvc.org/doc/dvclive Source = https://github.com/iterative/dvclive platforms=any -authors = Paweł Redzyński -author_email = pawel@iterative.ai -maintainer = Iterative +authors = Iterative maintainer_email = support@dvc.org keywords=data-science, metrics, machine-learning, developer-tools, ai classifiers =