Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Failed guessing mime type of file] Unable to publish ".png" image to the report. #401

Closed
MaxKumundzhiev opened this issue Feb 16, 2021 · 6 comments · Fixed by #427 or #431
Closed
Assignees
Labels
cml-publish Subcommand p1-important High priority

Comments

@MaxKumundzhiev
Copy link

Hi there !

Description

Based on the proposed by the DVCorg community MLOps tutorial I was attaching the calculated and saved confusion_matrix.png image to the report. But I continuously obtained the error:

Error: Failed guessing mime type of file result/confusion_matrix.png
    at mime_type (/cml/src/utils.js:49:11)
Error: Process completed with exit code 1.

The .github/workflow/expirement.cml file content:

name: experiment-workflow
on: [push]
jobs:
  run:
    runs-on: [ubuntu-latest]
    container: docker://dvcorg/cml-py3:latest
    steps:
      - uses: actions/checkout@v2
      - name: cml_run
        env:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
        run: |

          pip install -r requirements.txt
          python expirement.py

          # CML REPORT
          echo "## Model Metrics" >> report.md
          cat results/metrics.txt >> report.md

          echo "## Confusion Matrix" >> report.md
          cml-publish results/confusion_matrix.png --md >> report.md

          cml-send-comment report.md

The sample of the expirement.py file content:

# imports
...

_FOLDER = Path('./results')
_METRICS = Path('metrics.txt')
_CONFUSION_MATRIX = Path('confusion_matrix.png')


shutil.rmtree(_FOLDER, ignore_errors=False)
Path(_FOLDER).mkdir(exist_ok=True)

# example of model output
target = [1, 1, 1, 0, 0, 1]
predicted = [1, 1, 1, 1, 1, 0]


results_dict = {
    'Precision': MetricsFactory.precision(target=target, predicted=predicted),
    'Recall': MetricsFactory.recall(target=target, predicted=predicted),
    'ROC AUC': MetricsFactory.roc_auc(target=target, predicted=predicted),
    'F1 Score': MetricsFactory.f1(target=target, predicted=predicted),
    'Confusion Matrix': MetricsFactory.confusion_matrix(target=target, predicted=predicted)
}

with open(_FOLDER / _METRICS, 'w') as f:
    f.write(str(results_dict))

_confusion_matrix = pd.DataFrame(results_dict['Confusion Matrix'])

plt.figure(figsize=(10, 7))
sn.heatmap(_confusion_matrix, annot=True)
plt.savefig(_FOLDER / _CONFUSION_MATRIX)

Summary

The error denotes an issue with the confusion_matrix.png file. In the meantime I can open and validate the image exists and format is not corrupted.
Could you please give a hint what's going wrong ? What did I miss if so ?

@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Feb 19, 2021

👋 @KumundzhievMaxim
At first sight everything seems to be right in your workflow.
Let me do a check.
Also, is there any chance to see the repo? Is it public?

@DavidGOrtega
Copy link
Contributor

Could you please check that results/confusion_matrix.png is relative to cml-publish?

@DavidGOrtega
Copy link
Contributor

@KumundzhievMaxim did you find the issue?

@DavidGOrtega DavidGOrtega added cml-publish Subcommand p1-important High priority labels Feb 23, 2021
@DavidGOrtega
Copy link
Contributor

related to #308

@MaxKumundzhiev
Copy link
Author

👋 @DavidGOrtega, apologies for the delayed response.

Also, is there any chance to see the repo? Is it public?

Yes, the repo is private

@MaxKumundzhiev
Copy link
Author

MaxKumundzhiev commented Feb 28, 2021

Good news @DavidGOrtega, the issue can be closed I presume !

Explanation

Could you please check that results/confusion_matrix.png is relative to cml-publish?

Yes, the path is correct.

Did you find the issue?

Eventually I entirely reassembled the project and the results appeared in the generated with GitHub actions report.
Appreciate for rapid response and effort @DavidGOrtega

P.S.
The sample report output snapshot:
Screenshot 2021-02-28 at 12 55 53

0x2b3bfa0 added a commit that referenced this issue Mar 4, 2021
Closes #308 and probably also closes #401
0x2b3bfa0 added a commit that referenced this issue Mar 8, 2021
* Add sanity check for cml-publish files

Closes #308 and probably also closes #401

* Restyled by prettier (#428)

Co-authored-by: Restyled.io <[email protected]>

* Add tests for cml-publish file errors

* Also removes an stray leading dot on the introduced error message

* Embrace native file error messages for cml-publish

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <[email protected]>
DavidGOrtega added a commit that referenced this issue Mar 18, 2021
…#431)

* [create-pull-request] automated change (#425)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update dependacron pull request step (#426)

This commit updates the major version for the peter-evans/create-pull-request GitHub Action step.

Required in order to avoid a fatal error caused by the  hard deprecation of the `set-env` and `add-path` standard output commands after CVE-2020-15228.

* Add sanity check for cml-publish with filesystem paths (#427)

* Add sanity check for cml-publish files

Closes #308 and probably also closes #401

* Restyled by prettier (#428)

Co-authored-by: Restyled.io <[email protected]>

* Add tests for cml-publish file errors

* Also removes an stray leading dot on the introduced error message

* Embrace native file error messages for cml-publish

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <[email protected]>

* Add destroy timeout feature (#419)

* [create-pull-request] automated change (#441)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Helio Machado <[email protected]>

* Add support for singleton runners (#422)

* Add support for singleton runners

The --reuse-existing flag will cause cml-runner
to look up for already existing runners with the
specified --labels and skip creating a new one
if that's the case.

* Deprecate --name with a warning

* Apply pre-review suggestions and fixes

* Comment out deprecation warning
* Remove unnecessary comparison
* Rename reuse-existing to reuse
* Fix misconception about empty array truthiness
* Simplify reuse by name logic
* Add missing awaits
* Give precedence to name deduplication over label deduplication
* Remove commented code

* Startup script (#445)

* Startup script

* lint

* snapshots

* Add debugging message for #443 (#448)

This commit doesn't completely fix #443, but closes it until we can reproduce again the error.

* Bitbucket-1000-handling

* bump version

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: DavidGOrtega <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cml-publish Subcommand p1-important High priority
Projects
None yet
3 participants