Giter Club home page Giter Club logo

moncli's People

Contributors

alexalligator avatar archana511 avatar ashatz avatar aswath-m avatar aswathm78 avatar ccolligan avatar harryrobbins avatar lexsong avatar manjots avatar uri-may avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

moncli's Issues

get_groups() complexity error

When I try and grab the groups for a specific board, I get a MondayApiError that says that my request is too complex and is over their complexity limit. This particular board only has 5 groups so I am not sure if its some general issue with Monday's API, moncli or my own inexperience with python.

>>> groups = boards[0].get_groups()
Traceback (most recent call last):
  File "<pyshell#38>", line 1, in <module>
    groups = boards[0].get_groups()
  File "C:\Python37\lib\site-packages\moncli\entities\board.py", line 97, in get_groups
    ids=[int(self.id)])[0]
  File "C:\Python37\lib\site-packages\moncli\api_v2\handlers.py", line 20, in get_boards
    return execute_query(api_key, constants.BOARDS, *argv, **kwargs)
  File "C:\Python37\lib\site-packages\moncli\api_v2\handlers.py", line 208, in execute_query
    result = requests.execute_query(api_key, operation=operation)
  File "C:\Python37\lib\site-packages\moncli\api_v2\requests.py", line 35, in execute_query
    raise MondayApiError(error_query, status_code, errors)
moncli.api_v2.exceptions.MondayApiError: ('{"query": "query { boards (ids:[553122091]) { groups { id, title, archived, color, deleted, items { id }, position } } }", "variables": null}', 200, [{'message': 'Query has complexity of 1016020, which exceeds max complexity of 1000000'}])

That is the error that IDLE is spitting out when I attempt to get all of the groups on my first board. boards[0].get_items() and get_columns() works and returns the correct information.

TimelineValue format doesn't handle milestone

it looks like you're parsing it in the reading from api, however when you format it back out, it doesn't look like you're handling it

if value['visualization_type'] == 'milestone':
is_milestone = True

the format method doesn't addend the visualization_type regardless of the valule

Apostraphe in a name seems to cause issues for API

This throws an error from the API:
item.change_multiple_column_values({'name': "O'Dool", 'text': 'sometext'})

This does not:
item.change_multiple_column_values({'name': 'ODool', 'text': 'sometext'})

Board get item request formats the query incorrectly

Hello,
I am trying to get the items of a board with the column values. I tried the method that it says to do in the documentation, but I got an error that the query was formatted incorrectly.

board = client.get_boards('id', ids=[board_id])[0]
board_items = board.get_items('id', 'name', 'column_values.id', 'column_values.title', 'column_value.value')

This is the error that I have been getting.

MondayApiError: ('{"query": "query { boards (ids:[board_id]) { column_values { id, title }, column_value { value }, items { column_values { id, title, text, value, additional_info }, id, name }, id } }", "variables": null}', 200, '', [{'message': "Field 'column_values' doesn't exist on type 'Board'", 'locations': [{'line': 1, 'column': 37}], 'fields': ['query', 'boards', 'column_values']}, {'message': "Field 'column_value' doesn't exist on type 'Board'", 'locations': [{'line': 1, 'column': 66}], 'fields': ['query', 'boards', 'column_value']}])
It is formatting the query with column_value as a field of board and of items, and column_values as a field of board.
Thanks!

Unable to install version 0.1.7 for dropdown values

I would like to install version 0.1.7 so that I can get dropdown values instead of just the value IDs. When trying to install version 0.1.7 I get an error:

mbp ~ % pip3 install --user moncli==0.1.7 
ERROR: Could not find a version that satisfies the requirement moncli==0.1.7 (from versions: 0.1, 0.1.1, 0.1.2, 0.1.4, 0.1.5, 0.1.6)
ERROR: No matching distribution found for moncli==0.1.7

Is there any other way to get the text values from a dropdown with version 0.1.6? If not, how would I go about getting access to 0.1.7?

cannot retrieve column value to send file to files column

File "c:\Python38\Scripts\Projects\moncliTest.py", line 21, in <module>
    file_column = item.get_column_value(id='files1')
  File "C:\Python\lib\site-packages\moncli\entities\item.py", line 107, in get_column_value 
    self.get_column_values()
  File "C:\Python\lib\site-packages\moncli\entities\item.py", line 73, in get_column_values 
    column_value = create_column_value(id, column_type, title)
  File "C:\Python\lib\site-packages\moncli\columnvalue.py", line 601, in create_column_value
    return FileValue(id, title)
  File "C:\Python\lib\site-packages\moncli\columnvalue.py", line 149, in __init__
    self.files: list = kwargs['files']
KeyError: 'files'
  

Underlying code looks like this, where FILEPATH is a valid filepath:

file_column = item.get_column_value(id='files1')
file_asset = item.add_file(file_column=file_column,file_path=FILEPATH)

I can correctly add files to updates, but being able to add them to a files column would be significantly more useful in my use case.

group.py have errors on mutiple values for keyword argument 'groups'

This error occur in get_items where if the caller supplied a kwargs parameter, the call will have mutiple "groups" defined.

group.py / get_items

    ```
    args = ['groups.items.' + field for field in args]
    if kwargs:
        kwargs = {'groups': {'items': kwargs, 'ids': [self.id]}}
        
    items_data = client.get_boards(
        self.__creds.api_key_v2, 
        *args,
        ids=[int(self.__board_id)],
        limit=1,
        groups={'ids': [self.id]},
        **kwargs)[0]['groups'][0]['items']

Error : 
got multiple values for keyword argument 'groups'

kwargs = {'groups': {'items': kwargs, 'ids': [self.id]}}
groups={'ids': [self.id]},


Solution is to either get rid of "groups" in the api call or dont use "groups" key in filling in the "items"

Item.state is always None?

Hi All,

Happy Mondaying!

I've seen that a given items 'state' attribute is showing up as None for me, regardless of it's actual state.

If I retrieve 3 items (one active, one archived, one deleted), all items show a state of None.

Just checking if I'm missing something or whether this is a bug!

Thank you in advance :)

get_groups() doesn't finish executing

Hi, I was using get_groups() and even after waiting for 5 minutes the program didn't move on (I used the sample Monday "All in one software templates" to test). When using debugger I got:

Evaluating: boards[0].get_groups() did not finish after 3.00s seconds.
This may mean a number of things:

  • This evaluation is really slow and this is expected.
    In this case it's possible to silence this error by raising the timeout, setting the
    PYDEVD_WARN_EVALUATION_TIMEOUT environment variable to a bigger value.

  • The evaluation may need other threads running while it's running:
    In this case, it's possible to set the PYDEVD_UNBLOCK_THREADS_TIMEOUT
    environment variable so that if after a given timeout an evaluation doesn't finish,
    other threads are unblocked or you can manually resume all threads.

    Alternatively, it's also possible to skip breaking on a particular thread by setting a
    pydev_do_not_trace = True attribute in the related threading.Thread instance
    (if some thread should always be running and no breakpoints are expected to be hit in it).

  • The evaluation is deadlocked:
    In this case you may set the PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT
    environment variable to true so that a thread dump is shown along with this message and
    optionally, set the PYDEVD_INTERRUPT_THREAD_TIMEOUT to some value so that the debugger
    tries to interrupt the evaluation (if possible) when this happens.

Which doesn't really tell anything we already don't know, here is the code which can be used to reproduce the issue:

from moncli import MondayClient

client = MondayClient(user_name='[email protected]', api_key_v1='', api_key_v2 ='INSERT_KEY_HERE')
boards = client.get_boards(page=1, limit=50)

for every in boards:
print(every.get_groups())

Expected Response:
I would receive either the object containing the groups or an error

Received Response:
Infinite waiting loop

I would like to clarify that I didn't hit my Monday API rate limit.

Thank You

Nose requirement in setup.py

Hello and thank you for this great library.

Wondered if it would be possible to move nose from install_requires to tests_require in setup.py.

It appears to only be used to run tests and shouldn't be necessary for consumers of this library.

Thanks again.

Adding people to an item not working?

It appears the add_people() function is not working. Perhaps, I'm not doing right. I followed your documentation and code and I'm pretty sure everything is correct, but people are not being added to my items. Everything else works great.

user_ids is a list of user's ids.

  1. I get the board id.
  2. Then get the group id.
  3. Then add the item to the appropriate group.
  4. Once I have the task(item) object, I call get_column_value().
  5. I iterate over the user ids and attempt to add them to the item with add_people().
def create_item(client, board_id, group_id, task_name, user_ids):
    print("Creating items")
    task = None
    try:
        the_board = client.get_board(id=board_id)
        the_group = the_board.get_group(id=group_id)
        print("Creating item --- {0} ---".format(task_name))
        print(user_ids)
        task = the_group.add_item(item_name=task_name)
        t = task.get_column_values()
        for value in t:
            if type(value) == PeopleValue:
                for personid in user_ids:
                    print("adding owner ---- {0}".format(personid))
                    value.add_people(id=personid, kind=PeopleKind.person)
                    print("The people are:::: {0}".format(value.persons_and_teams))
    except Exception as e:
        print("ERROR:::::: {0}".format(e))
    return task_id

The person_and_teams list does reflect the change, but nothing shows up in Monday.

I also tried using the add_item() function on a group object with the column_values=column_values parameter (dictionary), but that didn't work either.

Any suggestions?

I really like the idea of automating some of my boards. It can get quite tedious to build them out in the GUI. Adding people is essential in our organization.

add_item timeout for HTTP connection pool (read timeout = 10)

I was working with the board.add_item function and noticed that when running the function for multiple items in a dataframe, I received an error with a readtimeout. Is there any way to increase the amount of time it takes for the function to timeout? The default seems to be 10, but I would like for it to be increased.

Screen Shot 2022-07-07 at 11 45 26 AM

Error Installing moncli

using "pip install moncli" I get the following error:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/man/man1/nosetests.1'
Consider using the `--user` option or check the permissions.

1.0.5 issues: create_column_value

Hi, I am encountering issues after upgrading today to the latest version 1.0.5,

column_value = create_column_value(id='check', column_type=ColumnType.checkbox, checked=True)
This line gives me this error
schematics.exceptions.DataError: {"checked": "Rogue field"}

I don't have this error if I don't specify the value and change it after creation:
column_value = create_column_value(id='check', column_type=ColumnType.checkbox)
column_value.checked = True

The above occurs within a view object returned by .items(), it does not trigger the error outside of it

Does add_item still works?

based on the documentation :
new_item_with_values = board.add_item(item_name='New Item With Text Value', column_values=column_values)

I am trying to add just a simple item with a text and a number it bombed out easily :

x = "Bolt"
sku = 45
dateval = datetime.today().strftime('%Y-%m-%d')
g_Board.add_item(item_name = x, column_values = {"text1": dateval, "sku" : sku})

moncli.api_v2.exceptions.MondayApiError: ('{"query": "mutation { create_item (column_values:\"{\\\"text1\\\": \\\"2021-02-15\\\", \\\"skus\\\": 45}\", item_name:\"Bolt\", board_id:1052214907) { id, name, created_at, creator_id, state } }", "variables": null}', 400, 'ColumnValueException', ['invalid value, please check our API documentation for the correct data structure for this column. https://monday.com/developers/v2#column-values-section'])

`get_board_by_id` and `get_board_by_name` only search among active boards

By default the Monday v2 API only acts on active boards:

# This query returns an empty list
query	{
  boards(ids:[<archived board id>]){
    id
    name
    state
  }
}
# This query returns the board
query	{
  boards(state:all, ids:[<archived board id>]){
    id
    name
    state
  }
}

Moncli's get_boards method allows the user to pass in a state enum to get all boards (both active and archived). However, the get_board_by_id and get_board_by_name methods do not and because they don't set the state to all internally, the methods raise BoardNotFound if the board is archived.

I propose that we change get_board_by_id and get_board_by_name so that they add state=all to the graphql query.
Something like:

def get_board_by_id(self, id: str):

        boards_data = client.get_boards(
            self.__creds.api_key_v2, 
            *GET_BOARD_FIELD_LIST,
            ids=[int(id)],
            limit=1,
            state=State.all)  # <-- New line

        if len(boards_data) == 0:
            raise ex.BoardNotFound('id', id)

        return Board(creds=self.__creds, **boards_data[0])

I'm happy to write a PR for this if you like :)

Error while retrieving item with a special character

Error while retrieving item with a special character

When searching for an item with apostrophe ('), I get this error:

('{"query": "query { items_by_column_values (board_id:499892072, column_id:\"name\", column_value:\"BJ\"s
Wholesale Club\") { id, name, created_at, creator_id, state } }", "variables": null}', 200, '', [{'message': 'Parse error on "Wholesale" (IDENTIFIER) at [1, 88]', 'locations': [{'line': 1, 'column': 88}]}])_

This is how I'm searching the item:

column_value = board.get_column_value(search_column_id)
column_value.name = value
item = board.get_items_by_column_values(column_value)

Doesnt work with "color mapping"

Getting column value where the rows have colors bombs out with an exception.

ERROR] DataError: 
{
    "color_mapping": "Rogue field"
}

My code iterate thru each row getting the value of a column as item.

Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 293, in lambda_handler
    Start()
  File "/var/task/lambda_function.py", line 274, in Start
    colvalue = x.get_column_value(id=g_IdsColumnToSearch)
  File "/opt/python/lib/python3.7/site-packages/moncli/entities/item.py", line 577, in get_column_value
    for column_value in self.get_column_values(*args):
  File "/opt/python/lib/python3.7/site-packages/moncli/entities/item.py", line 528, in get_column_values
    if columns_map[id].settings:
  File "/opt/python/lib/python3.7/site-packages/moncli/entities/objects.py", line 124, in settings
    return StatusSettings(settings_obj)
  File "/opt/python/lib/python3.7/site-packages/schematics/models.py", line 235, in __init__
    app_data=app_data, **kwargs)
  File "/opt/python/lib/python3.7/site-packages/schematics/models.py", line 299, in _convert
    return func(self._schema, self, raw_data=raw_data, oo=True, context=context, **kwargs)
  File "/opt/python/lib/python3.7/site-packages/schematics/transforms.py", line 428, in convert
    return import_loop(cls, mutable, raw_data, import_converter, **kwargs)
  File "/opt/python/lib/python3.7/site-packages/schematics/transforms.py", line 174, in import_loop
    raise DataError(errors, data)

Files

Hi there ! Can you provide an example of query for Files ? Thanks !

Use of hasattr with private variables

Background

If a Board is instantiated with a list of items then the item ids are stored as a list in a private variable called __item_ids.

class Board():

    def __init__(self, **kwargs):
        # ... code hidden

        for key, value in kwargs.items():
           # ... code hidden
            elif key == 'items':
                self.__item_ids = [int(item['id']) for item in value]

            elif key == 'owner':
                self.__owner_id: str = value['id']

Board's get_items method checks to see whether it already has value for __item_ids and if not it fetches them from Monday.

def get_items(self):
        
        field_list = [...]

        if not hasattr(self, '__item_ids'):  # <---- Checking to see if it already has __item_ids

            items = client.get_boards(
                self.__creds.api_key_v2,
                'items.id', 
                ids=[int(self.id)])[0]['items']

            self.__item_ids = [int(item['id']) for item in items]

        items_data = client.get_items(
            self.__creds.api_key_v2, 
            *field_list,
            ids=self.__item_ids, 
            limit=1000)

        return [Item(creds=self.__creds, **item_data) for item_data in items_data] 

Problem

The problem is that hasattr with always return False for variables starting with a double underscore. This is expected behaviour for private variables.

The knock on effect of this is that get_items will always make the call to Monday, even when this is unnecessary.

Proposed Solution

Rename __item_ids to _item_ids or even just item_ids so that hasattr works as expected

I'm happy to volunteer a PR if you like. 👍

Unable to Get Items By Column Value

Hi!!

Apologies for bothering you again, but when I try to create a status column value (with a view to using this column value to search for items containing that column value), I receive:

File /moncli/columnvalue.py", line 682, in create_column_value
return StatusValue(id, title, label=kwargs['label'], settings=kwargs['settings'])
KeyError: 'settings'

The code that calls the create column value function is:

sync_val = create_column_value(id='status5', title='Sync', column_type=ColumnType.status, label='Sync Now')

Would you have any insight into what I'm doing wrong?

Thanks in advance :)

Proper abstraction over graphql

Hi there,

I'm trying to switch over to this library from the ProdPerfect/monday library and I wasn't able to get it working with even a simple example. I could do board.get_items() but if I added any of the columns it would either build the query incorrectly or time out. I don't have a huge data set (250 items with 50 columns), but I see Monday is clamping down on API resource limits pretty heavily as of next week [1] so I suspect there needs to be more control over exactly what is fetched.

This is what I ended up with, querying graphql directly:

import requests

# Define the column IDs we care about (and the corresponding label for those headings)
MONDAY_COLS = (
    ("name", "Name"),
    ("text7", "Account code"),
    ("status", "Customer Status"),
    ("date5", "Loss Date"),
    ("loss_reason", "Loss Reason"),
    ("status7", "Product"),
    ("dropdown", "Sales Lead"),
    ("status35", "Attribution"),
    ("weblink8", "Server URL"),
    ("status65", "Currency"),
)

# Generic GraphQL helper (read only)
def monday_query(query):
    api_url = "https://api.monday.com/v2"
    headers = {"Authorization" : MONDAY_ACCESS_KEY}
    data = {'query' : query}
    r = requests.post(url=api_url, json=data, headers=headers)
    return r.json()

# Grab the column values for the Column IDs and Item IDs provided
def get_column_values_for_ids(ids, cols):
    id_str = ','.join(ids)
    field_str = ','.join([field for field, _ in cols])
    query = """{
        items (limit: 100, ids: [%s]) {
            name column_values (ids: [%s]) {
                title id type text
            }
        }
    }""" % (id_str, field_str)
    data = monday_query(query)
    return data['data']['items']


def get_items_from_monday(cols, board_id, logger=None):
    all_items = []
    page_no = 1
    while True:
        items_query = """{
            boards (ids: [%s]) {
                items (limit: 100, page: %s) {
                    id
                }
            }
        }""" % (str(board_id), str(page_no))
        res = monday_query(items_query)
        items = res['data']['boards'][0]['items']
        ids = [item['id'] for item in items]
        if not ids:
            break

        logger(f"Fetching data for {len(ids)} items ...")
        data = get_column_values_for_ids(ids, cols)
        all_items.extend(data)
        page_no += 1

    return all_items

Specifically,

  • I'm limiting the columns that get returned with name column_values (ids: [%s]) {
  • I'm fetching 100 item IDs at a time, then fetching the column values for those 100 IDs (100 being the new maximum the Monday API allows you to fetch).

Given the new API limits, is more fine grained control over the data fetched something that you'd implement?

Thanks for the work on the library to date.

[1] https://community.monday.com/t/adjustments-to-api-rate-limiting/18611

dependency missing keyError in exception

in complex.py

class DependencyValue(ComplexNullValue):
"""An item link column value."""

native_type = list
native_default = []

def _convert(self, value):
    try:
        list_ids = value['linkedPulseIds']
        return [int(value['linkedPulseId']) for value in list_ids ]
    except IndexError:
        return []

the except needs to also do keyError, monday seems to send back

  {
                    "id": "dependent_on",
                    "text": "",
                    "value": "{\"changed_at\":\"2021-04-28T19:55:53.979Z\"}"
                },

on a field that has been deleted

Fails to retrieve 'timerange' values for some items on board

Hi there,

Im finding when I iterate through a board and try to pull the value for a timerange style column, it consistently fails to pull the value for some items, repeated running appears to produce the same results. i.e. it skips the same items each time.

Ive attached a screen grab of the board, and a screen grab of the output from a basic script I wrote to PoC the issue. Ive attached the script too.

Is it something ive messed up?

Many thanks.

Cheers,

Mat

date_sample.py.txt
Screenshot 2022-02-02 at 09 56 21
Screenshot 2022-02-02 at 09 57 30

Breaking Change introduced at 2.0.6 for get_items_by_multiple_column_values

I've been leveraging the moncli library for several months and in trying to bring my frameworks up to date, I have found that the change introduced in 2.0.6 to allow for apostrophe's in values has broken the ability to provide a list to the function.

9a46f10 is the commit in question.

Method Signature in use:

get_items_by_multiple_column_values(
            myBoard.columns['text'],
            [data['company']],
            get_column_values=True,
            as_model=None
        )

The resulting change creates an invalid graphQL query on lists.

column_values:['data['company']'s value is here']

Monday's API throws parse error on ' after [

Iterating Columns Fails

This appears to have only just started happening and only against the European Instances, but when I run an established script (that worked last week) that contains:

    src_items = src_board.get_items()
    for src_item in src_items:
        for src_column in src_item.column_values:

I get the error:

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%Y-%m-%d'

Again running the same script against the US instance completes correctly.

Appears to happen when you hit a column of type Date that is not populated (not has ever been) populated with any date on a board that has been imported from an .xlsx. Even if you are testing against the title and not touching the value.

Feature Request: Requests timeout

Feature request:

Could you add a timeout to the requests sent to monday?

Ideally I would suggest making this an optional parameter (with sensible default) than can be passed when initialising the client:

class MondayClient():
    def __init__(self, user_name: str, api_key_v1: str, api_key_v2: str, timeout:int=10):

The client would then send the timeout to all the api functions (in the same way api_key is passed along to every function call).

boards_data = client.get_boards(
            self.__creds.api_key_v2, 
            self.timeout,
            'id', 
            'name', 
            **kwargs)

Or else, just hardcode a reasonable timeout into all the requests (10 seconds?).

What do you think?

P.S. Thanks for this awesome library :)

DataError when finding file_column to upload item in v1.0

This is the column that I am attempting to access to upload the file to:

{'id': 'files1', 'title': 'Completion Files', 'text':''}

Here is the portion of my script that gets the correct item that I want to upload files to, and the correct column.

items = board.get_items(ids=[self.customer.idnum])
item = items[0]
filecol = item.get_column_value(id='files1')  
item.add_file(filepath,file_column=filecol)

Once the script reaches this point, it gives a DataError:

Traceback (most recent call last):
  File "c:\Python38\Scripts\Projects\BarkerConstructionLLC\Monday_Client.py", line 169, in <module>    
    find_and_fill(root)
  File "c:\Python38\Scripts\Projects\BarkerConstructionLLC\Monday_Client.py", line 86, in find_and_fill
    doc.fill(customer)
  File "c:\Python38\Scripts\Projects\BarkerConstructionLLC\docs.py", line 130, in fill
    filecol = item.get_column_value(id='files1')
  File "C:\Python\lib\site-packages\moncli\entities\item.py", line 577, in get_column_value
    for column_value in self.get_column_values(*args):
  File "C:\Python\lib\site-packages\moncli\entities\item.py", line 528, in get_column_values
    if columns_map[id].settings:
  File "C:\Python\lib\site-packages\moncli\entities\objects.py", line 124, in settings
    return StatusSettings(settings_obj)
  File "C:\Python\lib\site-packages\schematics\models.py", line 232, in __init__
    data = self._convert(raw_data,
  File "C:\Python\lib\site-packages\schematics\models.py", line 299, in _convert
    return func(self._schema, self, raw_data=raw_data, oo=True, context=context, **kwargs)
  File "C:\Python\lib\site-packages\schematics\transforms.py", line 428, in convert
    return import_loop(cls, mutable, raw_data, import_converter, **kwargs)
  File "C:\Python\lib\site-packages\schematics\transforms.py", line 174, in import_loop
    raise DataError(errors, data)
schematics.exceptions.DataError: {"done_colors": "Rogue field", "hide_footer": "Rogue field"}

I am not sure if the issue is on my end, but I am also confused on whether I should be using this method https://github.com/trix-solutions/moncli#item or this https://github.com/trix-solutions/moncli#uploading-files method to upload files.

Thanks a lot guys!

Can't send values to Board column

Hi.

I am trying to send value to the Script column (attaching a screenshot to confirm the column type, which I am assuming to be text.)
Screen Shot 2023-01-22 at 10 21 05 PM

On running the following commands:

column_values = {'Script': 'https://docs.google.com/document/d/DUMM/edit'}
new_item_with_values = board_by_id.add_item(item_name='New Item With Text Value', column_values=column_values)

I see an entry like such:
Screen Shot 2023-01-22 at 10 25 14 PM

Not sure what is wrong here. Any suggestions?

Cannot import name 'MondayClient' from 'moncl

Error

File "...Monday_API\API_upload_file_DEV.py", line 6, in
from moncli import MondayClient
ImportError: cannot import name 'MondayClient' from 'moncli' (C:\Python310\lib\site-packages\moncli_init_.py)

Versions

Python. 3.10.5
moncli. 2.0.14

Add Item column values

I'm trying to add a new item with column values, it adds the item but it doesn't add the column_values, here is what i tried:

column_values={'t-name': '1'}
new_item_with_values = board.add_item(item_name='test',column_values=column_values)

Eventually i want to add multiple column values.

thank you

Updating linked column value

I got stuck when I try to update a item column value (provider_name) that it s linked to another board (providers “table").

This is my example code:

main_board = moncli.client.get_board_by_id(1234567890)
providers_board = moncli.client.get_board_by_id(9876543210)
provider = providers_board.get_items_by_multiple_column_values(column='name', column_values=['John Doe'])[0]
item = main_board.get_items_by_multiple_column_values(column='name', column_values=['2131361'])[0]
item.change_column_value(id='provider_name',column_value=[provider])

When I run it I got this error:

`UnboundLocalError: local variable 'column_id' referenced before assignment`

I red your wiki and searches in internet without success.
Do you have an example code to update a linked column value of an linked item?

I will really appreciate your help

Board get item by column value does not work by items name

I am trying to get an item by its name, and I am following along what it says to do in the documentation
column_id = 'test_column'
column_value = board.get_column_value(column_id)
column_value.text = 'Search Text'
items = board.get_items_by_column_values(column_value, 'id', 'name')
items
[{'id': '1234567', 'name': 'New Item'}]
The board.get_column_value function does not work and I get the following error: AttributeError: module 'moncli.column_value' has no attribute 'NameValue'.
Any guidance on how to fix this and get an item by its name would be appreciated. Thank you!

Converting a board to DataFrame works slowly

Hello,

I'm trying to get a Monday board and save it to a DataFrame but it takes a few seconds per row. I was wondering if I'm using moncli wrong for this and would love your comments.

mdGroupsBoard = mondayClient.get_board(id=groupsBoardID)
groupsDF = pd.DataFrame()
for item in mdGroupsBoard.items:
        Hidden = item.get_column_value(id='check')
        Subitems = item.get_column_value(id='subitems0')
        Status = item.get_column_value(id='status')
        groupsDF = groupsDF.append(
        {
            'Group ID':[item.id],
            'Group name':[item.name],
            'Rules':[Subitems.value],
            'Hidden':[Hidden.checked],
            'Status':[Status.label]
        }, ignore_index=True
        ))

Thanks!

Reference on issue # 25

Hi,

I have moncli 0.1.5 installed and have the same problem on (#25), I would like to change the status of an item but get this same error.

Version
Name: moncli Version: 0.1.5 Summary: Moncli, a pythonic/DDD client for Monday.com Home-page: https://github.com/trix-solutions/moncli Author: Andrew Shatz, Trix Solutions Author-email: [email protected] License: UNKNOWN Location: /home/ubuntu/anaconda3/lib/python3.6/site-packages Requires: requests, nose Required-by:

Process:
`
--- Create Item
day = dt.datetime.now()
item_name = f'Getting Tweets | {day.strftime("%Y-%m-%d %H:%M:%S")}'
group_id='topics'

item = board.add_item(item_name=item_name, group_id=group_id)
print(f'Id: {item.id} | Name: {item.name}')

--- Try to change status

status_value = create_column_value(id='status', title='Status', column_type=ColumnType.status, label='Done')
item = item.change_column_value(column_value=status_value)

And get this error:


KeyError Traceback (most recent call last)
in
----> 1 status_value = create_column_value(id='status', title='Status', column_type=ColumnType.status, label='Done')
2 item = item.change_column_value(column_value=status_value)

~/anaconda3/lib/python3.6/site-packages/moncli/columnvalue.py in create_column_value(id, column_type, title, **kwargs)
680
681 if kwargs.contains('label'):
--> 682 return StatusValue(id, title, label=kwargs['label'], settings=kwargs['settings'])
683
684 if kwargs.contains('index'):

KeyError: 'settings'

`

get_column_value ValueError: time data '' does not match format '%H:%M:%S'

Hi,
I want to upload a file to an item, so I do like you explain :
image
The problem is that I think you go over all the columns of the item and try to convert, but when it encountered a date column with no hours, like this : {'date': '2022-03-01', 'time': ''} an error occurs because the time is empty.
ValueError: time data ''' does not match format '%H:%M:%S'

Capture d’écran 2022-03-12 à 01 22 11

Do you know what can be the problem?
Thanks.

Can't retrieve update's files

Hi,

I'm trying to get update's file:

update = item.get_updates()[0]
f = update.get_files('name', 'url')

However, I get a timeout error:
_requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.monday.com', port=443): Read timed out. (read timeout=10)

Let me know if you need more info!

Issues with Location column type

I've recently started working with location column type in my boards. When trying to just get_items() from the board, I have been seeing the below error. The first time I received it, I assumed it was an issue with my column, so I deleted the column, replaced it with a new location column, then the problem was gone. I ran my script for about a week with the new column and then started seeing this error again today, so of course I have too much data now to just delete and replace again. I'm assuming that one of the locations selected on an item is missing a Lat value, but I don't have any way to see that in the UI, because the location values are just selected from the dropdown, and of course I can't pull the list of items, because I get this error. Any ideas how to avoid this error or a fix that can account for it?

Traceback (most recent call last): File "/Users/brentleecass/PycharmProjects/monday_practice/upcoming_expansions_automations.py", line 77, in <module> scheduled_items = scheduled_items_group.get_items('name') # pull items in scheduled items group File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/entities/group.py", line 359, in get_items items = [en.Item(creds=self.__creds, **item_data) for item_data in items_data] File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/entities/group.py", line 359, in <listcomp> items = [en.Item(creds=self.__creds, **item_data) for item_data in items_data] File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/entities/item.py", line 147, in __init__ self.__column_values.append(cv.create_column_value(column.column_type, settings_str=column.settings_str, **data)) File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/column_value/__init__.py", line 22, in create_column_value return getattr( File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/column_value/base.py", line 57, in __init__ self._value = self._convert(value) File "/Users/brentleecass/PycharmProjects/monday_practice/venv/lib/python3.9/site-packages/moncli/column_value/simple.py", line 216, in _convert return Location(lat=value['lat'],lng=value['lng'],address=value['address']) KeyError: 'lat'

Item.change_name Documentation Typo

Hi Team,

In the docs, the Item entity is described as having a "change_name" method, however today I saw that the method is in fact;

Item.change_item_name()

Hope this helps and I haven't misread anything!

NameError while creating MondayClient

Hi Team,

Great work on this package, it holds so much potential!

Unfortunately, I'm getting a NameError whenever I try to create the MondayClient object. Im using MacOS High Sierra 10.13.6 with Python 3.8.

Sorry if it seems like a rookie error but I'm new to this, I hope you can help!

Thakns in advance!

Can't access board after Monday update

Hey team,

I have been using Moncli to power by automations for almost 8 months now, but now none of the code works.

Upon running:
client.get_board(id=required_configs['BOARD_ID'])

moncli.api_v2.exceptions.MondayApiError: ('{"query": "query { boards (ids:[2528587524], limit:1) { id, name, board_folder_id, board_kind, communication, description, permissions, pos, state, workspace_id, updated_at } }", "variables": null}', 200, '', [{'message': "Field 'pos' doesn't exist on type 'Board'", 'locations': [{'line': 1, 'column': 126}], 'path': ['query', 'boards', 'pos'], 'extensions': {'code': 'undefinedField', 'typeName': 'Board', 'fieldName': 'pos'}}])

Can we work on fixing this asap?

from moncli import MondayClient ERROR

Hi,

There is a problem importing moncli:

from moncli import MondayClient


AttributeError Traceback (most recent call last)
in
----> 1 from moncli import MondayClient

~/anaconda3/lib/python3.6/site-packages/moncli/init.py in
----> 1 from .entities import MondayClient
2 from .enums import *
3 from .columnvalue import create_column_value

~/anaconda3/lib/python3.6/site-packages/moncli/entities/init.py in
----> 1 from .client import MondayClient

~/anaconda3/lib/python3.6/site-packages/moncli/entities/client.py in
----> 1 import moncli.entities.exceptions as ex
2 from .. import api_v2 as client
3 from ..enums import BoardKind, NotificationTargetType
4 from .objects import MondayClientCredentials, Tag, Update, Notification
5 from .board import Board

AttributeError: module 'moncli' has no attribute 'entities'

Webhook

Hi there ! Can you provide an example to verify a Webhook ? Thanks !

Timeline Fields causing get_items crash

from_date = datetime.strptime(value['from'], DATE_FORMAT)

When a timeline field somehow gets an errant value without from, or to values (example below), the library fails to pull in items from get_items calls.

The following is an example from our board. In our efforts with monday.com support to attempt to get more information on how this can occur, they were unable to successfully replicate this issue in their API. FURTHER, these fields bypass the audit log/activity log and the support teams failed to update their API to track these changes.

{
  "id": "timeline",
  "value": "{\"changed_at\":\"2022-07-11T13:08:20.385Z\"}",
  "text": ""
}

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.