Skip to content

Conversation

@FedericoNegri
Copy link
Contributor

@FedericoNegri FedericoNegri commented Aug 29, 2022

Multiple doc updates plus a few code changes:

  1. Project query: get_project now only queries projects by id consistently with the REST API. I introduced a separate method to query by name

    def get_project_by_name(self, name, last_created=True) -> Union[Project, List[Project]]:
         """
         Query projects by name. If no projects are found, an empty list is returned.
             In case of multiple projects with same name:
              - If `last_created = True`, the last created project is returned
              - If `last_created = False`, the full list of projects with given name is returned
         """
  2. JSON style print of resource objects. This PR includes a fix to make sure load_only fields are printed out. In general, printing a resource now looks like this:

    Old (DCS Python client style):

    In [2]: print(project)
    Project(
    id='02qpDM5mhNayzVMnCnJUwr',
    name='Mapdl Motorbike Frame',
    active=True,
    priority=1,
    creation_time=datetime.datetime(2022, 8, 30, 5, 41, 18, 97881, tzinfo=datetime.timezone(datetime.timedelta(0), '+0000')),
    modification_time=datetime.datetime(2022, 8, 30, 5, 41, 22, 426513, tzinfo=datetime.timezone(datetime.timedelta(0), '+0000')),
    file_storages=<marshmallow.missing>,
    statistics={'eval_status': {'aborted': 0, 'evaluated': 0, 'failed': 0, 'inactive': 0, 'pending': 50, 'prolog': 0, 'running': 0, 'timeout': 0}, 'files_size': 14444, 'num_jobs': 50}
    )

    New:

    In [2]: print(project)
    {
      "id": "02qpDM5mhNayzVMnCnJUwr",
      "name": "Mapdl Motorbike Frame",
      "active": true,
      "priority": 1,
      "creation_time": "2022-08-30T05:41:18.097881+00:00",    
      "modification_time": "2022-08-30T05:41:22.426513+00:00",
      "statistics": {
        "eval_status": {
          "aborted": 0,
          "evaluated": 0,
          "failed": 0,
          "inactive": 0,
          "pending": 50,
          "prolog": 0,
          "running": 0,
          "timeout": 0
        },
        "files_size": 14444,
        "num_jobs": 50
      }
    }

@FedericoNegri FedericoNegri requested a review from ojkoenig August 29, 2022 16:37
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Aug 29, 2022
return get_project(self.client, self.url, id, name)
return get_project(self.client, self.url, id)

def get_project_by_name(self, name, last_created=True) -> Union[Project, List[Project]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ojkoenig Please have a look at these changes. Trying to improve the querying projects by name...

@FedericoNegri FedericoNegri changed the title Doc update Doc update + get_project_by_name and pretty print Aug 30, 2022
Copy link
Contributor

@ojkoenig ojkoenig left a comment

Choose a reason for hiding this comment

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

Thought about more standard alternatives for your get_project_by_name(...) but did not really succeed to come up with something better, and I understand your proposal to keep convenience and access latest project of a given name easy.

@FedericoNegri FedericoNegri merged commit 0ec851b into main Aug 30, 2022
@FedericoNegri FedericoNegri deleted the fnegri/improve_doc branch August 31, 2022 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants