Coder Social home page Coder Social logo

Method Not Allowed about arcee-python HOT 13 CLOSED

arcee-ai avatar arcee-ai commented on May 29, 2024
Method Not Allowed

from arcee-python.

Comments (13)

Ben-Epstein avatar Ben-Epstein commented on May 29, 2024 2

Sounds good, I don't like the use of .value, because like you say, it's confusing.

StrEnum is a good workaround

from arcee-python.

Jacobsolawetz avatar Jacobsolawetz commented on May 29, 2024 1

@beddows that fixed a bug that I had replicated of yours - so hopefully it works! Thanks for surfacing this for us

from arcee-python.

beddows avatar beddows commented on May 29, 2024 1

It works, thanks for the quick fix!

from arcee-python.

Jacobsolawetz avatar Jacobsolawetz commented on May 29, 2024

Hello @beddows - a couple of questions?

which python version are you using? And which version of arcee-py?

And would you let us know which method you are trying to hit? Thanks!

from arcee-python.

Ben-Epstein avatar Ben-Epstein commented on May 29, 2024

Hey @beddows I think the issue comes from you likely being on python < 3.10. I just updated the repo to support 3.8+, and cut a release.

Can you try installing pip install --upgrade 'arcee-py>=0.1.0'? Thanks!

from arcee-python.

Jacobsolawetz avatar Jacobsolawetz commented on May 29, 2024

@metric-space found this is still broken for CLI

from arcee-python.

EricLiclair avatar EricLiclair commented on May 29, 2024

❗️Breaks in Python 3.11.6 as well

Screenshot 2023-10-17 at 11 49 06 AM

Replication:

  1. installation and api key
pip install arcee-py
# installs `arcee-py           0.1.0`

export ARCEE_API_KEY=********
  1. created a context in dashboard at app.arcee.ai/<org>/contexts named 'music_therapy'

  2. copied heading and some text from this source

import arcee

doc_name = "<copied heading>"
doc_text = """<copied content>"""

arcee.upload_doc("music_therapy", doc_name=doc_name, doc_text=doc_text)
  1. run dev.py
python dev.py

Throws:

(venv) shwu@Shubhams-MacBook-Pro temp % python dev.py
Traceback (most recent call last):
  File "/Users/shwu/temp/dev.py", line 17, in <module>
    arcee.upload_doc("music_therapy", doc_name=doc_name, doc_text=doc_text)
  File "/Users/shwu/temp/venv/lib/python3.11/site-packages/arcee/api.py", line 23, in upload_doc
    return make_request("post", Route.contexts, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/shwu/temp/venv/lib/python3.11/site-packages/arcee/api_handler.py", line 29, in decorator
    raise Exception(exception)
Exception: Failed to make request. Response: {"detail":"Method Not Allowed"}

observations

I added a print statement to check the url to which the request was being made:

call: ====>  https://api.arcee.ai/v2/Route.contexts {'context_name': 'music_therapy', 'documents': [{'name': 'The effect and mechanisms of music therapy on the autonomic nervous system and brain networks of patients of minimal conscious states: a randomized controlled trial', 'document': "Introduction: Music therapy has been employed as an alternative treatment modality for the arousal therapy of patients with disorders of consciousness (DOC) in clinical settings. However, due to the absence of continuous quantitative measurements and the...

I did some dive in and then changed this line here,
from

    return make_request("post", Route.contexts, data)

to

    return make_request("post", Route.contexts.value, data)

and it seems to be working. Any thoughts on this?

call: ====>  https://api.arcee.ai/v2/contexts {'context_name': 'music_therapy', 'documents': [{'name': 'The effect and mechanisms of music therapy on the autonomic nervous system and brain networks of patients of minimal conscious states: a randomized controlled trial', ...

my thoughts

the Route(str, Enum) enumeration is not being resolved into the value by default (❗️this is in Python 3.11.6)
I tried a few combinations for Python 3.11.6

Route Definition Behavior Notes
Route(str, Enum) ✅ (with Route.<key>.value) Requires .value
Route(StrEnum) ✅ works as is No additional step
Route(Enum) ✅ (with Route.<key>.value) Requires .value

A few discussions branching from this stack overflow answer do suggest different resolutions of enums.

Edit: more reference

from arcee-python.

tleyden avatar tleyden commented on May 29, 2024

I'm hitting the same issue, and I'm also on python 3.11. I think it's related to the fact that Python 3.11 changed things so that string enums are no longer literal strings

from arcee-python.

tleyden avatar tleyden commented on May 29, 2024

@EricLiclair Thank you for digging into this! Here's a PR with a fix #20 - it uses the same approach as your suggested workaround.

from arcee-python.

EricLiclair avatar EricLiclair commented on May 29, 2024

@tleyden thanks for the pr. while the explicit usage is absolutely correct, I was wondering if we could somehow maintain the implicit resolution of the enums to values. it seems StrEnum (along with other enums) were introduced in 3.11 with these limitations for otherwise the normal mixed enums;

To make it work across versions, most probably, we'll have to override the __format__ method;
Would like to know @Ben-Epstein's opinion on this.

Also, @tleyden if you have any opinions on this 🤔

from arcee-python.

Ben-Epstein avatar Ben-Epstein commented on May 29, 2024

Hey folks! It looks like this was a temporary python bug in 3.11.2 which had been reverted. python/cpython#103479 (comment)

@EricLiclair would you be willing to do a quick test on python (>=3.11.3, >3.12)?

If that works (as I think it should, based on that issue) I'd actually recommend keeping the behavior and just pinning against 3.11.2 in pyproject.

from arcee-python.

tleyden avatar tleyden commented on May 29, 2024

I'm seeing the error on Python 3.11.6

from arcee-python.

tleyden avatar tleyden commented on May 29, 2024

@Ben-Epstein I'm not a big fan of banning recent versions of python. I think that should only be done as a last resort. This seems pretty easy to workaround in a way that will work on all versions of python.

According to Enum with str or int Mixin Breaking Change in Python 3.11 this is a known breaking change rather than a bug in a particular patch version of python 3.11. The recommendation is to use the built-in StrEnum on Python 3.11, and the StrEnum package for older versions of python.

Using .value is a also a valid workaround, but as the blog post author points out: "But knowing when to use .value is inconvenient."

from arcee-python.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.