Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/codeocean/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ class CodeOcean:
retries: Optional[Retry | int] = 0
agent_id: Optional[str] = None

# Minimum server version required by this SDK
MIN_SERVER_VERSION = "3.6.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 3.6.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question.
Putting the new optional headers support aside, this is the system version that this SDK supports.
I didn't want to prevent users from using the latest SDK (0.8.0 that we'll release) with CO v3.6.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the version is not checked in all CO versions so far it doesn't really matter so I guess it's fine, but we can also check when was the last change to the API and pin the correlating version. Up to you.


def __post_init__(self):
self.session = BaseUrlSession(base_url=f"{self.domain}/api/v1/")
self.session.auth = (self.token, "")
self.session.headers.update({"Content-Type": "application/json"})
self.session.headers.update({
"Content-Type": "application/json",
"Min-Server-Version": CodeOcean.MIN_SERVER_VERSION,
})
if self.agent_id:
self.session.headers.update({"Agent-Id": self.agent_id})
self.session.hooks["response"] = [
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def test_basic_init(self):
headers = client.session.headers
self.assertIn("Content-Type", headers)
self.assertEqual(headers["Content-Type"], "application/json")
self.assertIn("Min-Server-Version", headers)
self.assertEqual(headers["Min-Server-Version"], CodeOcean.MIN_SERVER_VERSION)

@patch("codeocean.client.TCPKeepAliveAdapter")
def test_retry_configuration_types(self, mock_adapter):
Expand Down