-
Notifications
You must be signed in to change notification settings - Fork 3
Ct task project migration updates #267
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
base: main
Are you sure you want to change the base?
Conversation
…m/albert-labs/albert-python into ct-task-project-migration-updates
|
Thanks for the PR @TomAlbertInvent! Mind dropping a quick summary of the changes so I can review faster? :) |
Sure! Here's the changes I made. Added merge companies |
|
…m/albert-labs/albert-python into ct-task-project-migration-updates
| sources: list[TaskSource] | None = Field(alias="Sources", default=None) | ||
| parent_id: str | None = Field(alias="parentId", default=None) | ||
| notes: str | None = Field(default=None) | ||
| tags: list[Tag] | None = Field(default=None, alias="Tags") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GeneralData inherits from BaseTaggedResource which has tags in it, so we don't need it here.
| priority: Priority # enum?! | ||
| workflow: list[EntityLink] = Field(default=None, alias="Workflow") | ||
| notes: str | None = Field(default=None) | ||
| tags: list[Tag] | None = Field(default=None, alias="Tags") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| project: SerializeAsEntityLink[Project] | None = Field(alias="Project", default=None) | ||
| inventories: list[DataTemplateInventory] | None = Field(default=None, alias="Inventories") | ||
| due_date: str | None = Field(alias="dueDate", default=None) | ||
| tags: list[Tag] | None = Field(default=None, alias="Tags") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| ], | ||
| ) | ||
|
|
||
| def create(self, *, custom_template: CustomTemplate) -> CustomTemplate: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the API allows creation of multiple customtemplates at once, we could do something like this
| def create(self, *, custom_template: CustomTemplate) -> CustomTemplate: | |
| def create(self, *, custom_templates: list[CustomTemplate]) -> list[CustomTemplate]: |
| """Creates a new custom template. | ||
| Parameters | ||
| ---------- | ||
| custom_template : CustomTemplate | ||
| The custom template to create. | ||
| Returns | ||
| ------- | ||
| CustomTemplate | ||
| The created CustomTemplate object. | ||
| """ | ||
|
|
||
| response = self.session.post( | ||
| url=self.base_path, | ||
| json=[ | ||
| custom_template.model_dump( | ||
| mode="json", by_alias=True, exclude_unset=True, exclude_none=True | ||
| ) | ||
| ], | ||
| ) | ||
| return CustomTemplate(**response.json()[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| """Creates a new custom template. | |
| Parameters | |
| ---------- | |
| custom_template : CustomTemplate | |
| The custom template to create. | |
| Returns | |
| ------- | |
| CustomTemplate | |
| The created CustomTemplate object. | |
| """ | |
| response = self.session.post( | |
| url=self.base_path, | |
| json=[ | |
| custom_template.model_dump( | |
| mode="json", by_alias=True, exclude_unset=True, exclude_none=True | |
| ) | |
| ], | |
| ) | |
| return CustomTemplate(**response.json()[0]) | |
| """Create new custom templates. | |
| Parameters | |
| ---------- | |
| custom_templates : list[CustomTemplate] | |
| The custom templates to create. | |
| Returns | |
| ------- | |
| list[CustomTemplate] | |
| The list of created CustomTemplate objects. | |
| """ | |
| if isinstance(custom_templates, CustomTemplate): | |
| custom_templates = [custom_templates] | |
| response = self.session.post( | |
| url=self.base_path, | |
| json=[ | |
| custom_template.model_dump( | |
| mode="json", by_alias=True, exclude_unset=True, exclude_none=True | |
| ) | |
| for custom_template in custom_templates | |
| ], | |
| ) | |
| return [CustomTemplate(**x) for x in response.json()] |
what do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: why explicitly exclude unset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me!
Co-authored-by: Prasad <prasad@albertinvent.com>
…m/albert-labs/albert-python into ct-task-project-migration-updates
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def seeded_custom_templates(client: Albert, seed_prefix: str) -> Iterator[list[Location]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this function and generate_custom_template_seeds ?
and just define data=GeneralData(name=f"{seed_prefix}-general") instead of fetching from the seed?
Introduces 'IMAGE' as a new value in the DataType enum. Refactors the patching logic for required parameters in ParameterGroupCollection to avoid accumulating multiple updates and streamlines the session patch call.
Renamed 'users_with_access' to 'acl' in DataTemplate for clarity and consistency. Added CustomTemplateId as a valid type for Notebook's parent_id to support additional parent relationships.
No description provided.