Comments (13)
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.
@beddows that fixed a bug that I had replicated of yours - so hopefully it works! Thanks for surfacing this for us
from arcee-python.
It works, thanks for the quick fix!
from arcee-python.
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.
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.
@metric-space found this is still broken for CLI
from arcee-python.
❗️Breaks in Python 3.11.6 as well
Replication:
- installation and api key
pip install arcee-py
# installs `arcee-py 0.1.0`
export ARCEE_API_KEY=********
-
created a context in dashboard at app.arcee.ai/<org>/contexts named 'music_therapy'
-
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)
- 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.
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.
@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.
@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.
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.
I'm seeing the error on Python 3.11.6
from arcee-python.
@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)
- Set up openapi spec
- set a user-agent header like arcee-py/{version} on all api requests HOT 2
- Proposal: DALM connectors for popular frameworks HOT 17
- ImportError: cannot import name 'model_validator' from 'pydantic' (/usr/local/lib/python3.10/dist-packages/pydantic/__init__.py) HOT 4
- Error uploading document(s): Memory Limit Exceeded HOT 1
- Training Failed HOT 6
- Bugfix: pass filters as a dict with Arcee SDK
- Repo setup
- Train DALM status link innacurate HOT 1
- enable selecting your org on any given request
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arcee-python.